KDeclarative

DeclarativeDragDropEvent.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 BetterInbox <[email protected]>
3  SPDX-FileContributor: Gregory Schlomoff <[email protected]>
4  SPDX-FileCopyrightText: 2013 Sebastian K├╝gler <[email protected]>
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->pos().x()),
14  m_y(e->pos().y()),
15  m_buttons(e->mouseButtons()),
16  m_modifiers(e->keyboardModifiers()),
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() : " no color");
38  m_event->accept();
39 }
40 
41 void DeclarativeDragDropEvent::ignore()
42 {
43  m_event->ignore();
44 }
45 
46 DeclarativeMimeData* DeclarativeDragDropEvent::mimeData()
47 {
48  if (!m_data && m_event) {
49 // TODO This should be using MimeDataWrapper eventually, although this is an API break,
50 // so will need to be done carefully.
51  m_data.reset(new DeclarativeMimeData(m_event->mimeData()));
52  }
53  return m_data.data();
54 }
NoModifier
QByteArray data(const QString &mimeType) const const
NoButton
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:44:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.