[qet] qet/qet: [5789] Fix behavior when use arrow key with dynamic element text item and element text item group

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


Revision: 5789
Author:   blacksun
Date:     2019-03-16 12:34:52 +0100 (Sat, 16 Mar 2019)
Log Message:
-----------
Fix behavior when use arrow key with dynamic element text item and element text item group

Modified Paths:
--------------
    trunk/sources/diagramcommands.cpp
    trunk/sources/diagramcontent.cpp
    trunk/sources/diagramcontent.h
    trunk/sources/diagramview.cpp
    trunk/sources/elementsmover.cpp

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2019-03-16 10:50:30 UTC (rev 5788)
+++ trunk/sources/diagramcommands.cpp	2019-03-16 11:34:52 UTC (rev 5789)
@@ -191,7 +191,8 @@
 		DiagramContent::ConductorsToUpdate |
 		DiagramContent::ConductorsToMove |
 		DiagramContent::Images |
-		DiagramContent::Shapes
+		DiagramContent::Shapes |
+		DiagramContent::ElementTextFields
 	);
 	
 	setText(
@@ -248,7 +249,7 @@
 	typedef DiagramContent dc;
 
 		//Move every movable items, except conductor
-	for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup))
+	for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup | dc::ElementTextFields))
 	{
 			//If curent item have parent, and parent item is in content_to_move
 			//we don't apply movement to this item, because this item will be moved by is parent.

Modified: trunk/sources/diagramcontent.cpp
===================================================================
--- trunk/sources/diagramcontent.cpp	2019-03-16 10:50:30 UTC (rev 5788)
+++ trunk/sources/diagramcontent.cpp	2019-03-16 11:34:52 UTC (rev 5789)
@@ -356,6 +356,21 @@
 }
 
 /**
+ * @brief DiagramContent::hasTextEditing
+ * @return true if handle a text currently in editing intercation
+ */
+bool DiagramContent::hasTextEditing()
+{
+	for (DiagramTextItem *dti : selectedTexts()) {
+		if (dti->textInteractionFlags() == Qt::TextEditorInteraction) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
+/**
  * @brief DiagramContent::items
  * @param filter
  * @return The items of this diagram content according to @filter

Modified: trunk/sources/diagramcontent.h
===================================================================
--- trunk/sources/diagramcontent.h	2019-03-16 10:50:30 UTC (rev 5788)
+++ trunk/sources/diagramcontent.h	2019-03-16 11:34:52 UTC (rev 5789)
@@ -89,6 +89,7 @@
 		
 		DiagramContent& operator+=(const DiagramContent& other);
 		bool potentialIsManaged(QList<Conductor *>conductors);
+		bool hasTextEditing();
 };
 QDebug &operator<<(QDebug, DiagramContent &);
 #endif

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2019-03-16 10:50:30 UTC (rev 5788)
+++ trunk/sources/diagramview.cpp	2019-03-16 11:34:52 UTC (rev 5789)
@@ -703,22 +703,22 @@
 		}
 			break;
 		case Qt::Key_Up: {
-			if(!(dc.items(DiagramContent::All).isEmpty()))
+			if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
 				scrollOnMovement(e);
 		}
 			break;
 		case Qt::Key_Down: {
-			if(!(dc.items(DiagramContent::All).isEmpty()))
+			if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
 				scrollOnMovement(e);
 		}
 			break;
 		case Qt::Key_Left: {
-			if(!(dc.items(DiagramContent::All).isEmpty()))
+			if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
 				scrollOnMovement(e);
 		}
 			break;
 		case Qt::Key_Right: {
-			if(!(dc.items(DiagramContent::All).isEmpty()))
+			if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
 				scrollOnMovement(e);
 		}
 			break;

Modified: trunk/sources/elementsmover.cpp
===================================================================
--- trunk/sources/elementsmover.cpp	2019-03-16 10:50:30 UTC (rev 5788)
+++ trunk/sources/elementsmover.cpp	2019-03-16 11:34:52 UTC (rev 5789)
@@ -24,6 +24,8 @@
 #include "independenttextitem.h"
 #include "diagramimageitem.h"
 #include "conductorautonumerotation.h"
+#include "dynamicelementtextitem.h"
+#include "elementtextitemgroup.h"
 
 /**
  * @brief ElementsMover::ElementsMover Constructor
@@ -60,23 +62,39 @@
  * @param driver_item item moved by mouse and don't be moved by Element mover
  * @return the numbers of items to be moved or -1 if movement can't be init.
  */
-int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item) {
-	// They must be no movement in progress
+int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item)
+{
+		// They must be no movement in progress
 	if (movement_running_) return(-1);
 	
-	// Be sure we have diagram to work
+		// Be sure we have diagram to work
 	if (!diagram) return(-1);
 	diagram_ = diagram;
 	
-	// Take count of driver item
+		// Take count of driver item
 	m_movement_driver = driver_item;
 	
-	// At the beginning of movement, move is NULL
+		// At the beginning of movement, move is NULL
 	current_movement_ = QPointF(0.0, 0.0);
 	
 	m_moved_content = DiagramContent(diagram);
 	m_moved_content.removeNonMovableItems();
 
+		//Remove element text, if the parent element is selected.
+	QList<DynamicElementTextItem *> deti_list = m_moved_content.m_element_texts.toList();
+	for(DynamicElementTextItem *deti : deti_list) {
+		if(m_moved_content.m_elements.contains(deti->parentElement())) {
+			m_moved_content.m_element_texts.remove(deti);
+		}
+	}
+
+	QList<ElementTextItemGroup *> etig_list = m_moved_content.m_texts_groups.toList();
+	for(ElementTextItemGroup *etig : etig_list) {
+		if (m_moved_content.m_elements.contains(etig->parentElement())) {
+			m_moved_content.m_texts_groups.remove(etig);
+		}
+	}
+
 	if (!m_moved_content.count()) return(-1);
 	
 	/* At this point, we've got all info to manage movement.
@@ -98,7 +116,7 @@
 
 	//Move every movable item, except conductor
 	typedef DiagramContent dc;
-	for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes))
+	for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::ElementTextFields | dc::TextGroup))
 	{
 		if (qgi == m_movement_driver)
 			continue;


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