[qet] qet/qet: [4802] Conductor autonum : use a default QUndoCommand as parent of other inherited QUndoCommand.

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


Revision: 4802
Author:   blacksun
Date:     2016-12-07 19:56:31 +0100 (Wed, 07 Dec 2016)
Log Message:
-----------
Conductor autonum : use a default QUndoCommand as parent of other inherited QUndoCommand.

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/qetgraphicsitem/terminal.cpp

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2016-12-07 02:36:47 UTC (rev 4801)
+++ trunk/sources/conductorautonumerotation.cpp	2016-12-07 18:56:31 UTC (rev 4802)
@@ -66,12 +66,25 @@
 	cp.text = t;
 	new_value.setValue(cp);
 
-	QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
-	undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
+	QUndoCommand *undo = nullptr;
 
+	if (m_parent_undo)
+	{
+		new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
+		undo = m_parent_undo;
+	}
+	else
+	{
+		undo = new QUndoCommand();
+		new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo);
+		undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
+	}
+
 	if (!conductor_list.isEmpty())
 	{
-		undo->setText(QObject::tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
+		if (!m_parent_undo)
+			undo->setText(QObject::tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
+
 		foreach (Conductor *cond, conductor_list)
 		{
 			ConductorProperties cp2 = cond -> properties();

Modified: trunk/sources/qetgraphicsitem/terminal.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/terminal.cpp	2016-12-07 02:36:47 UTC (rev 4801)
+++ trunk/sources/qetgraphicsitem/terminal.cpp	2016-12-07 18:56:31 UTC (rev 4802)
@@ -602,7 +602,9 @@
 	}
 
 
-	QUndoCommand *undo = new AddItemCommand<Conductor *>(new_conductor, diagram());
+	QUndoCommand *undo = new QUndoCommand();
+	QUndoCommand *aic = new AddItemCommand<Conductor *>(new_conductor, diagram(), QPointF(), undo);
+	undo->setText(aic->text());
 
 	if (use_properties)
 	{


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