[qet] [3394] Improve signal of position changed, between linked elements

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


Revision: 3394
Author:   blacksun
Date:     2014-10-23 10:48:30 +0200 (Thu, 23 Oct 2014)
Log Message:
-----------
Improve signal of position changed, between linked elements

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/crossrefitem.cpp
    trunk/sources/qetgraphicsitem/masterelement.cpp
    trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
    trunk/sources/qetgraphicsitem/qetgraphicsitem.h
    trunk/sources/qetgraphicsitem/reportelement.cpp
    trunk/sources/qetgraphicsitem/slaveelement.cpp

Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-10-23 08:48:30 UTC (rev 3394)
@@ -37,14 +37,15 @@
 	m_element (elmt)
 {
 	m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
-	connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
-	connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
-	connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
 
+	connect(elmt,                           SIGNAL(elementInfoChange(DiagramContext)),                this, SLOT(updateLabel()));
+	connect(elmt -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+	connect(elmt -> diagram(),              SIGNAL(XRefPropertiesChanged()),                          this, SLOT(updateProperties()));
+
 	//set specific behavior related to the parent item.
 	if(m_properties.snapTo() == XRefProperties::Bottom) {
-		connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
-		connect(elmt, SIGNAL(rotationChanged()),	   this, SLOT(autoPos()));
+		connect(elmt, SIGNAL(yChanged()),        this, SLOT(autoPos()));
+		connect(elmt, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
 	} else {
 		setTextParent();
 	}
@@ -57,12 +58,12 @@
  */
 CrossRefItem::~CrossRefItem() {
 	if(m_properties.snapTo() == XRefProperties::Bottom) {
-		disconnect(m_element, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
-		disconnect(m_element, SIGNAL(rotationChanged()),	   this, SLOT(autoPos()));
+		disconnect(m_element, SIGNAL(yChanged()),        this, SLOT(autoPos()));
+		disconnect(m_element, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
 	}
-	disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
-	disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
-	disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
+	disconnect(m_element,                           SIGNAL(elementInfoChange(DiagramContext)),                this, SLOT(updateLabel()));
+	disconnect(m_element -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+	disconnect(m_element -> diagram(),              SIGNAL(XRefPropertiesChanged()),                          this, SLOT(updateProperties()));
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp	2014-10-23 08:48:30 UTC (rev 3394)
@@ -56,7 +56,8 @@
 		elmt->linkToElement(this);
 
 		if (!cri_) cri_ = new CrossRefItem(this); //create cross ref item if not yet
-			connect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel()));
+			connect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
+			connect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
 			cri_->updateLabel();
 		}
 }
@@ -86,7 +87,8 @@
 		elmt->unlinkElement(this);
 
 		//update the graphics cross ref
-		disconnect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel()));
+		disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
+		disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
 
 		if (linkedElements().isEmpty()) {
 			delete cri_;

Modified: trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp	2014-10-23 08:48:30 UTC (rev 3394)
@@ -29,8 +29,7 @@
 	is_movable_(true),
 	first_move_(true),
 	snap_to_grid_(true)
-{
-}
+{}
 
 QetGraphicsItem::~QetGraphicsItem()
 {}
@@ -53,7 +52,6 @@
 	if (pp == pos() || !is_movable_) return;
 	if (scene() && snap_to_grid_) {
 		QGraphicsItem::setPos(pp);
-		emit positionChange(pos());
 	} else QGraphicsItem::setPos(pp);
 }
 

Modified: trunk/sources/qetgraphicsitem/qetgraphicsitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetgraphicsitem.h	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/qetgraphicsitem.h	2014-10-23 08:48:30 UTC (rev 3394)
@@ -40,7 +40,6 @@
 	virtual QString name()const {return QString("");}
 
 	signals:
-	void positionChange(QPointF);
 
 	public slots:
 

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2014-10-23 08:48:30 UTC (rev 3394)
@@ -55,7 +55,8 @@
 	if ((elmt->linkType() == inverse_report) && i) {
 		unlinkAllElements();
 		connected_elements << elmt;
-		connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
+		connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
+		connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
 		connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
 		updateLabel();
 		elmt->linkToElement(this);
@@ -71,7 +72,8 @@
 		QList <Element *> tmp_elmt = connected_elements;
 
 		foreach(Element *elmt, connected_elements) {
-			disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
+			disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
+			disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
 			disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
 		}
 		connected_elements.clear();

Modified: trunk/sources/qetgraphicsitem/slaveelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/slaveelement.cpp	2014-10-23 08:05:53 UTC (rev 3393)
+++ trunk/sources/qetgraphicsitem/slaveelement.cpp	2014-10-23 08:48:30 UTC (rev 3394)
@@ -56,7 +56,8 @@
 		if(!isFree()) unlinkAllElements();
 		connected_elements << elmt;
 		updateLabel();
-		connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
+		connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
+		connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
 		connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 		elmt->linkToElement(this);
 	}
@@ -84,7 +85,8 @@
 	//Ensure elmt is linked to this element
 	if (connected_elements.contains(elmt)) {
 		connected_elements.removeOne(elmt);
-		disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
+		disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
+		disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
 		disconnect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 		delete Xref_item; Xref_item = NULL;
 		updateLabel();


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