[qet] [1806] Element editor: fixed a bug when determining the zValue for a newly added part.

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


Revision: 1806
Author:   xavier
Date:     2012-05-11 23:27:31 +0200 (Fri, 11 May 2012)
Log Message:
-----------
Element editor: fixed a bug when determining the zValue for a newly added part.

Modified Paths:
--------------
    trunk/sources/editor/editorcommands.cpp
    trunk/sources/editor/elementscene.cpp

Modified: trunk/sources/editor/editorcommands.cpp
===================================================================
--- trunk/sources/editor/editorcommands.cpp	2012-05-11 18:17:29 UTC (rev 1805)
+++ trunk/sources/editor/editorcommands.cpp	2012-05-11 21:27:31 UTC (rev 1806)
@@ -236,7 +236,9 @@
 void AddPartCommand::redo() {
 	// le premier appel a redo, lors de la construction de l'objet, ne doit pas se faire
 	if (first_redo) {
-		part -> setZValue(editor_scene -> items().count());
+		QList<QGraphicsItem *> existing_items = editor_scene -> zItems();
+		qreal z = existing_items.count() ? existing_items.last() -> zValue() + 1 : 1;
+		part -> setZValue(z);
 		editor_scene -> clearSelection();
 		part -> setSelected(true);
 		first_redo = false;

Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp	2012-05-11 18:17:29 UTC (rev 1805)
+++ trunk/sources/editor/elementscene.cpp	2012-05-11 21:27:31 UTC (rev 1806)
@@ -1211,7 +1211,7 @@
 				else if (qde.tagName() == "arc")      cep = new PartArc      (element_editor, 0, 0);
 				else continue;
 				if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) {
-					qgi -> setZValue(z++);
+					if (!qgi -> zValue()) qgi -> setZValue(z++);
 					loaded_parts << qgi;
 				}
 				cep -> fromXml(qde);


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