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{
17 Q_OBJECT
18
19 /**
20 * The mouse X position of the event relative to the DropArea that is receiving the event.
21 */
22 Q_PROPERTY(int x READ x)
23
24 /**
25 * The mouse Y position of the event relative to the DropArea that is receiving the event.
26 */
27 Q_PROPERTY(int y READ y)
28
29 /**
30 * The pressed mouse buttons.
31 * A combination of:
32 * Qt.NoButton The button state does not refer to any button (see QMouseEvent::button()).
33 * 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.)
34 * Qt.RightButton The right button.
35 * Qt.MidButton The middle button.
36 * Qt.MiddleButton MidButton The middle button.
37 * Qt.XButton1 The first X button.
38 * Qt.XButton2 The second X button.
39 */
40 Q_PROPERTY(int buttons READ buttons)
41
42 /**
43 * Pressed keyboard modifiers, a combination of:
44 * Qt.NoModifier No modifier key is pressed.
45 * Qt.ShiftModifier A Shift key on the keyboard is pressed.
46 * Qt.ControlModifier A Ctrl key on the keyboard is pressed.
47 * Qt.AltModifier An Alt key on the keyboard is pressed.
48 * Qt.MetaModifier A Meta key on the keyboard is pressed.
49 * Qt.KeypadModifier A keypad button is pressed.
50 * Qt.GroupSwitchModifier X11 only. A Mode_switch key on the keyboard is pressed.
51 */
52 Q_PROPERTY(int modifiers READ modifiers)
53
54 /**
55 * The mime data of this operation
56 * @see DeclarativeMimeData
57 */
58 Q_PROPERTY(DeclarativeMimeData *mimeData READ mimeData)
59
60 /**
61 * The possible different kind of action that can be done in the drop, is a combination of:
62 * Qt.CopyAction 0x1 Copy the data to the target.
63 * Qt.MoveAction 0x2 Move the data from the source to the target.
64 * Qt.LinkAction 0x4 Create a link from the source to the target.
65 * Qt.ActionMask 0xff
66 * Qt.IgnoreAction 0x0 Ignore the action (do nothing with the data).
67 * 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
68 * source application should not delete the data. On X11 this value is used to do a move. TargetMoveAction is not used on the Mac.
69 */
70 Q_PROPERTY(Qt::DropActions possibleActions READ possibleActions)
71
72 /**
73 * Default action
74 * @see possibleActions
75 */
76 Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction)
77
78public:
79 DeclarativeDragDropEvent(QDropEvent *e, DeclarativeDropArea *parent = nullptr);
80 DeclarativeDragDropEvent(QDragLeaveEvent *e, DeclarativeDropArea *parent = nullptr);
81
82 int x() const
83 {
84 return m_x;
85 }
86 int y() const
87 {
88 return m_y;
89 }
90 int buttons() const
91 {
92 return m_buttons;
93 }
94 int modifiers() const
95 {
96 return m_modifiers;
97 }
98 DeclarativeMimeData *mimeData();
99 Qt::DropAction proposedAction() const
100 {
101 return m_event->proposedAction();
102 }
103 Qt::DropActions possibleActions() const
104 {
105 return m_event->possibleActions();
106 }
107
108public Q_SLOTS:
109 void accept(int action);
110 void ignore();
111
112private:
113 int m_x;
114 int m_y;
115 Qt::MouseButtons m_buttons;
116 Qt::KeyboardModifiers m_modifiers;
117 QScopedPointer<DeclarativeMimeData> m_data;
118 QDropEvent *m_event;
119};
120
121#endif // DECLARATIVEDRAGDROPEVENT_H
122

source code of kdeclarative/src/qmlcontrols/draganddrop/DeclarativeDragDropEvent.h