[qet] qet/qet: [5263] Element editor : Now every "old text" are converted to the new dynamic text, when open an element in the element editor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [5263] Element editor : Now every "old text" are converted to the new dynamic text, when open an element in the element editor
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 11 Mar 2018 15:44:24 +0100
Revision: 5263
Author: blacksun
Date: 2018-03-11 15:44:21 +0100 (Sun, 11 Mar 2018)
Log Message:
-----------
Element editor : Now every "old text" are converted to the new dynamic text, when open an element in the element editor
Modified Paths:
--------------
trunk/sources/editor/elementscene.cpp
trunk/sources/editor/graphicspart/partdynamictextfield.cpp
trunk/sources/editor/graphicspart/partdynamictextfield.h
Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp 2018-03-11 13:38:41 UTC (rev 5262)
+++ trunk/sources/editor/elementscene.cpp 2018-03-11 14:44:21 UTC (rev 5263)
@@ -971,7 +971,6 @@
continue;
CustomElementPart *cep = nullptr;
PartDynamicTextField *pdtf = nullptr;
- bool convertibleTextField = false;
if (qde.tagName() == "line") cep = new PartLine (m_element_editor);
else if (qde.tagName() == "rect") cep = new PartRectangle(m_element_editor);
@@ -983,14 +982,7 @@
else if (qde.tagName() == "arc") cep = new PartArc (m_element_editor);
else if (qde.tagName() == "dynamic_text") cep = new PartDynamicTextField (m_element_editor);
//For the input (aka the old text field) we try to convert it to the new partDynamicTextField
- else if (qde.tagName() == "input")
- {
- convertibleTextField = PartDynamicTextField::canImportFromTextField(qde);
- if(convertibleTextField)
- cep = pdtf = new PartDynamicTextField(m_element_editor);
- else
- cep = new PartTextField(m_element_editor);
- }
+ else if (qde.tagName() == "input") cep = pdtf = new PartDynamicTextField(m_element_editor);
else continue;
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep))
@@ -1000,7 +992,7 @@
loaded_parts<<qgi;
- if(convertibleTextField)
+ if(pdtf)
pdtf->fromTextFieldXml(qde);
else
cep->fromXml(qde);
Modified: trunk/sources/editor/graphicspart/partdynamictextfield.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partdynamictextfield.cpp 2018-03-11 13:38:41 UTC (rev 5262)
+++ trunk/sources/editor/graphicspart/partdynamictextfield.cpp 2018-03-11 14:44:21 UTC (rev 5263)
@@ -25,24 +25,6 @@
#include <QColor>
#include <QMatrix>
-/**
- * @brief PartDynamicTextField::PartDynamicTextField
- * Return if a dynamic text field can import information from the xml definition of a text field
- * @param editor
- * @param parent
- */
-bool PartDynamicTextField::canImportFromTextField(const QDomElement &dom_element)
-{
- if(dom_element.tagName() != "input")
- return false;
-
- QString tagg = dom_element.attribute("tagg", "none");
- if(tagg == "none")
- return true;
- else
- return false;
-}
-
PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent) :
QGraphicsTextItem(parent),
CustomElementPart(editor),
@@ -202,11 +184,22 @@
*/
void PartDynamicTextField::fromTextFieldXml(const QDomElement &dom_element)
{
- if(canImportFromTextField(dom_element))
- {
+ if(dom_element.tagName() != "input")
+ return;
+
setFont(QETApp::diagramTextsFont(dom_element.attribute("size", QString::number(9)).toInt()));
- setTextFrom(DynamicElementTextItem::UserText);
- setText(dom_element.attribute("text", "_"));
+
+ if(dom_element.attribute("tagg", "none") == "none")
+ {
+ setTextFrom(DynamicElementTextItem::UserText);
+ setText(dom_element.attribute("text", "_"));
+ }
+ else
+ {
+ setTextFrom(DynamicElementTextItem::ElementInfo);
+ setInfoName(dom_element.attribute("tagg", "label"));
+ }
+
QGraphicsTextItem::setRotation(dom_element.attribute("rotation", "0").toDouble());
//the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
@@ -221,7 +214,6 @@
matrix.translate(dom_element.attribute("x", QString::number(0)).toDouble(),
dom_element.attribute("y", QString::number(0)).toDouble());
QGraphicsTextItem::setPos(matrix.map(pos));
- }
}
/**
Modified: trunk/sources/editor/graphicspart/partdynamictextfield.h
===================================================================
--- trunk/sources/editor/graphicspart/partdynamictextfield.h 2018-03-11 13:38:41 UTC (rev 5262)
+++ trunk/sources/editor/graphicspart/partdynamictextfield.h 2018-03-11 14:44:21 UTC (rev 5263)
@@ -43,9 +43,6 @@
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
public:
- static bool canImportFromTextField(const QDomElement &dom_element);
-
- public:
///PROPERTY
void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}