[qet] qet/qet: [4906] Fix bugtracker report N° 119 : Variable %F (of several element Xref) is not always up to date when the corresponding value of titleblock change. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [4906] Fix bugtracker report N° 119 : Variable %F (of several element Xref) is not always up to date when the corresponding value of titleblock change.
- From: subversion@xxxxxxxxxxxxx
- Date: Sat, 11 Feb 2017 12:42:53 +0100
Revision: 4906
Author: blacksun
Date: 2017-02-11 12:42:52 +0100 (Sat, 11 Feb 2017)
Log Message:
-----------
Fix bugtracker report N° 119 : Variable %F (of several element Xref) is not always up to date when the corresponding value of titleblock change.
Modified Paths:
--------------
trunk/sources/diagram.cpp
trunk/sources/diagram.h
trunk/sources/qetgraphicsitem/commentitem.cpp
trunk/sources/qetgraphicsitem/crossrefitem.cpp
trunk/sources/qetgraphicsitem/element.cpp
trunk/sources/qetgraphicsitem/element.h
trunk/sources/qetgraphicsitem/masterelement.cpp
trunk/sources/qetgraphicsitem/reportelement.cpp
trunk/sources/qetgraphicsitem/reportelement.h
trunk/sources/qetgraphicsitem/slaveelement.cpp
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/diagram.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -1694,15 +1694,11 @@
*/
void Diagram::setProject(QETProject *project)
{
- if (m_project == project) return;
+ if (m_project == project)
+ return;
- if (m_project)
- disconnect (m_project, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
-
m_project = project;
setParent (project);
-
- connect (m_project, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
}
/**
Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/diagram.h 2017-02-11 11:42:52 UTC (rev 4906)
@@ -129,18 +129,14 @@
public:
void setEventInterface (DiagramEventInterface *event_interface);
-
- //methods related to xref properties
- QString defaultReportProperties () const {return m_project -> defaultReportProperties();}
- XRefProperties defaultXRefProperties (const QString &str) const {return m_project -> defaultXRefProperties(str);}
-
- //methods related to autonum
+
+ //methods related to autonum
QString conductorsAutonumName() const;
void setConductorsAutonumName(const QString &name);
static bool clipboardMayContainDiagram();
- // methods related to parent project
+ // methods related to parent project
QETProject *project() const;
void setProject(QETProject *);
int folioIndex() const;
@@ -148,90 +144,90 @@
void showMe() {emit showDiagram(this);}
bool isReadOnly() const;
- // methods related to conductor creation
- void setConductor(bool);
- void setConductorStart (QPointF);
- void setConductorStop(QPointF);
- QList < QSet <Conductor *> > potentials();
+ // methods related to conductor creation
+ void setConductor(bool);
+ void setConductorStart (QPointF);
+ void setConductorStop(QPointF);
+ QList < QSet <Conductor *> > potentials();
- // methods related to XML import/export
- QDomDocument toXml(bool = true);
- bool initFromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
- bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
- bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
- void write();
- void write(const QDomElement &);
- bool wasWritten() const;
- QDomElement writeXml(QDomDocument &) const;
- void folioSequentialsToXml(QHash<QString, QStringList>*, QDomElement *, QString, QString, QDomDocument *);
- void folioSequentialsFromXml(const QDomElement&, QHash<QString, QStringList>*, QString, QString, QString, QString);
-
- void refreshContents();
-
- // methods related to graphics items addition/removal on the diagram
- virtual void addItem (QGraphicsItem *item);
- virtual void removeItem (QGraphicsItem *item);
+ // methods related to XML import/export
+ QDomDocument toXml(bool = true);
+ bool initFromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
+ bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
+ bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
+ void write();
+ void write(const QDomElement &);
+ bool wasWritten() const;
+ QDomElement writeXml(QDomDocument &) const;
+ void folioSequentialsToXml(QHash<QString, QStringList>*, QDomElement *, QString, QString, QDomDocument *);
+ void folioSequentialsFromXml(const QDomElement&, QHash<QString, QStringList>*, QString, QString, QString, QString);
- // methods related to graphics options
- ExportProperties applyProperties(const ExportProperties &);
- void setDisplayGrid(bool);
- bool displayGrid();
- void setUseBorder(bool);
- bool useBorder();
- void setBorderOptions(BorderOptions);
- BorderOptions borderOptions();
- DiagramPosition convertPosition(const QPointF &);
- static QPointF snapToGrid(const QPointF &p);
+ void refreshContents();
- bool drawTerminals() const;
- void setDrawTerminals(bool);
- bool drawColoredConductors() const;
- void setDrawColoredConductors(bool);
-
- QString title() const;
- bool toPaintDevice(QPaintDevice &, int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
- QSize imageSize() const;
+ // methods related to graphics items addition/removal on the diagram
+ virtual void addItem (QGraphicsItem *item);
+ virtual void removeItem (QGraphicsItem *item);
- bool isEmpty() const;
+ // methods related to graphics options
+ ExportProperties applyProperties(const ExportProperties &);
+ void setDisplayGrid(bool);
+ bool displayGrid();
+ void setUseBorder(bool);
+ bool useBorder();
+ void setBorderOptions(BorderOptions);
+ BorderOptions borderOptions();
+ DiagramPosition convertPosition(const QPointF &);
+ static QPointF snapToGrid(const QPointF &p);
- QList<CustomElement *> customElements() const;
- QList<Element *> elements() const;
- QList<Conductor *> conductors() const;
- QSet<DiagramTextItem *> selectedTexts() const;
- QSet<ConductorTextItem *> selectedConductorTexts() const;
- QSet<ElementTextItem*> selectedElementTexts() const;
- QSet<Conductor *> selectedConductors() const;
- DiagramContent content() const;
- DiagramContent selectedContent();
- bool canRotateSelection() const;
- int beginMoveElements(QGraphicsItem * = 0);
- void continueMoveElements(const QPointF &);
- void endMoveElements();
- int beginMoveElementTexts(QGraphicsItem * = 0);
- void continueMoveElementTexts(const QPointF &);
- void endMoveElementTexts();
- bool usesElement(const ElementsLocation &);
- bool usesTitleBlockTemplate(const QString &);
+ bool drawTerminals() const;
+ void setDrawTerminals(bool);
+ bool drawColoredConductors() const;
+ void setDrawColoredConductors(bool);
- QUndoStack &undoStack();
- QGIManager &qgiManager();
+ QString title() const;
+ bool toPaintDevice(QPaintDevice &, int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
+ QSize imageSize() const;
+
+ bool isEmpty() const;
- //methods related to element label Update Policy
- void freezeElements(bool freeze);
- void unfreezeElements();
- void setFreezeNewElements(bool);
- bool freezeNewElements();
+ QList<CustomElement *> customElements() const;
+ QList<Element *> elements() const;
+ QList<Conductor *> conductors() const;
+ QSet<DiagramTextItem *> selectedTexts() const;
+ QSet<ConductorTextItem *> selectedConductorTexts() const;
+ QSet<ElementTextItem*> selectedElementTexts() const;
+ QSet<Conductor *> selectedConductors() const;
+ DiagramContent content() const;
+ DiagramContent selectedContent();
+ bool canRotateSelection() const;
+ int beginMoveElements(QGraphicsItem * = 0);
+ void continueMoveElements(const QPointF &);
+ void endMoveElements();
+ int beginMoveElementTexts(QGraphicsItem * = 0);
+ void continueMoveElementTexts(const QPointF &);
+ void endMoveElementTexts();
+ bool usesElement(const ElementsLocation &);
+ bool usesTitleBlockTemplate(const QString &);
+
+ QUndoStack &undoStack();
+ QGIManager &qgiManager();
+
+ //methods related to element label Update Policy
+ void freezeElements(bool freeze);
+ void unfreezeElements();
+ void setFreezeNewElements(bool);
+ bool freezeNewElements();
+
+ //methods related to conductor label Update Policy
+ void freezeConductors(bool freeze);
+ void setFreezeNewConductors(bool);
+ bool freezeNewConductors();
+
+ //methods related to insertion and loading of folio sequential
+ void insertFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);
+ void loadFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);
- //methods related to conductor label Update Policy
- void freezeConductors(bool freeze);
- void setFreezeNewConductors(bool);
- bool freezeNewConductors();
- //methods related to insertion and loading of folio sequential
- void insertFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);
- void loadFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);
-
-
public slots:
void adjustSceneRect ();
void titleChanged(const QString &);
@@ -243,7 +239,7 @@
void loadElmtFolioSeq();
void loadCndFolioSeq();
- // methods related to graphics items selection
+ // methods related to graphics items selection
void selectAll();
void deselectAll();
void invertSelection();
@@ -255,7 +251,6 @@
void diagramTitleChanged(Diagram *, const QString &);
void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection
void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram
- void XRefPropertiesChanged();
void diagramActivated();
};
Q_DECLARE_METATYPE(Diagram *)
Modified: trunk/sources/qetgraphicsitem/commentitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/commentitem.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/commentitem.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -54,11 +54,13 @@
* @brief CommentItem::autoPos
* Adjust the position of this item.
*/
-void CommentItem::autoPos() {
+void CommentItem::autoPos()
+{
if (m_text_parent)
centerToParentBottom(this);
- else {
- XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
+ else
+ {
+ XRefProperties xrp = m_element->diagram()->project()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
centerToBottomDiagram(this, m_element, xrp.offset());
}
}
Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -45,15 +45,17 @@
{
Q_ASSERT_X(elmt->diagram(), "CrossRefItem constructor", "Parent element is not in a diagram");
- m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
+ m_properties = elmt->diagram()->project()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
setAcceptHoverEvents(true);
- connect(elmt -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
- connect(elmt -> diagram() -> project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
- connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
+ QETProject *project = elmt->diagram()->project();
+ connect(project, &QETProject::projectDiagramsOrderChanged, this, &CrossRefItem::updateLabel);
+ connect(project, &QETProject::diagramRemoved, this, &CrossRefItem::updateLabel);
+ connect(project, &QETProject::XRefPropertiesChanged, this, &CrossRefItem::updateProperties);
//set specific behavior related to the parent item.
- if(m_properties.snapTo() == XRefProperties::Bottom) {
+ if(m_properties.snapTo() == XRefProperties::Bottom)
+ {
connect(elmt, SIGNAL(yChanged()), this, SLOT(autoPos()));
connect(elmt, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
} else {
@@ -92,7 +94,7 @@
*/
QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_prefix) const
{
- XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
+ XRefProperties xrp = m_element->diagram()->project()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
QString formula = xrp.masterLabel();
autonum::sequentialNumbers seq;
QString txt = autonum::AssignVariables::formulaToLabel(formula, seq, elmt->diagram(), elmt);
@@ -110,16 +112,22 @@
* @brief CrossRefItem::updateProperties
* update the curent properties
*/
-void CrossRefItem::updateProperties() {
- XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
+void CrossRefItem::updateProperties()
+{
+ XRefProperties xrp = m_element->diagram()->project()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
- if (m_properties != xrp) {
- if (m_properties.snapTo() != xrp.snapTo()) {
- if (xrp.snapTo() == XRefProperties::Bottom) {
+ if (m_properties != xrp)
+ {
+ if (m_properties.snapTo() != xrp.snapTo())
+ {
+ if (xrp.snapTo() == XRefProperties::Bottom)
+ {
setParentItem(m_element);
connect(m_element, SIGNAL(yChanged()), this, SLOT(autoPos()));
connect(m_element, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
- } else {
+ }
+ else
+ {
setTextParent();
disconnect(m_element, SIGNAL(yChanged()), this, SLOT(autoPos()));
disconnect(m_element, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/element.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -877,7 +877,10 @@
//Because the variable %F is a reference to another text which can contain variables,
//we must to replace %F by the real text, to check if the real text contain the variable %id
if (diagram() && old_formula.contains("%F"))
- old_formula.replace("%F", diagram()->border_and_titleblock.folio());
+ {
+ disconnect(&diagram()->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &Element::updateLabel);
+ old_formula.replace("%F", m_F_str);
+ }
if (diagram() && (old_formula.contains("%f") || old_formula.contains("%id")))
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Element::updateLabel);
@@ -891,7 +894,11 @@
return;
if (diagram() && new_formula.contains("%F"))
- new_formula.replace("%F", diagram()->border_and_titleblock.folio());
+ {
+ m_F_str = diagram()->border_and_titleblock.folio();
+ new_formula.replace("%F", m_F_str);
+ connect(&diagram()->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &Element::updateLabel);
+ }
if (diagram() && (new_formula.contains("%f") || new_formula.contains("%id")))
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Element::updateLabel);
Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/element.h 2017-02-11 11:42:52 UTC (rev 4906)
@@ -149,7 +149,7 @@
void freezeNewAddedElement();
protected:
- void setUpConnectionForFormula(QString old_formula, QString new_formula);
+ virtual void setUpConnectionForFormula(QString old_formula, QString new_formula);
//ATTRIBUTES
protected:
@@ -156,6 +156,7 @@
DiagramContext m_element_informations, kind_informations_;
autonum::sequentialNumbers m_autoNum_seq;
bool m_freeze_label = false;
+ QString m_F_str;
/**
Draw this element
Modified: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -65,6 +65,7 @@
connect(elmt, SIGNAL(xChanged()), m_Xref_item, SLOT(updateLabel()));
connect(elmt, SIGNAL(yChanged()), m_Xref_item, SLOT(updateLabel()));
connect(elmt, SIGNAL(updateLabel()), m_Xref_item, SLOT(updateLabel()));
+ connect(&elmt->diagram()->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, m_Xref_item, &CrossRefItem::updateLabel);
m_Xref_item -> updateLabel();
emit linkedElementChanged();
}
@@ -103,6 +104,7 @@
disconnect(elmt, SIGNAL(xChanged()), m_Xref_item, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), m_Xref_item, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(updateLabel()), m_Xref_item, SLOT(updateLabel()));
+ disconnect(&elmt->diagram()->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, m_Xref_item, &CrossRefItem::updateLabel);
m_Xref_item -> updateLabel();
aboutDeleteXref();
Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -88,25 +88,22 @@
{
unlinkAllElements();
connected_elements << elmt;
-
- connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() ));
- connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
+ m_formula = diagram()->project()->defaultReportProperties();
+ setConnectionForFormula(m_formula);
connect(diagram()->project(), &QETProject::reportPropertiesChanged, this, &ReportElement::reportPropertiesChange);
- connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
+
if (elmt->terminals().size())
{
connect(elmt->terminals().first(), &Terminal::conductorWasAdded, this, &ReportElement::conductorWasAdded);
connect(elmt->terminals().first(), &Terminal::conductorWasRemoved, this, &ReportElement::conductorWasRemoved);
}
-
- m_label = diagram() -> defaultReportProperties();
-
+
if (!m_watched_conductor && elmt->conductors().size())
conductorWasAdded(elmt->conductors().first());
else
updateLabel();
- elmt -> linkToElement(this);
+ elmt->linkToElement(this);
emit linkedElementChanged();
}
@@ -118,16 +115,16 @@
*/
void ReportElement::unlinkAllElements()
{
- if (isFree()) return;
+ if (isFree())
+ return;
- QList <Element *> tmp_elmt = connected_elements;
+ const QList <Element *> tmp_elmt = connected_elements;
- foreach(Element *elmt, connected_elements)
+ for (Element *elmt : tmp_elmt)
{
- disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
- disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
+ removeConnectionForFormula(m_formula);
disconnect(diagram()->project(), &QETProject::reportPropertiesChanged, this, &ReportElement::reportPropertiesChange);
- disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+
if (elmt->terminals().size())
{
disconnect(elmt->terminals().first(), &Terminal::conductorWasAdded, this, &ReportElement::conductorWasAdded);
@@ -140,11 +137,12 @@
}
updateLabel();
- foreach(Element *elmt, tmp_elmt)
+ for(Element *elmt : tmp_elmt)
{
elmt -> setHighlighted(false);
elmt -> unlinkAllElements();
}
+
emit linkedElementChanged();
}
/**
@@ -198,12 +196,15 @@
}
/**
- * @brief ReportElement::setLabel
- * Set new label and call updatelabel
- * @param label new label
+ * @brief ReportElement::setFormula
+ * Set new Formula and call updatelabel
+ * @param formula : the new formula
*/
-void ReportElement::setLabel(QString label) {
- m_label = label;
+void ReportElement::setFormula(QString formula)
+{
+ removeConnectionForFormula(m_formula);
+ m_formula = formula;
+ setConnectionForFormula(m_formula);
updateLabel();
}
@@ -219,7 +220,7 @@
if (!connected_elements.isEmpty())
{
Element *elmt = connected_elements.at(0);
- QString label = m_label;
+ QString label = m_formula;
label = autonum::AssignVariables::formulaToLabel(label, elmt->rSequenceStruct(), elmt->diagram(), elmt);
m_text_field -> setPlainText(label);
}
@@ -233,5 +234,73 @@
void ReportElement::reportPropertiesChange(const QString &old_str, const QString &new_str)
{
Q_UNUSED(old_str);
- setLabel(new_str);
+ setFormula(new_str);
}
+
+/**
+ * @brief ReportElement::setConnectionForFormula
+ * Set up the required connection for the formula @str.
+ * @param str
+ */
+void ReportElement::setConnectionForFormula(const QString &str)
+{
+ if (connected_elements.isEmpty() || str.isEmpty())
+ return;
+
+ QString string = str;
+ Element *other_elmt = connected_elements.first();
+ Diagram *other_diagram = other_elmt->diagram();
+
+ //Because the variable %F is a reference to another text which can contain variables,
+ //we must to replace %F by the real text, to check if the real text contain the variable %id
+ if (other_diagram && string.contains("%F"))
+ {
+ m_F_str = other_diagram->border_and_titleblock.folio();
+ string.replace("%F", m_F_str);
+ connect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &ReportElement::updateFormulaConnection);
+ }
+
+ if (other_diagram && (string.contains("%f") || string.contains("%id")))
+ connect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &ReportElement::updateLabel);
+ if (string.contains("%l"))
+ connect(other_elmt, &Element::yChanged, this, &ReportElement::updateLabel);
+ if (string.contains("%c"))
+ connect(other_elmt, &Element::xChanged, this, &ReportElement::updateLabel);
+}
+
+/**
+ * @brief ReportElement::removeConnectionForFormula
+ * Remove the existing connection made for the formula @str
+ * @param str
+ */
+void ReportElement::removeConnectionForFormula(const QString &str)
+{
+ if (connected_elements.isEmpty() || str.isEmpty())
+ return;
+
+ QString string = str;
+ Element *other_element = connected_elements.first();
+ Diagram *other_diagram = other_element->diagram();
+
+ //Because the variable %F is a reference to another text which can contain variables,
+ //we must to replace %F by the real text, to check if the real text contain the variable %id
+ if (other_diagram && string.contains("%F"))
+ {
+ string.replace("%F", m_F_str);
+ disconnect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &ReportElement::updateFormulaConnection);
+ }
+
+ if (other_diagram && (string.contains("%f") || string.contains("%id")))
+ disconnect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &ReportElement::updateLabel);
+ if (string.contains("%l"))
+ disconnect(other_element, &Element::yChanged, this, &ReportElement::updateLabel);
+ if (string.contains("%c"))
+ disconnect(other_element, &Element::xChanged, this, &ReportElement::updateLabel);
+}
+
+void ReportElement::updateFormulaConnection()
+{
+ removeConnectionForFormula(m_formula);
+ setConnectionForFormula(m_formula);
+ updateLabel();
+}
Modified: trunk/sources/qetgraphicsitem/reportelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.h 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/reportelement.h 2017-02-11 11:42:52 UTC (rev 4906)
@@ -37,21 +37,22 @@
virtual void linkToElement(Element *);
virtual void unlinkAllElements();
virtual void unlinkElement(Element *elmt);
-
+
private:
- int m_inverse_report;
- QString m_label;
- ElementTextItem *m_text_field;
- Conductor *m_watched_conductor;
-
- private:
void conductorWasAdded(Conductor *conductor);
void conductorWasRemoved(Conductor *conductor);
-
- private slots:
- void setLabel (QString label);
+ void setFormula (QString label);
void updateLabel();
void reportPropertiesChange(const QString &old_str, const QString &new_str);
+ void setConnectionForFormula(const QString &str);
+ void removeConnectionForFormula(const QString &str);
+ void updateFormulaConnection();
+
+ private:
+ int m_inverse_report;
+ QString m_formula;
+ ElementTextItem *m_text_field;
+ Conductor *m_watched_conductor;
};
#endif // REPORTELEMENT_H
Modified: trunk/sources/qetgraphicsitem/slaveelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/slaveelement.cpp 2017-02-09 19:00:29 UTC (rev 4905)
+++ trunk/sources/qetgraphicsitem/slaveelement.cpp 2017-02-11 11:42:52 UTC (rev 4906)
@@ -60,13 +60,14 @@
this->disconnect();
connected_elements << elmt;
- connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
- connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
- connect(elmt, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)),this, SLOT(updateLabel()));
- connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
- connect(diagram()->project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
- connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel()));
- connect(elmt, SIGNAL(updateLabel()), this, SLOT(updateLabel()));
+ QETProject *project = elmt->diagram()->project();
+ connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
+ connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
+ connect(elmt, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel()));
+ connect(project, SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+ connect(project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
+ connect(project, SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel()));
+ connect(elmt, SIGNAL(updateLabel()), this, SLOT(updateLabel()));
updateLabel();
elmt -> linkToElement(this);
@@ -141,11 +142,11 @@
{
no_editable = true;
Element *elmt = linkedElements().first();
- label = elmt -> elementInformations()["label"].toString();
- XRefProperties xrp = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
+ label = elmt->elementInformations()["label"].toString();
+
+ XRefProperties xrp = elmt->diagram()->project()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
Xreflabel = xrp.slaveLabel();
Xreflabel = autonum::AssignVariables::formulaToLabel(Xreflabel, elmt->rSequenceStruct(), elmt->diagram(), elmt);
- label = autonum::AssignVariables::formulaToLabel(label, elmt->rSequenceStruct(), elmt->diagram(), elmt);
}
else
label = autonum::AssignVariables::formulaToLabel(label, m_autoNum_seq, diagram(), this);