[qet] qet/qet: [4940] Fix the lose of the text of element text item tagged " label" in some case. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4940
Author: blacksun
Date: 2017-03-31 19:09:04 +0200 (Fri, 31 Mar 2017)
Log Message:
-----------
Fix the lose of the text of element text item tagged "label" in some case.
See the diff for more information.
Modified Paths:
--------------
trunk/sources/qetgraphicsitem/element.cpp
Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp 2017-03-31 15:48:14 UTC (rev 4939)
+++ trunk/sources/qetgraphicsitem/element.cpp 2017-03-31 17:09:04 UTC (rev 4940)
@@ -394,7 +394,14 @@
@return true si l'import a reussi, false sinon
*/
-bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool handle_inputs_rotation) {
+bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool handle_inputs_rotation)
+{
+ QDomDocument doc = e.ownerDocument();
+ QDomElement root = doc.documentElement();
+ double saved_version = -1;
+ if(root.tagName() == "project")
+ saved_version = root.attribute("version", "-1").toDouble();
+
/*
les bornes vont maintenant etre recensees pour associer leurs id a leur adresse reelle
ce recensement servira lors de la mise en place des fils
@@ -483,6 +490,30 @@
{
m_element_informations.addValue("formula", m_element_informations["label"]);
}
+
+ /**
+ * At the start of the 0.51 devel, if the text item with tagg "label" was edited directly in the diagram,
+ * the text was not write to the element information value "formula".
+ * During the devel, this behavior change, when user edit the text item direclty in the diagram,
+ * the text was also write in the element information.
+ * Then when open a .qet file, the text item with tagg "label", is write with the value stored in the element information.
+ * The mistake is :
+ * if user write directly in the diagram with a version befor the change (so the text is not in the element information),
+ * and open the project with a version after the change, then the text item with tagg "label" is empty.
+ * The code below fix this.
+ */
+ if (saved_version > -1 && saved_version <= 0.51)
+ {
+ if (ElementTextItem *eti = taggedText("label"))
+ {
+ if (m_element_informations["label"].toString().isEmpty() &&
+ m_element_informations["formula"].toString().isEmpty() &&
+ !eti->toPlainText().isEmpty())
+ {
+ m_element_informations.addValue("formula", eti->toPlainText());
+ }
+ }
+ }
//Position and selection.
//We directly call setPos from QGraphicsObject, because QetGraphicsItem will snap to grid