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
30QT_BEGIN_NAMESPACE
31
32class Q_AUTOTEST_EXPORT QQuickDragAttachedPrivate : public QObjectPrivate,
33 public QSafeQuickItemChangeListener<QQuickDragAttachedPrivate>
34{
35 Q_DECLARE_PUBLIC(QQuickDragAttached)
36 QML_ANONYMOUS
37 QML_ADDED_IN_VERSION(2, 0)
38
39public:
40 static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) {
41 return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(o: attached)); }
42
43 QQuickDragAttachedPrivate()
44 : attachedItem(nullptr)
45 , mimeData(nullptr)
46 , proposedAction(Qt::MoveAction)
47 , supportedActions(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction)
48 , active(false)
49 , listening(false)
50 , inEvent(false)
51 , dragRestarted(false)
52 , itemMoved(false)
53 , eventQueued(false)
54 , overrideActions(false)
55 , dragType(QQuickDrag::Internal)
56 {
57 }
58
59 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
60 void itemParentChanged(QQuickItem *, QQuickItem *parent) override;
61 void updatePosition();
62 void restartDrag();
63 void deliverEnterEvent();
64 void deliverMoveEvent();
65 void deliverLeaveEvent();
66 void deliverEvent(QQuickWindow *window, QEvent *event);
67 void start(Qt::DropActions supportedActions);
68 Qt::DropAction startDrag(Qt::DropActions supportedActions);
69 void setTarget(QQuickItem *item);
70 QMimeData *createMimeData() const;
71 void loadPixmap();
72
73 QQuickDragGrabber dragGrabber;
74
75 QPointer<QObject> source;
76 QPointer<QObject> target;
77 QPointer<QQuickWindow> window;
78 QQuickItem *attachedItem;
79 QQuickDragMimeData *mimeData;
80 Qt::DropAction proposedAction;
81 Qt::DropActions supportedActions;
82 bool active : 1;
83 bool listening : 1;
84 bool inEvent : 1;
85 bool dragRestarted : 1;
86 bool itemMoved : 1;
87 bool eventQueued : 1;
88 bool overrideActions : 1;
89 QPointF hotSpot;
90 QUrl imageSource;
91 QSize imageSourceSize;
92 QQuickPixmap pixmapLoader;
93 QStringList keys;
94 QVariantMap externalMimeData;
95 QQuickDrag::DragType dragType;
96};
97
98QT_END_NAMESPACE
99
100#endif
101

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