use a position relative to the DropArea

view-position is completely useless from QML
This commit is contained in:
Marco Martin 2012-10-23 13:53:37 +02:00
parent f8e9eeb587
commit 3910b0604f
2 changed files with 10 additions and 5 deletions

View File

@ -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)

View File

@ -27,18 +27,19 @@
#include <QObject>
#include <QGraphicsSceneDragDropEvent>
#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; }