From b60983ca1f588afbf9d554d35ae71268b805eb4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 27 Feb 2013 18:55:49 +0100 Subject: [PATCH] Port DeclarativeDragDropEvent --- .../draganddrop/DeclarativeDragDropEvent.cpp | 39 ++++++++++++------- .../draganddrop/DeclarativeDragDropEvent.h | 4 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp b/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp index a719b83f8..627089594 100644 --- a/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp +++ b/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp @@ -1,5 +1,6 @@ /* Copyright (C) 2010 by BetterInbox + Copyright 2013 by Sebastian Kügler Original author: Gregory Schlomoff Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,24 +24,34 @@ #include "DeclarativeDragDropEvent.h" -DeclarativeDragDropEvent::DeclarativeDragDropEvent(QEvent* e, DeclarativeDropArea* parent) : +DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDropEvent* e, DeclarativeDropArea* parent) : QObject(parent), -// m_x(e->pos().x()), -// m_y(e->pos().y()), -// m_buttons(e->buttons()), -// m_modifiers(e->modifiers()), -// m_data(e->mimeData()), + m_x(e->pos().x()), + m_y(e->pos().y()), + m_buttons(e->mouseButtons()), + m_modifiers(e->keyboardModifiers()), + m_data(e->mimeData()), + m_event(e) +{ + init(); +} + +DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDragLeaveEvent* e, DeclarativeDropArea* parent) : + QObject(parent), + m_x(0), + m_y(0), + m_buttons(Qt::NoButton), + m_modifiers(Qt::NoModifier), + //m_data(e->mimeData()), m_event(0) { - QPointF pos; - m_event = dynamic_cast(e); // also covers enter +} - if (m_event) { -// m_x = m_event->pos.x(); -// m_y = m_event->pos.y(); - m_buttons = m_event->mouseButtons(); - } - if (parent) { +void DeclarativeDragDropEvent::init() +{ + QPointF pos; + + if (parent()) { //pos = parent->mapFromScene(e->scenePos()); m_x = pos.x(); m_y = pos.y(); diff --git a/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.h b/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.h index 0299b16b6..468f7850e 100644 --- a/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.h +++ b/src/declarativeimports/draganddrop/DeclarativeDragDropEvent.h @@ -95,7 +95,8 @@ class DeclarativeDragDropEvent : public QObject public: - DeclarativeDragDropEvent(QEvent* e, DeclarativeDropArea* parent = 0); + DeclarativeDragDropEvent(QDropEvent* e, DeclarativeDropArea* parent = 0); + DeclarativeDragDropEvent(QDragLeaveEvent* e, DeclarativeDropArea* parent = 0); int x() const { return m_x; } int y() const { return m_y; } @@ -109,6 +110,7 @@ public Q_SLOTS: void accept(int action); private: + void init(); int m_x; int m_y; Qt::MouseButtons m_buttons;