From: Laszlo Agocs Date: Mon, 25 Jul 2011 07:12:39 +0000 (+0300) Subject: Support non-desktop platforms better with QDragManager. X-Git-Tag: qt-v5.0.0-alpha1~3626^2~258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ce5297cc506b16ffefaf018952ed2bf20ceb46b;p=profile%2Fivi%2Fqtbase.git Support non-desktop platforms better with QDragManager. By default QDragManager brings in a number of "desktopisms" (e.g. that a drag is always controlled by mouse events, can be cancelled with some key press, etc.), these assumptions are not necessarily suitable for all QPA platforms. Therefore there has to be a way to disable this built-in event handling, and let the QPlaformDrag decide how the drag is controlled and when it ends. Change-Id: Ie9fa2df7ba1e30dd1c6e2cff406490e36be73c4f Reviewed-on: http://codereview.qt.nokia.com/2085 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index 8ce4f11..4ed2515 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -511,6 +511,24 @@ void QDragManager::cancel(bool deleteSource) global_accepted_action = Qt::IgnoreAction; } +/*! + Called from startDrag() in QPlatformDrag implementations that do not need + the desktop-oriented stuff provided by the event filter (e.g. because their + drag is not based on mouse events). Instead, they will manage everything on + their own, will not rely on move/drop/cancel, and will call stopDrag() to stop + the event loop when the drag is over. + */ +void QDragManager::unmanageEvents() +{ + qApp->removeEventFilter(this); +} + +void QDragManager::stopDrag() +{ + if (eventLoop) + eventLoop->exit(); +} + #endif // QT_NO_DRAGANDDROP #if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 7159acf..2a81de5 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -200,6 +200,9 @@ public: QShapedPixmapWindow *shapedPixmapWindow; + void unmanageEvents(); + void stopDrag(); + private: QMimeData *platformDropData;