Clear PLC slave data on paste

This commit is contained in:
Kellermorph
2026-09-13 12:58:43 +02:00
parent 467a14df71
commit 9c55d36d55
+22
View File
@@ -21,6 +21,7 @@
#include "qetgraphicsitem/conductortextitem.h"
#include "qetgraphicsitem/element.h"
#include "qetgraphicsitem/elementtextitemgroup.h"
#include "qetinformation.h"
#include "qgimanager.h"
/**
@@ -97,6 +98,27 @@ void PasteDiagramCommand::redo()
dc.addValue("label", "");
dc.addValue("comment", "");
dc.addValue("location", "");
// PLC slaves store master data (type, address, comment,
// cross-ref, etc.) in their own elementInformations.
// Remove them the same way MasterElement::unlinkElement()
// does, so pasted PLC slaves start clean like regular
// slaves.
if (e->linkType() == Element::Slave) {
dc.remove(QETInformation::ELMT_PLC_TYPE);
dc.remove(QETInformation::ELMT_PLC_ADDRESS);
dc.remove(QETInformation::ELMT_PLC_FUNCTION);
dc.remove(QETInformation::ELMT_PLC_COMMENT);
dc.remove(QETInformation::ELMT_PLC_CROSSREF);
dc.remove(QETInformation::ELMT_LABEL);
dc.remove(QETInformation::ELMT_PLC_TC);
dc.remove(QETInformation::ELMT_PLC_T1);
dc.remove(QETInformation::ELMT_PLC_T2);
dc.remove(QETInformation::ELMT_PLC_T3);
dc.remove(QETInformation::ELMT_PLC_T4);
dc.remove(QStringLiteral("xref"));
}
e->setElementInformations(dc);
//Reset the text of conductors, the same way the label/comment/