[qet] qet/qet: [4834] Minor revamp

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


Revision: 4834
Author:   blacksun
Date:     2017-01-05 20:32:52 +0100 (Thu, 05 Jan 2017)
Log Message:
-----------
Minor revamp

Modified Paths:
--------------
    trunk/sources/ui/potentialselectordialog.cpp
    trunk/sources/ui/potentialselectordialog.h

Modified: trunk/sources/ui/potentialselectordialog.cpp
===================================================================
--- trunk/sources/ui/potentialselectordialog.cpp	2017-01-05 15:25:07 UTC (rev 4833)
+++ trunk/sources/ui/potentialselectordialog.cpp	2017-01-05 19:32:52 UTC (rev 4834)
@@ -44,8 +44,8 @@
 			terminal_1->removeConductor(conductor);
 			terminal_2->removeConductor(conductor);
 
-			getPotential(terminal_1, m_properties_1, m_seq_num_1, m_conductor_number_1, m_properties_list_1);
-			getPotential(terminal_2, m_properties_2, m_seq_num_2, m_conductor_number_2, m_properties_list_2);
+			getPotential(terminal_1, m_seq_num_1, m_conductor_number_1, m_properties_list_1, m_conductors_list_1);
+			getPotential(terminal_2, m_seq_num_2, m_conductor_number_2, m_properties_list_2, m_conductors_list_2);
 
 				//There isn't a potential at terminal 1 or 2.
 			if (m_conductor_number_1 == 0 && m_conductor_number_2 == 0) return;
@@ -65,7 +65,7 @@
 		 * @param properties
 		 * @param number
 		 */
-		void getPotential(Terminal *terminal, ConductorProperties &properties, autonum::sequentialNumbers &seq_num , int &number, QList<ConductorProperties> &properties_list)
+		void getPotential(Terminal *terminal, autonum::sequentialNumbers &seq_num , int &number, QList<ConductorProperties> &properties_list, QList<Conductor*> &c_list)
 		{
 			Conductor *conductor_in_potential = nullptr;
 
@@ -100,11 +100,10 @@
 
 			if (!conductor_in_potential)
 				return;
-			properties = conductor_in_potential->properties();
 			seq_num = conductor_in_potential->sequenceNum();
 			number = conductor_in_potential->relatedPotentialConductors().size()+1; //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors
 
-			QList<Conductor *> c_list = conductor_in_potential->relatedPotentialConductors().toList();
+			c_list = conductor_in_potential->relatedPotentialConductors().toList();
 			c_list.append(conductor_in_potential);
 			foreach(Conductor *c, c_list)
 				properties_list.append(c->properties());
@@ -135,24 +134,18 @@
 				if (report->conductors().isEmpty() || other_report->conductors().isEmpty())
 					return;
 
-				QList <Conductor*> c_list;
-
-				m_properties_1 = report->conductors().first()->properties();
 				m_conductor_number_1 = report->conductors().first()->relatedPotentialConductors().size() + 1;
 				m_seq_num_1 = report->conductors().first()->sequenceNum();
-				c_list.append(report->conductors().first()->relatedPotentialConductors().toList());
-				c_list.append(report->conductors().first());
-				foreach(Conductor *c, c_list)
+				m_conductors_list_1.append(report->conductors().first()->relatedPotentialConductors().toList());
+				m_conductors_list_1.append(report->conductors().first());
+				foreach(Conductor *c, m_conductors_list_1)
 					m_properties_list_1 << c->properties();
 
-				c_list.clear();
-
-				m_properties_2 = other_report->conductors().first()->properties();
 				m_conductor_number_2 = other_report->conductors().first()->relatedPotentialConductors().size() + 1;
 				m_seq_num_2 = other_report->conductors().first()->sequenceNum();
-				c_list.append(other_report->conductors().first()->relatedPotentialConductors().toList());
-				c_list.append(other_report->conductors().first());
-				foreach(Conductor *c, c_list)
+				m_conductors_list_2.append(other_report->conductors().first()->relatedPotentialConductors().toList());
+				m_conductors_list_2.append(other_report->conductors().first());
+				foreach(Conductor *c, m_conductors_list_2)
 					m_properties_list_2 << c->properties();
 
 					//We relink the report
@@ -221,17 +214,16 @@
  */
 void PotentialSelectorDialog::buildWidget()
 {
-	QRadioButton *rb1 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_1.text).arg(m_potential_selector->m_conductor_number_1), this);
-	QRadioButton *rb2 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_2.text).arg(m_potential_selector->m_conductor_number_2), this);
+	QRadioButton *rb1 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_list_1.first().text).arg(m_potential_selector->m_conductor_number_1), this);
+	QRadioButton *rb2 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_list_2.first().text).arg(m_potential_selector->m_conductor_number_2), this);
 
 	connect(rb1, &QRadioButton::toggled, [this](bool t)
 	{
 		if(t)
 		{
-			this->m_selected_properties = this->m_potential_selector->m_properties_1;
 			this->m_sequential_num = this->m_potential_selector->m_seq_num_1;
 			this->m_properties_list = this->m_potential_selector->m_properties_list_1;
-			m_selected = 1;
+			this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_2;
 		}
 	});
 	connect(rb2, &QRadioButton::toggled, [this](bool t)
@@ -238,10 +230,9 @@
 	{
 		if(t)
 		{
-			this->m_selected_properties = this->m_potential_selector->m_properties_2;
 			this->m_sequential_num = this->m_potential_selector->m_seq_num_2;
 			this->m_properties_list = this->m_potential_selector->m_properties_list_2;
-			m_selected = 2;
+			this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_1;
 		}
 	});
 
@@ -285,30 +276,12 @@
 			if (m_report->diagram())
 				diagram = m_report->diagram();
 
-				//We temporarily unlink report to get the two existing potential
-			Element *other_report = m_report->linkedElements().first();
-			m_report->unlinkAllElements();
-
-			QList<Conductor *> conductor_list;
-
-			if (m_selected == 1)
-			{
-				conductor_list.append(other_report->conductors().first()->relatedPotentialConductors().toList());
-				conductor_list.append(other_report->conductors().first());
-			}
-
-			else if (m_selected == 2)
-			{
-				conductor_list.append(m_report->conductors().first()->relatedPotentialConductors().toList());
-				conductor_list.append(m_report->conductors().first());
-			}
-
 			QVariant old_value, new_value;
 			QVariant old_seq, new_seq;
 			new_seq.setValue(m_sequential_num);
 
 				//Set the new properties for each conductors of the new potential
-			foreach(Conductor *cond, conductor_list)
+			foreach(Conductor *cond, m_conductors_to_change)
 			{
 				ConductorProperties new_properties = cond->properties();
 				new_properties.applyForEqualAttributes(m_properties_list);
@@ -318,8 +291,6 @@
 				new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
 				new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
 			}
-				//We relink the report
-			m_report->linkToElement(other_report);
 		}
 
 	}

Modified: trunk/sources/ui/potentialselectordialog.h
===================================================================
--- trunk/sources/ui/potentialselectordialog.h	2017-01-05 15:25:07 UTC (rev 4833)
+++ trunk/sources/ui/potentialselectordialog.h	2017-01-05 19:32:52 UTC (rev 4834)
@@ -32,10 +32,10 @@
 		virtual ~AbstractPotentialSelector() {}
 		virtual bool isValid() const = 0;
 
-		ConductorProperties m_properties_1, m_properties_2;
 		autonum::sequentialNumbers m_seq_num_1, m_seq_num_2;
 		int m_conductor_number_1, m_conductor_number_2;
 		QList<ConductorProperties> m_properties_list_1, m_properties_list_2;
+		QList <Conductor *> m_conductors_list_1, m_conductors_list_2;
 };
 
 namespace Ui {
@@ -74,10 +74,10 @@
         Conductor *m_conductor;
 		Element *m_report;
 		QUndoCommand *m_parent_undo;
-		ConductorProperties m_selected_properties;
 		autonum::sequentialNumbers m_sequential_num;
 		AbstractPotentialSelector *m_potential_selector;
 		QList <ConductorProperties> m_properties_list;
+		QList <Conductor *> m_conductors_to_change;
 		int m_selected = 0;
 };
 #endif // POTENTIALSELECTORDIALOG_H


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