[qet] qet/qet: [4845] Text of conductor is updated when folio position change, if formula contain the variable %id.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4845
Author:   blacksun
Date:     2017-01-14 16:01:49 +0100 (Sat, 14 Jan 2017)
Log Message:
-----------
Text of conductor is updated when folio position change, if formula contain the variable %id.

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/conductor.h

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2017-01-12 21:44:56 UTC (rev 4844)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2017-01-14 15:01:49 UTC (rev 4845)
@@ -1322,17 +1322,22 @@
 {
 	if (m_properties == property) return;
 
+	QString formula = m_properties.m_formula;
 	m_properties = property;
 
 	if (!m_properties.m_formula.isEmpty())
 	{
-		if (diagram()) {
+		if (diagram())
+		{
 			QString text = autonum::AssignVariables::formulaToLabel(m_properties.m_formula, m_autoNum_seq, diagram());
 			m_properties.text = text;
 		}
-		else if (m_properties.text.isEmpty()){
+		else if (m_properties.text.isEmpty())
+		{
 			m_properties.text = m_properties.m_formula;
 		}
+
+		setUpConnectionForFormula(formula, m_properties.m_formula);
 	}
 
 	m_text_item->setPlainText(m_properties.text);
@@ -1487,6 +1492,25 @@
 }
 
 /**
+ * @brief Conductor::setUpConnectionForFormula
+ * setup connection according to the variable of formula
+ * @param old_formula
+ * @param new_formula
+ */
+void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formula)
+{
+	if (diagram() && old_formula.contains("%id"))
+		disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
+
+		//Label is frozen, so we don't update it.
+	if (m_freeze_label == true)
+		return;
+
+	if (diagram() && new_formula.contains("%id"))
+		connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
+}
+
+/**
 	@param a point
 	@param b point
 	@param c point
@@ -1755,6 +1779,14 @@
  * Unfreeze this conductor label if false
  * @param freeze
  */
-void Conductor::setFreezeLabel(bool freeze) {
+void Conductor::setFreezeLabel(bool freeze)
+{
 	m_freeze_label = freeze;
+
+	if (m_freeze_label != freeze)
+	{
+		m_freeze_label = freeze;
+		QString f = m_properties.m_formula;
+		setUpConnectionForFormula(f,f);
+	}
 }

Modified: trunk/sources/qetgraphicsitem/conductor.h
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.h	2017-01-12 21:44:56 UTC (rev 4844)
+++ trunk/sources/qetgraphicsitem/conductor.h	2017-01-14 15:01:49 UTC (rev 4845)
@@ -119,7 +119,9 @@
 		autonum::sequentialNumbers sequenceNum () const {return m_autoNum_seq;}
 		autonum::sequentialNumbers& rSequenceNum()      {return m_autoNum_seq;}
 		void setSequenceNum(autonum::sequentialNumbers sn);
+
 	private:
+		void setUpConnectionForFormula(QString old_formula, QString new_formula);
 		autonum::sequentialNumbers m_autoNum_seq;
 
 	public:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/