mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Keep up to date the label of element when folio position change (Formula contain %id)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4744 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "masterelement.h"
|
||||
#include "crossrefitem.h"
|
||||
#include "elementtextitem.h"
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
* @brief MasterElement::MasterElement
|
||||
@@ -122,6 +123,15 @@ void MasterElement::initLink(QETProject *project) {
|
||||
updateLabel(DiagramContext(), elementInformations());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MasterElement::folioIdChange
|
||||
* Used to update the label of this item when the folio id change
|
||||
*/
|
||||
void MasterElement::folioIdChange() {
|
||||
DiagramContext dc =elementInformations();
|
||||
setTaggedText("label", assignVariables(dc["label"].toString(), this), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MasterElement::changeElementInfo()
|
||||
* Update label if it contains %c, %l, %f or %F variables
|
||||
@@ -144,13 +154,23 @@ void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info
|
||||
Element *elmt = this;
|
||||
newstr = assignVariables(newstr, elmt);
|
||||
|
||||
//Label of element
|
||||
//Label of element
|
||||
if (old_info["label"].toString() != newstr) {
|
||||
if (new_info["label"].toString().isEmpty())
|
||||
setTaggedText("label", "_", false);
|
||||
else {
|
||||
setTaggedText("label", newstr, true);
|
||||
}
|
||||
|
||||
//If autonum formula have %id we connect the change of folio position, to keep up to date the label.
|
||||
if (diagram() && diagram()->project()) {
|
||||
if (old_info["label"].toString().contains("%id") && !new_info["label"].toString().contains("%id")) {
|
||||
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &MasterElement::folioIdChange);
|
||||
}
|
||||
else if (new_info["label"].toString().contains("%id")) {
|
||||
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &MasterElement::folioIdChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ElementTextItem *eti = taggedText("label")) {
|
||||
|
||||
@@ -43,6 +43,9 @@ class MasterElement : public CustomElement
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
void folioIdChange();
|
||||
|
||||
public slots:
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
void changeElementInfo();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "simpleelement.h"
|
||||
#include "commentitem.h"
|
||||
#include "elementtextitem.h"
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::SimpleElement
|
||||
@@ -56,6 +57,15 @@ void SimpleElement::initLink(QETProject *project) {
|
||||
updateLabel(DiagramContext(), elementInformations());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::folioIdChange
|
||||
* Use to update the label of this item when the foio id change
|
||||
*/
|
||||
void SimpleElement::folioIdChange() {
|
||||
DiagramContext dc =elementInformations();
|
||||
setTaggedText("label", assignVariables(dc["label"].toString(), this), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::changeElementInfo()
|
||||
* Update label if it contains %c, %l, %f or %F variables
|
||||
@@ -77,13 +87,23 @@ void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info
|
||||
Element *elmt = this;
|
||||
label = assignVariables(label,elmt);
|
||||
|
||||
//Label of element
|
||||
//Label of element
|
||||
if (old_info["label"].toString() != label) {
|
||||
if (new_info["label"].toString().isEmpty())
|
||||
setTaggedText("label", "_", false);
|
||||
else {
|
||||
setTaggedText("label", label, true);
|
||||
}
|
||||
|
||||
//If autonum formula have %id we connect the change of folio position, to keep up to date the label.
|
||||
if (diagram() && diagram()->project()) {
|
||||
if (old_info["label"].toString().contains("%id") && !new_info["label"].toString().contains("%id")) {
|
||||
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &SimpleElement::folioIdChange);
|
||||
}
|
||||
else if (new_info["label"].toString().contains("%id")) {
|
||||
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &SimpleElement::folioIdChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ElementTextItem *eti = taggedText("label")) {
|
||||
|
||||
@@ -39,6 +39,9 @@ class SimpleElement : public CustomElement {
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
void folioIdChange();
|
||||
|
||||
public slots:
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
void changeElementInfo();
|
||||
@@ -46,7 +49,6 @@ class SimpleElement : public CustomElement {
|
||||
private:
|
||||
CommentItem *m_comment_item;
|
||||
CommentItem *m_location_item;
|
||||
|
||||
};
|
||||
|
||||
#endif // SIMPLEELEMENT_H
|
||||
|
||||
Reference in New Issue
Block a user