[qet] [2119] fix a bug when change a conductor property on multiple conductor potential with conductor dialog property

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


Revision: 2119
Author:   blacksun
Date:     2013-04-19 14:28:08 +0200 (Fri, 19 Apr 2013)
Log Message:
-----------
fix a bug when change a conductor property on multiple conductor potential with conductor dialog property

Modified Paths:
--------------
    trunk/sources/diagramview.cpp

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2013-04-18 15:53:06 UTC (rev 2118)
+++ trunk/sources/diagramview.cpp	2013-04-19 12:28:08 UTC (rev 2119)
@@ -37,7 +37,6 @@
 #include "qeticons.h"
 #include "qetmessagebox.h"
 #include "qtextorientationspinboxwidget.h"
-#include "conductorautonumerotation.h"
 
 
 /**
@@ -989,16 +988,39 @@
 		ConductorProperties new_properties = cpw -> conductorProperties();
 		if (new_properties != old_properties) {
 			int qmbreturn=0;
-			//if conductor isn't alone at this potential
+			//if conductor isn't alone at this potential and text is changed
 			//ask user to apply text on every conductors of this potential
-			if (edited_conductor -> relatedPotentialConductors().size() >= 1){
+			if ((edited_conductor -> relatedPotentialConductors().size() >= 1) && (old_properties.text != new_properties.text)){
 				qmbreturn = QMessageBox::question(diagramEditor(), tr("Textes de conducteurs"),
 												  tr("Voulez-vous appliquer le nouveau texte \n"
 													 "\340 l'ensemble des conducteurs de ce potentiel ?"),
 												  QMessageBox::No| QMessageBox::Yes, QMessageBox::Yes);
+
 				if (qmbreturn == QMessageBox::Yes){
-					ConductorAutoNumerotation can(edited_conductor);
-					can.setText(new_properties.text);
+					QSet <Conductor *> conductorslist = edited_conductor -> relatedPotentialConductors();
+					conductorslist << edited_conductor;
+					QList <ConductorProperties> old_properties_list, new_properties_list;
+					ConductorProperties cp;
+
+					foreach (Conductor *c, conductorslist) {
+						if (c == edited_conductor) {
+							old_properties_list << old_properties;
+							new_properties_list << new_properties;
+						}
+						else {
+							old_properties_list << c -> properties();
+							cp = c -> properties();
+							cp.text = new_properties.text;
+							c -> setProperties(cp);
+							new_properties_list << c -> properties();
+							c -> setText(new_properties.text);
+						}
+					}
+					//initialize the corresponding UndoCommand object
+					ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(conductorslist);
+					cscpc -> setOldSettings(old_properties_list);
+					cscpc -> setNewSettings(new_properties_list);
+					diagram() -> undoStack().push(cscpc);
 				}
 			}
 			if (qmbreturn == 0 || qmbreturn == QMessageBox::No) {


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