diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-07-25 10:09:38 +0300 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-07-25 15:26:51 +0200 |
commit | 43f2246995faf6c6051af862cb6d2ca64d7c08c6 (patch) | |
tree | 35f068a31cce639b7833d58d110972cb26c38b11 /src/gui/kernel/qguiapplication.cpp | |
parent | ec984bdd3e8e640606d420a68bcb00967d5f55fe (diff) |
Add drag and drop events to QWindowSystemInterface.
For non-desktop platforms these are better suited and are more
QPA style than relying purely on QDragManager/QSimpleDrag/sending
drag events directly to the windows.
Change-Id: Id466830cf83427b3d86925602086a858e8f713e5
Reviewed-on: http://codereview.qt.nokia.com/2084
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b44503141e..6edf71ad3d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -62,6 +62,7 @@ #include "private/qwindow_p.h" #include "private/qkeymapper_p.h" #include "private/qcursor_p.h" +#include "private/qdnd_p.h" #ifndef QT_NO_CURSOR #include "qplatformcursor_qpa.h" #endif @@ -755,6 +756,51 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E QCoreApplication::sendSpontaneousEvent(e->exposed.data(), &event); } +Qt::DropAction QGuiApplicationPrivate::processDrag(QWindow *w, QMimeData *dropData, const QPoint &p) +{ + static QPointer<QWindow> currentDragWindow; + QDragManager *manager = QDragManager::self(); + if (!dropData) { + if (currentDragWindow.data() == w) + currentDragWindow = 0; + QDragLeaveEvent e; + QGuiApplication::sendEvent(w, &e); + manager->global_accepted_action = Qt::IgnoreAction; + return Qt::IgnoreAction; + } + QDragMoveEvent me(p, manager->possible_actions, dropData, + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); + if (w != currentDragWindow) { + if (currentDragWindow) { + QDragLeaveEvent e; + QGuiApplication::sendEvent(currentDragWindow, &e); + manager->global_accepted_action = Qt::IgnoreAction; + } + currentDragWindow = w; + QDragEnterEvent e(p, manager->possible_actions, dropData, + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); + QGuiApplication::sendEvent(w, &e); + manager->global_accepted_action = e.isAccepted() ? e.dropAction() : Qt::IgnoreAction; + if (manager->global_accepted_action != Qt::IgnoreAction) { + me.setDropAction(manager->global_accepted_action); + me.accept(); + } + } + QGuiApplication::sendEvent(w, &me); + manager->global_accepted_action = me.isAccepted() ? me.dropAction() : Qt::IgnoreAction; + return manager->global_accepted_action; +} + +Qt::DropAction QGuiApplicationPrivate::processDrop(QWindow *w, QMimeData *dropData, const QPoint &p) +{ + QDragManager *manager = QDragManager::self(); + QDropEvent de(p, manager->possible_actions, dropData, + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); + QGuiApplication::sendEvent(w, &de); + manager->global_accepted_action = de.isAccepted() ? de.dropAction() : Qt::IgnoreAction; + return manager->global_accepted_action; +} + #ifndef QT_NO_CLIPBOARD QClipboard * QGuiApplication::clipboard() { |