[qet] [3454] element editor : improve add line

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


Revision: 3454
Author:   blacksun
Date:     2014-11-05 11:09:12 +0100 (Wed, 05 Nov 2014)
Log Message:
-----------
element editor : improve add line

Modified Paths:
--------------
    trunk/sources/editor/elementscene.cpp
    trunk/sources/editor/esevent/eseventaddline.cpp
    trunk/sources/editor/esevent/eseventaddline.h

Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp	2014-11-04 23:36:37 UTC (rev 3453)
+++ trunk/sources/editor/elementscene.cpp	2014-11-05 10:09:12 UTC (rev 3454)
@@ -68,6 +68,7 @@
 */
 void ElementScene::slot_move() {
 	behavior = Normal;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -75,6 +76,7 @@
 */
 void ElementScene::slot_addRectangle() {
 	behavior = Rectangle;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -82,6 +84,7 @@
 */
 void ElementScene::slot_addCircle() {
 	behavior = Circle;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -89,6 +92,7 @@
 */
 void ElementScene::slot_addEllipse() {
 	behavior = Ellipse;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -96,6 +100,7 @@
 */
 void ElementScene::slot_addPolygon() {
 	behavior = Polygon;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 
@@ -104,6 +109,7 @@
 */
 void ElementScene::slot_addText() {
 	behavior = Text;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -111,6 +117,7 @@
 */
 void ElementScene::slot_addTerminal() {
 	behavior = Terminal;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -118,6 +125,7 @@
 */
 void ElementScene::slot_addArc() {
 	behavior = Arc;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**
@@ -125,6 +133,7 @@
 */
 void ElementScene::slot_addTextField() {
 	behavior = TextField;
+	if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
 }
 
 /**

Modified: trunk/sources/editor/esevent/eseventaddline.cpp
===================================================================
--- trunk/sources/editor/esevent/eseventaddline.cpp	2014-11-04 23:36:37 UTC (rev 3453)
+++ trunk/sources/editor/esevent/eseventaddline.cpp	2014-11-05 10:09:12 UTC (rev 3454)
@@ -72,18 +72,6 @@
 		return true;
 	}
 
-	//Remove the current line if exist
-	//or finish if no line
-	if (event -> button() == Qt::RightButton) {
-		if (m_line) {
-			delete m_line; m_line = nullptr;
-		}
-		else {
-			m_running = false;
-		}
-		return true;
-	}
-
 	return false;
 }
 
@@ -101,3 +89,17 @@
 	m_line -> setLine(QLineF(m_line->line().p1(), pos));
 	return true;
 }
+
+/**
+ * @brief ESEventAddLine::mouseReleaseEvent
+ * @param event
+ * @return
+ */
+bool ESEventAddLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
+	if (event -> button() == Qt::RightButton) {
+		if (m_line) {delete m_line; m_line = nullptr;}
+		else        {m_running = false;}
+		return true;
+	}
+	return false;
+}

Modified: trunk/sources/editor/esevent/eseventaddline.h
===================================================================
--- trunk/sources/editor/esevent/eseventaddline.h	2014-11-04 23:36:37 UTC (rev 3453)
+++ trunk/sources/editor/esevent/eseventaddline.h	2014-11-05 10:09:12 UTC (rev 3454)
@@ -30,8 +30,9 @@
 		ESEventAddLine(ElementScene *scene);
 		virtual ~ESEventAddLine();
 
-		virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
-		virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
+		virtual bool mousePressEvent   (QGraphicsSceneMouseEvent *event);
+		virtual bool mouseMoveEvent    (QGraphicsSceneMouseEvent *event);
+		virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
 
 	private:
 		PartLine *m_line;


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