File indexing completed on 2024-05-19 15:09:21
0001 /* 0002 SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com> 0003 SPDX-FileContributor: Gregory Schlomoff <greg@betterinbox.com> 0004 0005 SPDX-License-Identifier: MIT 0006 */ 0007 0008 #ifndef DECLARATIVEDRAGDROPEVENT_H 0009 #define DECLARATIVEDRAGDROPEVENT_H 0010 0011 #include "DeclarativeDropArea.h" 0012 #include "DeclarativeMimeData.h" 0013 #include <QObject> 0014 0015 class DeclarativeDragDropEvent : public QObject 0016 { 0017 Q_OBJECT 0018 0019 /** 0020 * The mouse X position of the event relative to the DropArea that is receiving the event. 0021 */ 0022 Q_PROPERTY(int x READ x) 0023 0024 /** 0025 * The mouse Y position of the event relative to the DropArea that is receiving the event. 0026 */ 0027 Q_PROPERTY(int y READ y) 0028 0029 /** 0030 * The pressed mouse buttons. 0031 * A combination of: 0032 * Qt.NoButton The button state does not refer to any button (see QMouseEvent::button()). 0033 * 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.) 0034 * Qt.RightButton The right button. 0035 * Qt.MidButton The middle button. 0036 * Qt.MiddleButton MidButton The middle button. 0037 * Qt.XButton1 The first X button. 0038 * Qt.XButton2 The second X button. 0039 */ 0040 Q_PROPERTY(int buttons READ buttons) 0041 0042 /** 0043 * Pressed keyboard modifiers, a combination of: 0044 * Qt.NoModifier No modifier key is pressed. 0045 * Qt.ShiftModifier A Shift key on the keyboard is pressed. 0046 * Qt.ControlModifier A Ctrl key on the keyboard is pressed. 0047 * Qt.AltModifier An Alt key on the keyboard is pressed. 0048 * Qt.MetaModifier A Meta key on the keyboard is pressed. 0049 * Qt.KeypadModifier A keypad button is pressed. 0050 * Qt.GroupSwitchModifier X11 only. A Mode_switch key on the keyboard is pressed. 0051 */ 0052 Q_PROPERTY(int modifiers READ modifiers) 0053 0054 /** 0055 * The mime data of this operation 0056 * @see DeclarativeMimeData 0057 */ 0058 Q_PROPERTY(DeclarativeMimeData *mimeData READ mimeData) 0059 0060 /** 0061 * The possible different kind of action that can be done in the drop, is a combination of: 0062 * Qt.CopyAction 0x1 Copy the data to the target. 0063 * Qt.MoveAction 0x2 Move the data from the source to the target. 0064 * Qt.LinkAction 0x4 Create a link from the source to the target. 0065 * Qt.ActionMask 0xff 0066 * Qt.IgnoreAction 0x0 Ignore the action (do nothing with the data). 0067 * 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 0068 * source application should not delete the data. On X11 this value is used to do a move. TargetMoveAction is not used on the Mac. 0069 */ 0070 Q_PROPERTY(Qt::DropActions possibleActions READ possibleActions) 0071 0072 /** 0073 * Default action 0074 * @see possibleActions 0075 */ 0076 Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction) 0077 0078 public: 0079 DeclarativeDragDropEvent(QDropEvent *e, DeclarativeDropArea *parent = nullptr); 0080 DeclarativeDragDropEvent(QDragLeaveEvent *e, DeclarativeDropArea *parent = nullptr); 0081 0082 int x() const 0083 { 0084 return m_x; 0085 } 0086 int y() const 0087 { 0088 return m_y; 0089 } 0090 int buttons() const 0091 { 0092 return m_buttons; 0093 } 0094 int modifiers() const 0095 { 0096 return m_modifiers; 0097 } 0098 DeclarativeMimeData *mimeData(); 0099 Qt::DropAction proposedAction() const 0100 { 0101 return m_event->proposedAction(); 0102 } 0103 Qt::DropActions possibleActions() const 0104 { 0105 return m_event->possibleActions(); 0106 } 0107 0108 public Q_SLOTS: 0109 void accept(int action); 0110 void ignore(); 0111 0112 private: 0113 int m_x; 0114 int m_y; 0115 Qt::MouseButtons m_buttons; 0116 Qt::KeyboardModifiers m_modifiers; 0117 QScopedPointer<DeclarativeMimeData> m_data; 0118 QDropEvent *m_event; 0119 }; 0120 0121 #endif // DECLARATIVEDRAGDROPEVENT_H