Compare commits

..

5 Commits

Author SHA1 Message Date
Laurent Trinques 3cbb930751 Update pl translations, thanks Pawel 2026-09-13 17:04:41 +02:00
Laurent Trinques 51209d30b6 Merge pull request #855 from Kellermorph/copy-paste-fix
Clear PLC slave data on paste
2026-09-13 13:32:09 +02:00
Kellermorph 9c55d36d55 Clear PLC slave data on paste 2026-09-13 12:58:43 +02:00
Laurent Trinques 3ac557570c Merge pull request #853 from Kellermorph/fix-template-placing
Fix macro drag-and-drop placement and preview for Qt6
2026-09-13 12:27:51 +02:00
Kellermorph 0c2cf409f8 Fix macro drag-and-drop placement and preview for Qt6 2026-09-13 10:09:44 +02:00
4 changed files with 1498 additions and 1689 deletions
+1464 -1678
View File
File diff suppressed because it is too large Load Diff
+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/
@@ -17,6 +17,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QStatusBar>
#include <QPainter>
#include <QSettings>
DiagramEventAddMacro::DiagramEventAddMacro(const ElementsLocation &location, Diagram *diagram, QPointF pos) :
DiagramEventInterface(diagram),
@@ -63,6 +64,7 @@ m_preview_item(nullptr)
QDomElement diagram_node = root.firstChildElement("diagram_content").firstChildElement("diagram");
if (!diagram_node.isNull()) {
dummy_diagram->setDisplayGrid(false);
dummy_diagram->fromXml(diagram_node, QPointF(0, 0), false, nullptr);
QRectF scene_rect = dummy_diagram->itemsBoundingRect();
@@ -237,13 +239,16 @@ void DiagramEventAddMacro::addMacro(QPointF final_pos)
if (!diagram_node.isNull()) {
QDomElement cloned_node = diagram_node.cloneNode(true).toElement();
QPointF target_pos = final_pos;
DiagramContent pasted_content;
m_diagram->fromXml(cloned_node, target_pos, false, &pasted_content);
m_diagram->fromXml(cloned_node, final_pos, false, &pasted_content);
m_diagram->refreshContents();
// Prevent PasteDiagramCommand from erasing labels (BMK)
QSettings settings;
bool saved_erase = settings.value("diagramcommands/erase-label-on-copy", true).toBool();
settings.setValue("diagramcommands/erase-label-on-copy", false);
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, pasted_content));
settings.setValue("diagramcommands/erase-label-on-copy", saved_erase);
}
}
+4 -8
View File
@@ -211,10 +211,10 @@ void DiagramView::handleElementDrop(QDropEvent *event)
}
QPointF drop_pos;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
drop_pos = mapToScene(event->pos());
#else
drop_pos = event->position();
drop_pos = mapToScene(event->position().toPoint());
#endif
if (location.path().endsWith(".qetmak")) {
@@ -290,16 +290,12 @@ void DiagramView::handleTextDrop(QDropEvent *e) {
iti -> setHtml (e -> mimeData() -> text());
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
iti, m_diagram, mapToScene(e->pos())));
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
iti, m_diagram, e->position()));
iti, m_diagram, mapToScene(e->position().toPoint())));
#endif
}