From 074e2c8b2d831f7d0c24e46da433abf1360b1b78 Mon Sep 17 00:00:00 2001 From: Simon De Backer Date: Sat, 3 Oct 2020 15:42:58 +0200 Subject: [PATCH] QT6: QDropEvent --- sources/diagramview.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 011514f4e..6ea9d28f3 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -34,6 +34,8 @@ #include "changetitleblockcommand.h" #include "conductorcreator.h" +#include + /** Constructeur @param diagram Schema a afficher ; si diagram vaut 0, un nouveau Diagram est utilise @@ -200,7 +202,19 @@ void DiagramView::handleElementDrop(QDropEvent *event) return; } - diagram()->setEventInterface(new DiagramEventAddElement(location, diagram(), mapToScene(event->pos()))); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove + diagram()->setEventInterface( + new DiagramEventAddElement( + location, diagram(), mapToScene(event->pos()))); +#else +#if TODO_LIST +#pragma message("@TODO remove code for QT 6 or later") +#endif + diagram()->setEventInterface( + new DiagramEventAddElement( + location, diagram(), event->position())); +#endif + //Set focus to the view to get event this->setFocus(); } @@ -268,7 +282,19 @@ void DiagramView::handleTextDrop(QDropEvent *e) { iti -> setHtml (e -> mimeData() -> text()); } - m_diagram -> undoStack().push(new AddItemCommand(iti, m_diagram, mapToScene(e->pos()))); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove + + m_diagram -> undoStack().push( + new AddItemCommand( + 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 AddItemCommand( + iti, m_diagram, e->position())); +#endif } /** @@ -588,7 +614,15 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e) }); QMenu *menu = new QMenu(this); menu->addAction(act); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove menu->popup(e->globalPos()); +#else +#if TODO_LIST +#pragma message("@TODO remove code for QT 6 or later") +#endif + menu->popup(e->pos()); +#endif } m_free_rubberbanding = false;