KDeclarative

DeclarativeDragDropEvent.h
1/*
2 SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com>
3 SPDX-FileContributor: Gregory Schlomoff <greg@betterinbox.com>
4
5 SPDX-License-Identifier: MIT
6*/
7
8#ifndef DECLARATIVEDRAGDROPEVENT_H
9#define DECLARATIVEDRAGDROPEVENT_H
10
11#include "DeclarativeDropArea.h"
12#include "DeclarativeMimeData.h"
13#include <QObject>
14
15class DeclarativeDragDropEvent : public QObject
16{
18 QML_NAMED_ELEMENT(DragDropEvent)
19 QML_UNCREATABLE("DragDropEvent cannot be created from QML.")
20
21 /**
22 * The mouse X position of the event relative to the DropArea that is receiving the event.
23 */
24 Q_PROPERTY(int x READ x)
25
26 /**
27 * The mouse Y position of the event relative to the DropArea that is receiving the event.
28 */
29 Q_PROPERTY(int y READ y)
30
31 /**
32 * The pressed mouse buttons.
33 * A combination of:
34 * Qt.NoButton The button state does not refer to any button (see QMouseEvent::button()).
35 * Qt.LeftButton The left button is pressed, or an event refers to the left button. (The left button may be the right button on left-handed mice.)
36 * Qt.RightButton The right button.
37 * Qt.MidButton The middle button.
38 * Qt.MiddleButton MidButton The middle button.
39 * Qt.XButton1 The first X button.
40 * Qt.XButton2 The second X button.
41 */
42 Q_PROPERTY(int buttons READ buttons)
43
44 /**
45 * Pressed keyboard modifiers, a combination of:
46 * Qt.NoModifier No modifier key is pressed.
47 * Qt.ShiftModifier A Shift key on the keyboard is pressed.
48 * Qt.ControlModifier A Ctrl key on the keyboard is pressed.
49 * Qt.AltModifier An Alt key on the keyboard is pressed.
50 * Qt.MetaModifier A Meta key on the keyboard is pressed.
51 * Qt.KeypadModifier A keypad button is pressed.
52 * Qt.GroupSwitchModifier X11 only. A Mode_switch key on the keyboard is pressed.
53 */
54 Q_PROPERTY(int modifiers READ modifiers)
55
56 /**
57 * The mime data of this operation
58 * @see DeclarativeMimeData
59 */
60 Q_PROPERTY(DeclarativeMimeData *mimeData READ mimeData)
61
62 /**
63 * The possible different kind of action that can be done in the drop, is a combination of:
64 * Qt.CopyAction 0x1 Copy the data to the target.
65 * Qt.MoveAction 0x2 Move the data from the source to the target.
66 * Qt.LinkAction 0x4 Create a link from the source to the target.
67 * Qt.ActionMask 0xff
68 * Qt.IgnoreAction 0x0 Ignore the action (do nothing with the data).
69 * Qt.TargetMoveAction 0x8002 On Windows, this value is used when the ownership of the D&D data should be taken over by the target application, i.e., the
70 * source application should not delete the data. On X11 this value is used to do a move. TargetMoveAction is not used on the Mac.
71 */
72 Q_PROPERTY(Qt::DropActions possibleActions READ possibleActions)
73
74 /**
75 * Default action
76 * @see possibleActions
77 */
78 Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction)
79
80public:
81 DeclarativeDragDropEvent(QDropEvent *e, DeclarativeDropArea *parent = nullptr);
82 DeclarativeDragDropEvent(QDragLeaveEvent *e, DeclarativeDropArea *parent = nullptr);
83
84 int x() const
85 {
86 return m_x;
87 }
88 int y() const
89 {
90 return m_y;
91 }
92 int buttons() const
93 {
94 return m_buttons;
95 }
96 int modifiers() const
97 {
98 return m_modifiers;
99 }
100 DeclarativeMimeData *mimeData();
101 Qt::DropAction proposedAction() const
102 {
103 return m_event->proposedAction();
104 }
105 Qt::DropActions possibleActions() const
106 {
107 return m_event->possibleActions();
108 }
109
110public Q_SLOTS:
111 void accept(int action);
112 void ignore();
113
114private:
115 int m_x;
116 int m_y;
117 Qt::MouseButtons m_buttons;
118 Qt::KeyboardModifiers m_modifiers;
119 QScopedPointer<DeclarativeMimeData> m_data;
120 QDropEvent *m_event;
121};
122
123#endif // DECLARATIVEDRAGDROPEVENT_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
DropAction
typedef KeyboardModifiers
typedef MouseButtons
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:58:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.