diff --git a/sources/conductorautonumerotation.cpp b/sources/conductorautonumerotation.cpp index a1b782aa6..9da3870bd 100644 --- a/sources/conductorautonumerotation.cpp +++ b/sources/conductorautonumerotation.cpp @@ -58,7 +58,7 @@ void ConductorAutoNumerotation::numerate() { * @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 c_list = conductor->relatedPotentialConductors(); c_list << conductor; @@ -70,7 +70,7 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) { 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()); } } diff --git a/sources/conductorautonumerotation.h b/sources/conductorautonumerotation.h index ea9e9a57c..75c49f39f 100644 --- a/sources/conductorautonumerotation.h +++ b/sources/conductorautonumerotation.h @@ -32,7 +32,7 @@ class ConductorAutoNumerotation //methods void numerate (); - static void checkPotential (Conductor *); + static void checkPotential (Conductor *conductor, QUndoCommand *parent = nullptr); void applyText (QString); private: diff --git a/sources/ui/linksingleelementwidget.cpp b/sources/ui/linksingleelementwidget.cpp index b6ff6da65..db9994396 100644 --- a/sources/ui/linksingleelementwidget.cpp +++ b/sources/ui/linksingleelementwidget.cpp @@ -190,8 +190,8 @@ bool LinkSingleElementWidget::setLiveEdit(bool live_edit) 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); } /** diff --git a/sources/undocommand/linkelementcommand.cpp b/sources/undocommand/linkelementcommand.cpp index 91504ddc5..a9e71a9a7 100644 --- a/sources/undocommand/linkelementcommand.cpp +++ b/sources/undocommand/linkelementcommand.cpp @@ -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 @@ LinkElementCommand::LinkElementCommand(Element *element_, QUndoCommand *parent): */ 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 (other); if (m_element != undo->m_element) return false; m_linked_after = undo->m_linked_after; @@ -204,6 +206,14 @@ void LinkElementCommand::redo() { 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(); } diff --git a/sources/undocommand/linkelementcommand.h b/sources/undocommand/linkelementcommand.h index c8f307e02..e2f8c3549 100644 --- a/sources/undocommand/linkelementcommand.h +++ b/sources/undocommand/linkelementcommand.h @@ -54,6 +54,7 @@ class LinkElementCommand : public QUndoCommand private: Element *m_element; + bool m_first_redo; QList m_linked_before; // m_linked_after; //