[qet] [3499] Element information : Check box "visible" for text re-work.

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


Revision: 3499
Author:   blacksun
Date:     2014-11-19 00:00:06 +0100 (Wed, 19 Nov 2014)
Log Message:
-----------
Element information : Check box "visible" for text re-work.

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/qetgraphicsitem/element.h
    trunk/sources/qetgraphicsitem/masterelement.cpp
    trunk/sources/qetgraphicsitem/masterelement.h
    trunk/sources/qetgraphicsitem/simpleelement.cpp
    trunk/sources/qetgraphicsitem/simpleelement.h

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/element.cpp	2014-11-18 23:00:06 UTC (rev 3499)
@@ -518,8 +518,9 @@
  * @param dc
  */
 void Element::setElementInformations(DiagramContext dc) {
+	DiagramContext old_info = element_informations_;
 	element_informations_ = dc;
-	emit elementInfoChange(element_informations_);
+	emit elementInfoChange(old_info, element_informations_);
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/element.h	2014-11-18 23:00:06 UTC (rev 3499)
@@ -121,7 +121,7 @@
 		kind link_type_;
 
 	signals:
-		void elementInfoChange(DiagramContext);
+		void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
 
 	//METHODS related to information
 	public:

Modified: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp	2014-11-18 23:00:06 UTC (rev 3499)
@@ -17,6 +17,7 @@
 */
 #include "masterelement.h"
 #include "crossrefitem.h"
+#include "elementtextitem.h"
 
 /**
  * @brief MasterElement::MasterElement
@@ -31,7 +32,7 @@
 	cri_ (nullptr)
 {
 	link_type_ = Master;
-	connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
+	connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
 }
 
 /**
@@ -97,13 +98,14 @@
 
 /**
  * @brief MasterElement::initLink
- * Initialise the links between this element and other element.
  * @param project
+ * Call init Link from custom element and after
+ * call update label for setup it.
  */
 void MasterElement::initLink(QETProject *project) {
 	//Create the link with other element if needed
 	CustomElement::initLink(project);
-	updateLabel();
+	updateLabel(DiagramContext(), elementInformations());
 }
 
 /**
@@ -111,14 +113,19 @@
  * update label of this element
  * and the comment item if he's displayed.
  */
-void MasterElement::updateLabel() {
-	QString label = elementInformations()["label"].toString();
-	bool	show  = elementInformations().keyMustShow("label");
+void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
+	//Label of element
+	if (old_info["label"].toString() != new_info["label"].toString()) {
+		if (new_info["label"].toString().isEmpty())
+			setTaggedText("label", "_", false);
+		else
+			setTaggedText("label", new_info["label"].toString(), true);
+	}
 
-	// setup the label
-	if (!label.isEmpty() && show) setTaggedText("label", label, true);
+	if (ElementTextItem *eti = taggedText("label")) {
+		new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
+	}
 
-
 	//Delete or update the xref
 	if (cri_) {
 		aboutDeleteXref();

Modified: trunk/sources/qetgraphicsitem/masterelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.h	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/masterelement.h	2014-11-18 23:00:06 UTC (rev 3499)
@@ -44,7 +44,7 @@
 	signals:
 
 	public slots:
-		void updateLabel();
+		void updateLabel(DiagramContext old_info, DiagramContext new_info);
 
 	private:
 		bool aboutDeleteXref ();

Modified: trunk/sources/qetgraphicsitem/simpleelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/simpleelement.cpp	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/simpleelement.cpp	2014-11-18 23:00:06 UTC (rev 3499)
@@ -17,6 +17,7 @@
 */
 #include "simpleelement.h"
 #include "commentitem.h"
+#include "elementtextitem.h"
 /**
  * @brief SimpleElement::SimpleElement
  * @param location
@@ -29,37 +30,47 @@
 	m_comment_item (nullptr)
 {
 	link_type_ = Simple;
-	connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
+	connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
 }
 
 /**
  * @brief SimpleElement::~SimpleElement
  */
 SimpleElement::~SimpleElement() {
-	disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 	if (m_comment_item) delete m_comment_item;
 }
 
+/**
+ * @brief SimpleElement::initLink
+ * @param project
+ * Call init Link from custom element and after
+ * call update label for setup it.
+ */
 void SimpleElement::initLink(QETProject *project) {
 	CustomElement::initLink(project);
-	updateLabel();
+	updateLabel(DiagramContext(), elementInformations());
 }
 
 /**
  * @brief SimpleElement::updateLabel
  * update label of this element
  */
-void SimpleElement::updateLabel() {
+void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
 	//Label of element
-	QString label = elementInformations()["label"].toString();
-	bool	show  = elementInformations().keyMustShow("label");
+	if (old_info["label"].toString() != new_info["label"].toString()) {
+		if (new_info["label"].toString().isEmpty())
+			setTaggedText("label", "_", false);
+		else
+			setTaggedText("label", new_info["label"].toString(), true);
+	}
 
-	// setup the label
-	if (!label.isEmpty() && show) setTaggedText("label", label, true);
+	if (ElementTextItem *eti = taggedText("label")) {
+		new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
+	}
 
 	//Comment of element
-	QString comment   = elementInformations()["comment"].toString();
-	bool    must_show = elementInformations().keyMustShow("comment");
+	QString comment   = new_info["comment"].toString();
+	bool    must_show = new_info.keyMustShow("comment");
 
 	if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
 		m_comment_item = new CommentItem(this);

Modified: trunk/sources/qetgraphicsitem/simpleelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/simpleelement.h	2014-11-17 22:32:06 UTC (rev 3498)
+++ trunk/sources/qetgraphicsitem/simpleelement.h	2014-11-18 23:00:06 UTC (rev 3499)
@@ -40,7 +40,7 @@
 	signals:
 
 	public slots:
-		void updateLabel();
+		void updateLabel(DiagramContext old_info, DiagramContext new_info);
 
 	private:
 		CommentItem *m_comment_item;


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