From 4386425ce310815076739ea5f15fe4f1218599c8 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 7 Jun 2011 15:07:44 +0200 Subject: Implement QDropEvent::source() again QDropEvent::source() now returns a QObject instead of a widget, matching the implementation in QDrag. Reviewed-by: Samuel --- src/gui/kernel/qevent.cpp | 10 ++++------ src/gui/kernel/qevent.h | 2 +- src/widgets/graphicsview/qgraphicsview.cpp | 2 +- src/widgets/to_be_moved/qtextcontrol.cpp | 2 +- src/widgets/to_be_moved/qtextcontrol_p_p.h | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5e01e43e56..f5a5c2826a 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -46,7 +46,7 @@ #include "private/qkeysequence_p.h" #include "qdebug.h" #include "qmime.h" -//#include "private/qdnd_p.h" +#include "private/qdnd_p.h" #include "qevent_p.h" #ifdef Q_OS_SYMBIAN @@ -2265,12 +2265,10 @@ bool QDropEvent::provides(const char *mimeType) const \sa QDrag::QDrag() */ -QWidget* QDropEvent::source() const +QObject* QDropEvent::source() const { - return 0; - // ### Qt5 -// QDragManager *manager = QDragManager::self(); -// return manager ? manager->source() : 0; + QDragManager *manager = QDragManager::self(); + return (manager && manager->object) ? manager->object->source() : 0; } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 21a0b05b55..fc9e8118fd 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -443,7 +443,7 @@ public: inline Qt::DropAction dropAction() const { return drop_action; } void setDropAction(Qt::DropAction action); - QWidget* source() const; + QObject* source() const; inline const QMimeData *mimeData() const { return mdata; } // QT3_SUPPORT diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index c6e06e22c2..c918072196 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -780,7 +780,7 @@ void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEven dest->setDropAction(source->dropAction()); dest->setMimeData(source->mimeData()); dest->setWidget(viewport); - dest->setSource(source->source()); + dest->setSource(qobject_cast(source->source())); #else Q_UNUSED(dest) Q_UNUSED(source) diff --git a/src/widgets/to_be_moved/qtextcontrol.cpp b/src/widgets/to_be_moved/qtextcontrol.cpp index ab294b9e0d..aeb2ede106 100644 --- a/src/widgets/to_be_moved/qtextcontrol.cpp +++ b/src/widgets/to_be_moved/qtextcontrol.cpp @@ -1885,7 +1885,7 @@ bool QTextControlPrivate::dragMoveEvent(QEvent *e, const QMimeData *mimeData, co return true; // accept proposed action } -bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source) +bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source) { Q_Q(QTextControl); dndFeedbackCursor = QTextCursor(); diff --git a/src/widgets/to_be_moved/qtextcontrol_p_p.h b/src/widgets/to_be_moved/qtextcontrol_p_p.h index 099843437a..1b707eeef3 100644 --- a/src/widgets/to_be_moved/qtextcontrol_p_p.h +++ b/src/widgets/to_be_moved/qtextcontrol_p_p.h @@ -160,7 +160,7 @@ public: bool dragEnterEvent(QEvent *e, const QMimeData *mimeData); void dragLeaveEvent(); bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos); - bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source); + bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source); void inputMethodEvent(QInputMethodEvent *); -- cgit v1.2.3