[qet] [4017] Fix regression : Check conductors text when link two folios report.

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


Revision: 4017
Author:   blacksun
Date:     2015-06-16 10:26:03 +0200 (Tue, 16 Jun 2015)
Log Message:
-----------
Fix regression : Check conductors text when link two folios report.

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

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2015-06-15 21:08:46 UTC (rev 4016)
+++ trunk/sources/conductorautonumerotation.cpp	2015-06-16 08:26:03 UTC (rev 4017)
@@ -58,7 +58,7 @@
  * @param conductor
  * A conductor of the potential to check.
  */
-void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
+void ConductorAutoNumerotation::checkPotential(Conductor *conductor, QUndoCommand *parent) {
 		//fill list of potential
 	QSet <Conductor *> c_list = conductor->relatedPotentialConductors();
 	c_list << conductor;
@@ -70,7 +70,7 @@
 	if (!QET::eachStrIsEqual(strl)) {
 		PotentialTextsDialog ptd(conductor, conductor->diagramEditor());
 		if ( ptd.exec() == QDialog::Accepted ) {
-			ConductorAutoNumerotation can(conductor, conductor -> diagram());
+			ConductorAutoNumerotation can(conductor, conductor -> diagram(), parent);
 			can.applyText(ptd.selectedText());
 		}
 	}

Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h	2015-06-15 21:08:46 UTC (rev 4016)
+++ trunk/sources/conductorautonumerotation.h	2015-06-16 08:26:03 UTC (rev 4017)
@@ -32,7 +32,7 @@
 
 			//methods
 		void        numerate       ();
-		static void checkPotential (Conductor *);
+		static void checkPotential (Conductor *conductor, QUndoCommand *parent = nullptr);
 		void        applyText      (QString);
 
 	private:

Modified: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp	2015-06-15 21:08:46 UTC (rev 4016)
+++ trunk/sources/ui/linksingleelementwidget.cpp	2015-06-16 08:26:03 UTC (rev 4017)
@@ -190,8 +190,8 @@
 void LinkSingleElementWidget::enableLiveEdit()
 {
 	if (!esw_) return;
-	connect(esw_, &ElementSelectorWidget::elementSelected, this, &LinkSingleElementWidget::apply);
-	connect(ui->m_unlink_pb, &QPushButton::clicked, this, &LinkSingleElementWidget::apply);
+	connect(esw_, &ElementSelectorWidget::elementSelected, this, &LinkSingleElementWidget::apply, Qt::QueuedConnection);
+	connect(ui->m_unlink_pb, &QPushButton::clicked, this, &LinkSingleElementWidget::apply, Qt::QueuedConnection);
 }
 
 /**

Modified: trunk/sources/undocommand/linkelementcommand.cpp
===================================================================
--- trunk/sources/undocommand/linkelementcommand.cpp	2015-06-15 21:08:46 UTC (rev 4016)
+++ trunk/sources/undocommand/linkelementcommand.cpp	2015-06-16 08:26:03 UTC (rev 4017)
@@ -18,6 +18,7 @@
 #include "linkelementcommand.h"
 #include "element.h"
 #include "diagram.h"
+#include "conductorautonumerotation.h"
 
 /**
  * @brief LinkElementCommand::LinkElementCommand
@@ -27,7 +28,8 @@
  */
 LinkElementCommand::LinkElementCommand(Element *element_, QUndoCommand *parent):
 	QUndoCommand(parent),
-	m_element(element_)
+	m_element(element_),
+	m_first_redo (true)
 {
 	m_linked_before = m_linked_after = m_element->linkedElements();
 	setText(QObject::tr("Éditer les référence croisé", "edite the cross reference"));
@@ -40,7 +42,7 @@
  */
 bool LinkElementCommand::mergeWith(const QUndoCommand *other)
 {
-	if (id() != other->id()) return false;
+	if (id() != other->id() || other->childCount()) return false;
 	LinkElementCommand const *undo = static_cast<const LinkElementCommand *> (other);
 	if (m_element != undo->m_element) return false;
 	m_linked_after = undo->m_linked_after;
@@ -204,6 +206,14 @@
 {
 	if(m_element->diagram()) m_element->diagram()->showMe();
 	makeLink(m_linked_after);
+
+	if (m_first_redo && (m_element->linkType() & Element::AllReport) \
+		&& m_element->conductors().size() \
+		&& m_linked_after.size() && m_linked_after.first()->conductors().size())
+	{
+		ConductorAutoNumerotation::checkPotential(m_element->conductors().first(), this);
+		m_first_redo = false;
+	}
 	QUndoCommand::redo();
 }
 

Modified: trunk/sources/undocommand/linkelementcommand.h
===================================================================
--- trunk/sources/undocommand/linkelementcommand.h	2015-06-15 21:08:46 UTC (rev 4016)
+++ trunk/sources/undocommand/linkelementcommand.h	2015-06-16 08:26:03 UTC (rev 4017)
@@ -54,6 +54,7 @@
 
 	private:
 		Element *m_element;
+		bool m_first_redo;
 		QList<Element *> m_linked_before; //<Linked elements before this command, or when we call "undo"
 		QList<Element *> m_linked_after;  //<Linked elements after this command, or when we recall "redo"
 };


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