| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com> |
| 3 | SPDX-FileContributor: Gregory Schlomoff <greg@betterinbox.com> |
| 4 | SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org> |
| 5 | |
| 6 | SPDX-License-Identifier: MIT |
| 7 | */ |
| 8 | |
| 9 | #include "DeclarativeDragDropEvent.h" |
| 10 | |
| 11 | DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDropEvent *e, DeclarativeDropArea *parent) |
| 12 | : QObject(parent) |
| 13 | , m_x(e->position().x()) |
| 14 | , m_y(e->position().y()) |
| 15 | , m_buttons(e->buttons()) |
| 16 | , m_modifiers(e->modifiers()) |
| 17 | , m_data(nullptr) |
| 18 | , m_event(e) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDragLeaveEvent *e, DeclarativeDropArea *parent) |
| 23 | : QObject(parent) |
| 24 | , m_x(0) |
| 25 | , m_y(0) |
| 26 | , m_buttons(Qt::NoButton) |
| 27 | , m_modifiers(Qt::NoModifier) |
| 28 | , m_data(nullptr) |
| 29 | , m_event(nullptr) |
| 30 | { |
| 31 | Q_UNUSED(e); |
| 32 | } |
| 33 | |
| 34 | void DeclarativeDragDropEvent::accept(int action) |
| 35 | { |
| 36 | m_event->setDropAction(static_cast<Qt::DropAction>(action)); |
| 37 | // qDebug() << "-----> Accepting event: " << this << m_data.urls() << m_data.text() << m_data.html() << ( m_data.hasColor() ? m_data.color().name() : " |
| 38 | // no color"); |
| 39 | m_event->accept(); |
| 40 | } |
| 41 | |
| 42 | void DeclarativeDragDropEvent::ignore() |
| 43 | { |
| 44 | m_event->ignore(); |
| 45 | } |
| 46 | |
| 47 | DeclarativeMimeData *DeclarativeDragDropEvent::mimeData() |
| 48 | { |
| 49 | if (!m_data && m_event) { |
| 50 | // TODO This should be using MimeDataWrapper eventually, although this is an API break, |
| 51 | // so will need to be done carefully. |
| 52 | m_data.reset(other: new DeclarativeMimeData(m_event->mimeData())); |
| 53 | } |
| 54 | return m_data.data(); |
| 55 | } |
| 56 | |
| 57 | #include "moc_DeclarativeDragDropEvent.cpp" |
| 58 | |