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/qquickpixmapcache_p.h>
29
30QT_BEGIN_NAMESPACE
31
32class 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
38public:
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
71 QQuickDragGrabber dragGrabber;
72
73 QPointer<QObject> source;
74 QPointer<QObject> target;
75 QPointer<QQuickWindow> window;
76 QQuickItem *attachedItem;
77 QQuickDragMimeData *mimeData;
78 Qt::DropAction proposedAction;
79 Qt::DropActions supportedActions;
80 bool active : 1;
81 bool listening : 1;
82 bool inEvent : 1;
83 bool dragRestarted : 1;
84 bool itemMoved : 1;
85 bool eventQueued : 1;
86 bool overrideActions : 1;
87 QPointF hotSpot;
88 QUrl imageSource;
89 QQuickPixmap pixmapLoader;
90 QStringList keys;
91 QVariantMap externalMimeData;
92 QQuickDrag::DragType dragType;
93};
94
95QT_END_NAMESPACE
96
97#endif
98

source code of qtdeclarative/src/quick/items/qquickdrag_p_p.h