From c03a862151c9f102f82a89c19510c0cd17427e61 Mon Sep 17 00:00:00 2001 From: blacksun Date: Fri, 31 Mar 2017 17:09:04 +0000 Subject: [PATCH] Fix the lose of the text of element text item tagged "label" in some case. See the diff for more information. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4940 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetgraphicsitem/element.cpp | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 4549d4227..6d6ecd4bc 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -394,7 +394,14 @@ bool Element::valideXml(QDomElement &e) { @return true si l'import a reussi, false sinon */ -bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool handle_inputs_rotation) { +bool Element::fromXml(QDomElement &e, QHash &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 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool { 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