KDeclarative

DeclarativeDragDropEvent.cpp
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
11DeclarativeDragDropEvent::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
22DeclarativeDragDropEvent::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
34void 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
42void DeclarativeDragDropEvent::ignore()
43{
44 m_event->ignore();
45}
46
47DeclarativeMimeData *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(new DeclarativeMimeData(m_event->mimeData()));
53 }
54 return m_data.data();
55}
56
57#include "moc_DeclarativeDragDropEvent.cpp"
const QMimeData * mimeData() const const
void setDropAction(Qt::DropAction action)
void accept()
void ignore()
T * data() const const
void reset(T *other)
DropAction
NoModifier
NoButton
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.