[qet] [2634] when change a propertie of conductor, ask for apply the change for each conductor of the same potential

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


Revision: 2634
Author:   blacksun
Date:     2013-11-21 22:34:49 +0100 (Thu, 21 Nov 2013)
Log Message:
-----------
when change a propertie of conductor, ask for apply the change for each conductor of the same potential

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

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2013-11-21 18:58:12 UTC (rev 2633)
+++ trunk/sources/diagramcommands.cpp	2013-11-21 21:34:49 UTC (rev 2634)
@@ -988,16 +988,27 @@
 
 /// definit l'ancienne configuration
 void ChangeSeveralConductorsPropertiesCommand::setOldSettings(const QList<ConductorProperties> &properties) {
-	old_properties = properties;
-	old_settings_set = true;
+	if (!old_settings_set) {
+		old_properties = properties;
+		old_settings_set = true;
+	}
 }
 
 /// definit la nouvelle configuration
 void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const QList<ConductorProperties> &properties) {
-	new_properties = properties;
-	new_settings_set = true;
+	if (!new_settings_set) {
+		new_properties = properties;
+		new_settings_set = true;
+	}
 }
 
+void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const ConductorProperties &properties) {
+	if (!new_settings_set) {
+		single_new_properties = properties;
+		new_settings_set = true;
+	}
+}
+
 /**
 	Annule les changements - Attention : les anciens et nouveaux parametres
 	doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
@@ -1019,12 +1030,24 @@
 */
 void ChangeSeveralConductorsPropertiesCommand::redo() {
 	if (old_settings_set && new_settings_set) {
-		int i=0;
-		foreach(Conductor *c, conductors) {
-			c -> setProperties(new_properties.at(i));
-			c -> update();
-			i++;
+
+		//new propertie are the same for each conductor
+		if (new_properties.isEmpty()) {
+			foreach(Conductor *c, conductors) {
+				c -> setProperties(single_new_properties);
+				c -> update();
+			}
 		}
+
+		//new propertie are different for each conductor
+		else {
+			int i=0;
+			foreach(Conductor *c, conductors) {
+				c -> setProperties(new_properties.at(i));
+				c -> update();
+				i++;
+			}
+		}
 	}
 }
 

Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h	2013-11-21 18:58:12 UTC (rev 2633)
+++ trunk/sources/diagramcommands.h	2013-11-21 21:34:49 UTC (rev 2634)
@@ -544,6 +544,7 @@
 	virtual void redo();
 	virtual void setOldSettings(const QList<ConductorProperties> &);
 	virtual void setNewSettings(const QList<ConductorProperties> &);
+	virtual void setNewSettings(const ConductorProperties &);
 
 	// attributes
 	private:
@@ -553,6 +554,8 @@
 	QList <ConductorProperties> old_properties;
 	/// properties after the change
 	QList <ConductorProperties> new_properties;
+	///  single properties for each conductor
+	ConductorProperties single_new_properties;
 	/// track whether pre-change properties were set
 	bool old_settings_set;
 	/// track whether post-change properties were set

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2013-11-21 18:58:12 UTC (rev 2633)
+++ trunk/sources/diagramview.cpp	2013-11-21 21:34:49 UTC (rev 2634)
@@ -1047,43 +1047,39 @@
 	if (conductor_dialog.exec() == QDialog::Accepted) {
 		// recupere les nouvelles proprietes
 		ConductorProperties new_properties = cpw -> conductorProperties();
+
 		if (new_properties != old_properties) {
 			int qmbreturn=0;
-			//if conductor isn't alone at this potential and text is changed
+			//if conductor isn't alone at this potential and is property is changed
 			//ask user to apply text on every conductors of this potential
-			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"
+			if (edited_conductor -> relatedPotentialConductors().size() >= 1){
+				qmbreturn = QMessageBox::question(diagramEditor(), tr("Propri\351t\351 de conducteurs"),
+												  tr("Voulez-vous appliquer les nouvelles propri\351t\351s \n"
 													 "\340 l'ensemble des conducteurs de ce potentiel ?"),
 												  QMessageBox::No| QMessageBox::Yes, QMessageBox::Yes);
 
 				if (qmbreturn == QMessageBox::Yes){
 					QSet <Conductor *> conductorslist = edited_conductor -> relatedPotentialConductors();
 					conductorslist << edited_conductor;
-					QList <ConductorProperties> old_properties_list, new_properties_list;
-					ConductorProperties cp;
+					QList <ConductorProperties> old_properties_list;
 
 					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);
+							c -> setProperties(new_properties);
 						}
 					}
 					//initialize the corresponding UndoCommand object
 					ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(conductorslist);
 					cscpc -> setOldSettings(old_properties_list);
-					cscpc -> setNewSettings(new_properties_list);
+					cscpc -> setNewSettings(new_properties);
 					diagram() -> undoStack().push(cscpc);
 				}
 			}
+
 			if (qmbreturn == 0 || qmbreturn == QMessageBox::No) {
 				// initialise l'objet UndoCommand correspondant
 				ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(edited_conductor);


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