Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickdrag_p_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKDRAG_P_P_H
6#define QQUICKDRAG_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qquickdrag_p.h"
20
21#include <QtCore/qobject.h>
22#include <QtCore/private/qobject_p.h>
23#include <QtCore/qpointer.h>
24#include <QtCore/qurl.h>
25#include <QtCore/qvariant.h>
26
27#include <QtQuick/qquickitem.h>
28#include <QtQuick/private/qquickitemchangelistener_p.h>
29#include <QtQuick/private/qquickpixmap_p.h>
30
32
33class Q_AUTOTEST_EXPORT QQuickDragAttachedPrivate : public QObjectPrivate,
34 public QSafeQuickItemChangeListener<QQuickDragAttachedPrivate>
35{
36 Q_DECLARE_PUBLIC(QQuickDragAttached)
37 QML_ANONYMOUS
38 QML_ADDED_IN_VERSION(2, 0)
39
40public:
41 static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) {
42 return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(attached)); }
43
44 QQuickDragAttachedPrivate()
45 : attachedItem(nullptr)
46 , mimeData(nullptr)
47 , proposedAction(Qt::MoveAction)
48 , supportedActions(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction)
49 , active(false)
50 , listening(false)
51 , inEvent(false)
52 , executingNativeDrag(false)
53 , dragRestarted(false)
54 , itemMoved(false)
55 , eventQueued(false)
56 , overrideActions(false)
57 , listeningForDestruction(false)
58 , dragType(QQuickDrag::Internal)
59 {
60 }
61
62 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
63 void itemParentChanged(QQuickItem *, QQuickItem *parent) override;
64 void itemDestroyed(QQuickItem *item) override;
65 void listenForAttachedItemDestruction(bool listen);
66 void updatePosition();
67 void restartDrag();
68 void deliverEnterEvent();
69 void deliverMoveEvent();
70 void deliverLeaveEvent();
71 void deliverEvent(QQuickWindow *window, QEvent *event);
72 void start(Qt::DropActions supportedActions);
73 Qt::DropAction startDrag(Qt::DropActions supportedActions, QPixmap pixmap = {});
74 void setTarget(QQuickItem *item);
75 QMimeData *createMimeData() const;
76 void loadPixmap();
77
78 QQuickDragGrabber dragGrabber;
79
80 QPointer<QObject> source;
81 QPointer<QObject> target;
82 QPointer<QQuickWindow> window;
83 QQuickItem *attachedItem;
84 QQuickDragMimeData *mimeData;
85 Qt::DropAction proposedAction;
86 Qt::DropActions supportedActions;
87 bool active : 1;
88 bool listening : 1;
89 bool inEvent : 1;
90 bool executingNativeDrag : 1;
91 bool dragRestarted : 1;
92 bool itemMoved : 1;
93 bool eventQueued : 1;
94 bool overrideActions : 1;
95 // Whether we are registered as a Destroyed change listener on attachedItem, which
96 // we only are for the duration of a native drag.
97 bool listeningForDestruction : 1;
98 QPointF hotSpot;
99 QUrl imageSource;
100 QSize imageSourceSize;
101 QQuickPixmap pixmapLoader;
102 QStringList keys;
103 QVariantMap externalMimeData;
104 QQuickDrag::DragType dragType;
105};
106
107QT_END_NAMESPACE
108
109#endif
iterator release(iterator at)
ItemList::iterator iterator
void grab(QQuickItem *item)
bool isEmpty() const
QObject * target() const
void setTarget(QObject *target)
void setProposedAction(Qt::DropAction action)
static void setProposedAction(QDropEvent *event, Qt::DropAction action)
static void copyActions(QDropEvent *to, const QDropEvent &from)
void copyActions(const QDropEvent &from)
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(quick_draganddrop)