diff --git a/sources/diagramevent/diagrameventaddmacro.cpp b/sources/diagramevent/diagrameventaddmacro.cpp index 81a0387e0..74714da8c 100644 --- a/sources/diagramevent/diagrameventaddmacro.cpp +++ b/sources/diagramevent/diagrameventaddmacro.cpp @@ -17,6 +17,7 @@ #include #include #include +#include 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); } } diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 548da5acc..4b2d97563 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -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 }