mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
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:
@@ -726,6 +726,18 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
|
|||||||
eti -> setFollowParentRotations(e.attribute("rotate") == "true");
|
eti -> setFollowParentRotations(e.attribute("rotate") == "true");
|
||||||
list_texts_ << eti;
|
list_texts_ << eti;
|
||||||
|
|
||||||
|
if (e.attribute("tagg")=="label") {
|
||||||
|
DiagramContext &dc = this->rElementInformations();
|
||||||
|
dc.addValue("label", e.attribute("text"));
|
||||||
|
this->setElementInformations(dc);
|
||||||
|
this->setTaggedText("label", e.attribute("text"));
|
||||||
|
}
|
||||||
|
else if (e.attribute("tagg")=="function") {
|
||||||
|
DiagramContext &dc = this->rElementInformations();
|
||||||
|
dc.addValue("function", e.attribute("text"));
|
||||||
|
this->setElementInformations(dc);
|
||||||
|
}
|
||||||
|
|
||||||
// Se positionne aux coordonnees indiquees dans la description du texte
|
// Se positionne aux coordonnees indiquees dans la description du texte
|
||||||
qp.setTransform(QTransform(), false);
|
qp.setTransform(QTransform(), false);
|
||||||
qp.translate(pos_x, pos_y);
|
qp.translate(pos_x, pos_y);
|
||||||
@@ -783,18 +795,6 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
|||||||
eti -> setFont(QETApp::diagramTextsFont(size));
|
eti -> setFont(QETApp::diagramTextsFont(size));
|
||||||
eti -> setTagg(e.attribute("tagg", "other"));
|
eti -> setTagg(e.attribute("tagg", "other"));
|
||||||
|
|
||||||
if (e.attribute("tagg")=="label") {
|
|
||||||
DiagramContext &dc = this->rElementInformations();
|
|
||||||
dc.addValue("label", e.attribute("text"));
|
|
||||||
this->setElementInformations(dc);
|
|
||||||
this->setTaggedText("label", e.attribute("text"));
|
|
||||||
}
|
|
||||||
else if (e.attribute("tagg")=="function") {
|
|
||||||
DiagramContext &dc = this->rElementInformations();
|
|
||||||
dc.addValue("function", e.attribute("text"));
|
|
||||||
this->setElementInformations(dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// position the text field
|
// position the text field
|
||||||
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
||||||
eti -> setPos(pos_x, pos_y);
|
eti -> setPos(pos_x, pos_y);
|
||||||
|
|||||||
@@ -307,6 +307,25 @@ void Element::updatePixmap() {
|
|||||||
paint(&p, 0);
|
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
|
Permet de savoir si un element XML (QDomElement) represente bien un element
|
||||||
@param e Le QDomElement a valide
|
@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");
|
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
foreach(QGraphicsItem *qgi, childItems()) {
|
||||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||||
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
foreach(QDomElement input, inputs) {
|
||||||
|
eti -> fromXml(input);
|
||||||
|
etiToElementLabels(eti);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ class Element : public QetGraphicsItem {
|
|||||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
|
void etiToElementLabels(ElementTextItem*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
||||||
|
|||||||
Reference in New Issue
Block a user