File indexing completed on 2025-03-09 04:05:57

0001 /*
0002     SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com>
0003     SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
0004     Original author: Gregory Schlomoff <greg@betterinbox.com>
0005 
0006     SPDX-License-Identifier: MIT
0007 */
0008 
0009 #include "DeclarativeDragDropEvent.h"
0010 #include "DeclarativeMimeData.h"
0011 
0012 DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDropEvent* e, DeclarativeDropArea* parent) :
0013     QObject(parent),
0014     m_x(e->pos().x()),
0015     m_y(e->pos().y()),
0016     m_buttons(e->mouseButtons()),
0017     m_modifiers(e->keyboardModifiers()),
0018     m_data(0),
0019     m_event(e)
0020 {
0021 }
0022 
0023 DeclarativeDragDropEvent::DeclarativeDragDropEvent(QDragLeaveEvent* e, DeclarativeDropArea* parent) :
0024     QObject(parent),
0025     m_x(0),
0026     m_y(0),
0027     m_buttons(Qt::NoButton),
0028     m_modifiers(Qt::NoModifier),
0029     m_data(0),
0030     m_event(0)
0031 {
0032     Q_UNUSED(e);
0033 }
0034 
0035 void DeclarativeDragDropEvent::accept(int action)
0036 {
0037     m_event->setDropAction( (Qt::DropAction) action );
0038 //     qDebug() << "-----> Accepting event: " << this << m_data.urls() << m_data.text() << m_data.html() << ( m_data.hasColor() ? m_data.color().name() : " no color");
0039     m_event->accept();
0040 }
0041 
0042 DeclarativeMimeData* DeclarativeDragDropEvent::mimeData()
0043 {
0044     if (!m_data && m_event) {
0045 //         TODO This should be using MimeDataWrapper eventually, although this is an API break,
0046 //         so will need to be done carefully.
0047         m_data = new DeclarativeMimeData(m_event->mimeData());
0048     }
0049     return m_data;
0050 }
0051