[qet] [2951] master element: add auto label when "comment" isn' t empty and must show

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


Revision: 2951
Author:   blacksun
Date:     2014-03-31 18:02:47 +0200 (Mon, 31 Mar 2014)
Log Message:
-----------
master element: add auto label when "comment" isn't empty and must show
element info widget -> comment line: must show is checked by default

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/masterelement.cpp
    trunk/sources/qetgraphicsitem/masterelement.h
    trunk/sources/ui/elementinfowidget.cpp

Modified: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp	2014-03-28 10:33:14 UTC (rev 2950)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp	2014-03-31 16:02:47 UTC (rev 2951)
@@ -30,6 +30,7 @@
 {
 	link_type_ = Master;
 	cri_ = 0;
+	connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 }
 
 /**
@@ -38,6 +39,7 @@
  */
 MasterElement::~MasterElement() {
 	unlinkAllElements();
+	disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 }
 
 /**
@@ -92,3 +94,17 @@
 		}
 	}
 }
+
+/**
+ * @brief MasterElement::updateLabel
+ * update label of this element
+ */
+void MasterElement::updateLabel() {
+	QString label = elementInformations()["label"].toString();
+	bool	show  = elementInformations().keyMustShow("label");
+
+	// setup the label
+	(label.isEmpty() || !show)?
+				setTaggedText("label", "_", false):
+				setTaggedText("label", label, true);
+}

Modified: trunk/sources/qetgraphicsitem/masterelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.h	2014-03-28 10:33:14 UTC (rev 2950)
+++ trunk/sources/qetgraphicsitem/masterelement.h	2014-03-31 16:02:47 UTC (rev 2951)
@@ -35,10 +35,10 @@
 	signals:
 
 	public slots:
+	void updateLabel();
 
 	private:
 	CrossRefItem *cri_;
-
 };
 
 #endif // MASTERELEMENT_H

Modified: trunk/sources/ui/elementinfowidget.cpp
===================================================================
--- trunk/sources/ui/elementinfowidget.cpp	2014-03-28 10:33:14 UTC (rev 2950)
+++ trunk/sources/ui/elementinfowidget.cpp	2014-03-31 16:02:47 UTC (rev 2951)
@@ -86,5 +86,7 @@
 		//check "show" if this eipw is label and if elmt_info haven't got value for label.
 		if (eipw->key() == "label" && (elmt_info["label"].toString().isEmpty()))
 			eipw->setShow(true);
+		else if (eipw->key() == "comment" && (elmt_info["comment"].toString().isEmpty()))
+			eipw->setShow(true);
 	}
 }


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