mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +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 "masterelement.h"
|
||||||
#include "crossrefitem.h"
|
#include "crossrefitem.h"
|
||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MasterElement::MasterElement
|
* @brief MasterElement::MasterElement
|
||||||
@@ -122,6 +123,15 @@ void MasterElement::initLink(QETProject *project) {
|
|||||||
updateLabel(DiagramContext(), elementInformations());
|
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()
|
* @brief MasterElement::changeElementInfo()
|
||||||
* Update label if it contains %c, %l, %f or %F variables
|
* Update label if it contains %c, %l, %f or %F variables
|
||||||
@@ -151,6 +161,16 @@ void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info
|
|||||||
else {
|
else {
|
||||||
setTaggedText("label", newstr, true);
|
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")) {
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class MasterElement : public CustomElement
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void folioIdChange();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
void changeElementInfo();
|
void changeElementInfo();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "simpleelement.h"
|
#include "simpleelement.h"
|
||||||
#include "commentitem.h"
|
#include "commentitem.h"
|
||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::SimpleElement
|
* @brief SimpleElement::SimpleElement
|
||||||
@@ -56,6 +57,15 @@ void SimpleElement::initLink(QETProject *project) {
|
|||||||
updateLabel(DiagramContext(), elementInformations());
|
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()
|
* @brief SimpleElement::changeElementInfo()
|
||||||
* Update label if it contains %c, %l, %f or %F variables
|
* Update label if it contains %c, %l, %f or %F variables
|
||||||
@@ -84,6 +94,16 @@ void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info
|
|||||||
else {
|
else {
|
||||||
setTaggedText("label", label, true);
|
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")) {
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class SimpleElement : public CustomElement {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void folioIdChange();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
void changeElementInfo();
|
void changeElementInfo();
|
||||||
@@ -46,7 +49,6 @@ class SimpleElement : public CustomElement {
|
|||||||
private:
|
private:
|
||||||
CommentItem *m_comment_item;
|
CommentItem *m_comment_item;
|
||||||
CommentItem *m_location_item;
|
CommentItem *m_location_item;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIMPLEELEMENT_H
|
#endif // SIMPLEELEMENT_H
|
||||||
|
|||||||
Reference in New Issue
Block a user