[qet] qet/qet: [5032] When we link two reports together, if the text is the same for every conductors, we don' t ask to user what to do, even if the function or the tension/ protocol are not identical.

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


Revision: 5032
Author:   blacksun
Date:     2017-08-27 13:27:41 +0200 (Sun, 27 Aug 2017)
Log Message:
-----------
When we link two reports together, if the text is the same for every conductors, we don't ask to user what to do, even if the function or the tension/protocol are not identical.
Now we check : text, function and tension/protocol, if one of these three values is not identical, we ask to user what to do.

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

Modified: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp	2017-08-25 07:28:30 UTC (rev 5031)
+++ trunk/sources/ui/linksingleelementwidget.cpp	2017-08-27 11:27:41 UTC (rev 5032)
@@ -83,10 +83,12 @@
 	if(m_showed_element)
 		m_showed_element->setHighlighted(false);
 	
-	m_element->setHighlighted(false);
-	
-	if (!m_element->isFree())
-		m_element->linkedElements().first()->setHighlighted(false);
+	if(m_element)
+	{
+		m_element->setHighlighted(false);		
+		if (!m_element->isFree())
+			m_element->linkedElements().first()->setHighlighted(false);
+	}
 	delete ui;
 }
 

Modified: trunk/sources/ui/potentialselectordialog.cpp
===================================================================
--- trunk/sources/ui/potentialselectordialog.cpp	2017-08-25 07:28:30 UTC (rev 5031)
+++ trunk/sources/ui/potentialselectordialog.cpp	2017-08-27 11:27:41 UTC (rev 5032)
@@ -215,9 +215,28 @@
  */
 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_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);
+	QString text1(tr("%n conducteurs composent potentiel suivant :", "", m_potential_selector->m_conductor_number_1));
+	ConductorProperties cp1 = m_potential_selector->m_properties_list_1.first();
 
+	if(!cp1.text.isEmpty())
+		text1.append(tr("\nNumero : %1").arg(cp1.text));
+	if(!cp1.m_function.isEmpty())
+		text1.append(tr("\nFonction : %1").arg(cp1.m_function));
+	if(!cp1.m_tension_protocol.isEmpty())
+		text1.append(tr("\nTension/protocole : %1").arg(cp1.m_tension_protocol));
+			
+	QString text2(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_2));
+	ConductorProperties cp2 = m_potential_selector->m_properties_list_2.first();
+	if(!cp2.text.isEmpty())
+		text2.append(tr("\nNumero : %1").arg(cp2.text));
+	if(!cp2.m_function.isEmpty())
+		text2.append(tr("\nFonction : %1").arg(cp2.m_function));
+	if(!cp2.m_tension_protocol.isEmpty())
+		text2.append(tr("\nTension/protocole : %1").arg(cp2.m_tension_protocol));
+			
+	QRadioButton *rb1 = new QRadioButton(text1, this);
+	QRadioButton *rb2 = new QRadioButton(text2, this);
+
 	connect(rb1, &QRadioButton::toggled, [this](bool t)
 	{
 		if(t)
@@ -252,7 +271,6 @@
 		rb2->setChecked(true);
 	}
 }
-#include <QDebug>
 
 /**
  * @brief PotentialSelectorDialog::on_buttonBox_accepted

Modified: trunk/sources/undocommand/linkelementcommand.cpp
===================================================================
--- trunk/sources/undocommand/linkelementcommand.cpp	2017-08-25 07:28:30 UTC (rev 5031)
+++ trunk/sources/undocommand/linkelementcommand.cpp	2017-08-27 11:27:41 UTC (rev 5032)
@@ -124,29 +124,6 @@
 }
 
 /**
- * @brief LinkElementCommand::addLink
- * Add elements from the list to the linked element of edited element
- * This method do several check to know if element can be linked or not.
- * @param element_list
- */
-void LinkElementCommand::addLink(QList<Element *> element_list)
-{
-	setUpNewLink(element_list, false);
-}
-
-/**
- * @brief LinkElementCommand::addLink
- * This is an overloaded function
- * @param element_
- */
-void LinkElementCommand::addLink(Element *element_)
-{
-	QList<Element *> list;
-	list << element_;
-	addLink(list);
-}
-
-/**
  * @brief LinkElementCommand::setLink
  * Replace all linked elements of edited element by elements stored in @element_list
  * This method do several check to know if element can be linked or not.
@@ -209,6 +186,9 @@
 	if(m_element->diagram()) m_element->diagram()->showMe();
 	makeLink(m_linked_after);
 
+		//If the action is to link two reports together, we check if the conductors
+		//of the new potential have the same text, function, and protocol.
+		//if not, a dialog ask what do to.
 	if (m_first_redo && (m_element->linkType() & Element::AllReport) \
 		&& m_element->conductors().size() \
 		&& m_linked_after.size() && m_linked_after.first()->conductors().size())
@@ -217,11 +197,18 @@
 		QSet <Conductor *> c_list = m_element->conductors().first()->relatedPotentialConductors();
 		c_list << m_element->conductors().first();
 			//fill list of text
-		QStringList strl;
-		foreach (const Conductor *c, c_list) strl<<(c->properties().text);
+		QStringList str_txt;
+		QStringList str_funct;
+		QStringList str_tens;
+		for (const Conductor *c : c_list)
+		{
+			str_txt   << c->properties().text;
+			str_funct << c->properties().m_function;
+			str_tens  << c->properties().m_tension_protocol;
+		}
 
 			//check text list, isn't same in potential, ask user what to do
-		if (!QET::eachStrIsEqual(strl))
+		if (!QET::eachStrIsEqual(str_txt) || !QET::eachStrIsEqual(str_funct) || !QET::eachStrIsEqual(str_tens))
 		{
 			PotentialSelectorDialog psd(m_element, this);
 			psd.exec();

Modified: trunk/sources/undocommand/linkelementcommand.h
===================================================================
--- trunk/sources/undocommand/linkelementcommand.h	2017-08-25 07:28:30 UTC (rev 5031)
+++ trunk/sources/undocommand/linkelementcommand.h	2017-08-27 11:27:41 UTC (rev 5032)
@@ -38,8 +38,6 @@
 
 		static bool isLinkable (Element *element_a, Element *element_b, bool already_linked = false);
 
-		void addLink (QList<Element *> element_list);
-		void addLink (Element *element_);
 		void setLink (QList<Element *> element_list);
 		void setLink (Element *element_);
 		void unlink  (QList<Element *> element_list);


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