Fix Element Label when opening older QET versions. Fix old user created element label's handling on newer QET versions

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4591 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-25 19:18:26 +00:00
parent 138505a14e
commit 52e33787a8
3 changed files with 36 additions and 13 deletions

View File

@@ -307,6 +307,25 @@ void Element::updatePixmap() {
paint(&p, 0);
}
/**
This class is used to retrieve label and function information from element
and add it to Diagram Context. Used to make older versions work correctly
@param Element Text item to check information
*/
void Element::etiToElementLabels(ElementTextItem *eti) {
if (eti->tagg() == "label" && eti->toPlainText()!= "_") {
DiagramContext &dc = this->rElementInformations();
dc.addValue("label", eti->toPlainText());
this->setElementInformations(dc);
this->setTaggedText("label", eti->toPlainText());
}
else if(eti->tagg() == "function" && eti->toPlainText() != "_") {
DiagramContext &dc = this->rElementInformations();
dc.addValue("function", eti->toPlainText());
this->setElementInformations(dc);
}
}
/**
Permet de savoir si un element XML (QDomElement) represente bien un element
@param e Le QDomElement a valide
@@ -393,7 +412,10 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
foreach(QGraphicsItem *qgi, childItems()) {
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
foreach(QDomElement input, inputs) eti -> fromXml(input);
foreach(QDomElement input, inputs) {
eti -> fromXml(input);
etiToElementLabels(eti);
}
}
}