From 3910b0604fc17215a8537173d958b1d002a703e4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 23 Oct 2012 13:53:37 +0200 Subject: [PATCH] use a position relative to the DropArea view-position is completely useless from QML --- .../draganddrop/DeclarativeDragDropEvent.cpp | 8 ++++++-- declarativeimports/draganddrop/DeclarativeDragDropEvent.h | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp b/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp index d5bb1984c..aeb70df66 100644 --- a/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp +++ b/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp @@ -23,7 +23,7 @@ #include "DeclarativeDragDropEvent.h" -DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* parent) : +DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, DeclarativeDropArea* parent) : QObject(parent), m_x(e->pos().x()), m_y(e->pos().y()), @@ -32,7 +32,11 @@ DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* m_data(e->mimeData()), m_event(e) { - + if (parent) { + QPointF pos = parent->mapFromScene(e->scenePos()); + m_x = pos.x(); + m_y = pos.y(); + } } void DeclarativeDragDropEvent::accept(int action) diff --git a/declarativeimports/draganddrop/DeclarativeDragDropEvent.h b/declarativeimports/draganddrop/DeclarativeDragDropEvent.h index e199499c1..cb19af2d9 100644 --- a/declarativeimports/draganddrop/DeclarativeDragDropEvent.h +++ b/declarativeimports/draganddrop/DeclarativeDragDropEvent.h @@ -27,18 +27,19 @@ #include #include #include "DeclarativeMimeData.h" +#include "DeclarativeDropArea.h" class DeclarativeDragDropEvent : public QObject { Q_OBJECT /** - * The mouse X position of the event relative to the view that sent the event. + * The mouse X position of the event relative to the DropArea that is receiving the event. */ Q_PROPERTY(int x READ x) /** - * The mouse Y position of the event relative to the view that sent the event. + * The mouse Y position of the event relative to the DropArea that is receiving the event. */ Q_PROPERTY(int y READ y) @@ -94,7 +95,7 @@ class DeclarativeDragDropEvent : public QObject public: - DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* parent = 0); + DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, DeclarativeDropArea* parent = 0); int x() const { return m_x; } int y() const { return m_y; }