| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKDRAG_P_P_H |
| 5 | #define QQUICKDRAG_P_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qquickdrag_p.h" |
| 19 | |
| 20 | #include <QtCore/qobject.h> |
| 21 | #include <QtCore/private/qobject_p.h> |
| 22 | #include <QtCore/qpointer.h> |
| 23 | #include <QtCore/qurl.h> |
| 24 | #include <QtCore/qvariant.h> |
| 25 | |
| 26 | #include <QtQuick/qquickitem.h> |
| 27 | #include <QtQuick/private/qquickitemchangelistener_p.h> |
| 28 | #include <QtQuick/private/qquickpixmap_p.h> |
| 29 | |
| 30 | QT_BEGIN_NAMESPACE |
| 31 | |
| 32 | class Q_AUTOTEST_EXPORT QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener |
| 33 | { |
| 34 | Q_DECLARE_PUBLIC(QQuickDragAttached) |
| 35 | QML_ANONYMOUS |
| 36 | QML_ADDED_IN_VERSION(2, 0) |
| 37 | |
| 38 | public: |
| 39 | static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) { |
| 40 | return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(o: attached)); } |
| 41 | |
| 42 | QQuickDragAttachedPrivate() |
| 43 | : attachedItem(nullptr) |
| 44 | , mimeData(nullptr) |
| 45 | , proposedAction(Qt::MoveAction) |
| 46 | , supportedActions(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction) |
| 47 | , active(false) |
| 48 | , listening(false) |
| 49 | , inEvent(false) |
| 50 | , dragRestarted(false) |
| 51 | , itemMoved(false) |
| 52 | , eventQueued(false) |
| 53 | , overrideActions(false) |
| 54 | , dragType(QQuickDrag::Internal) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; |
| 59 | void itemParentChanged(QQuickItem *, QQuickItem *parent) override; |
| 60 | void updatePosition(); |
| 61 | void restartDrag(); |
| 62 | void deliverEnterEvent(); |
| 63 | void deliverMoveEvent(); |
| 64 | void deliverLeaveEvent(); |
| 65 | void deliverEvent(QQuickWindow *window, QEvent *event); |
| 66 | void start(Qt::DropActions supportedActions); |
| 67 | Qt::DropAction startDrag(Qt::DropActions supportedActions); |
| 68 | void setTarget(QQuickItem *item); |
| 69 | QMimeData *createMimeData() const; |
| 70 | void loadPixmap(); |
| 71 | |
| 72 | QQuickDragGrabber dragGrabber; |
| 73 | |
| 74 | QPointer<QObject> source; |
| 75 | QPointer<QObject> target; |
| 76 | QPointer<QQuickWindow> window; |
| 77 | QQuickItem *attachedItem; |
| 78 | QQuickDragMimeData *mimeData; |
| 79 | Qt::DropAction proposedAction; |
| 80 | Qt::DropActions supportedActions; |
| 81 | bool active : 1; |
| 82 | bool listening : 1; |
| 83 | bool inEvent : 1; |
| 84 | bool dragRestarted : 1; |
| 85 | bool itemMoved : 1; |
| 86 | bool eventQueued : 1; |
| 87 | bool overrideActions : 1; |
| 88 | QPointF hotSpot; |
| 89 | QUrl imageSource; |
| 90 | QSize imageSourceSize; |
| 91 | QQuickPixmap pixmapLoader; |
| 92 | QStringList keys; |
| 93 | QVariantMap externalMimeData; |
| 94 | QQuickDrag::DragType dragType; |
| 95 | }; |
| 96 | |
| 97 | QT_END_NAMESPACE |
| 98 | |
| 99 | #endif |
| 100 | |