Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qplatformdrag.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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#include "qplatformdrag.h"
5
6#include <QtGui/private/qdnd_p.h>
7#include <QtGui/QKeyEvent>
8#include <QtGui/QGuiApplication>
9#include <QtCore/QEventLoop>
10
12
13#ifdef QDND_DEBUG
14# include <QtCore/QDebug>
15#endif
16
18 : m_accepted(accepted)
19 , m_accepted_action(acceptedAction)
20{
21}
22
24{
25 return m_accepted;
26}
27
29{
30 return m_accepted_action;
31}
32
34 : QPlatformDropQtResponse(accepted,acceptedAction)
35 , m_answer_rect(answerRect)
36{
37}
38
40{
41 return m_answer_rect;
42}
43
50
63
65{
66 delete d_ptr;
67}
68
70{
71 return QDragManager::self()->object();
72}
73
74Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,
75 Qt::KeyboardModifiers modifiers) const
76{
77#ifdef QDND_DEBUG
78 qDebug() << "QDragManager::defaultAction(Qt::DropActions possibleActions)\nkeyboard modifiers : " << modifiers;
79#endif
80
81 Qt::DropAction default_action = Qt::IgnoreAction;
82
83 if (currentDrag()) {
84 default_action = currentDrag()->defaultAction();
85 }
86
87
88 if (default_action == Qt::IgnoreAction) {
89 //This means that the drag was initiated by QDrag::start and we need to
90 //preserve the old behavior
91 default_action = Qt::CopyAction;
92 }
93
95 default_action = Qt::LinkAction;
97 default_action = Qt::CopyAction;
99 default_action = Qt::MoveAction;
100 else if (modifiers & Qt::AltModifier)
101 default_action = Qt::LinkAction;
102
103#ifdef QDND_DEBUG
104 qDebug() << "possible actions : " << possibleActions;
105#endif
106
107 // Check if the action determined is allowed
108 if (!(possibleActions & default_action)) {
109 if (possibleActions & Qt::CopyAction)
110 default_action = Qt::CopyAction;
111 else if (possibleActions & Qt::MoveAction)
112 default_action = Qt::MoveAction;
113 else if (possibleActions & Qt::LinkAction)
114 default_action = Qt::LinkAction;
115 else
116 default_action = Qt::IgnoreAction;
117 }
118
119#ifdef QDND_DEBUG
120 qDebug() << "default action : " << default_action;
121#endif
122
123 return default_action;
124}
125
139
145{
146 Q_D(QPlatformDrag);
147 if (d->cursor_drop_action != action) {
148 d->cursor_drop_action = action;
149 emit currentDrag()->actionChanged(action);
150 }
151}
152
153static const char *const default_pm[] = {
154"13 9 3 1",
155". c None",
156" c #000000",
157"X c #FFFFFF",
158"X X X X X X X",
159" X X X X X X ",
160"X ......... X",
161" X.........X ",
162"X ......... X",
163" X.........X ",
164"X ......... X",
165" X X X X X X ",
166"X X X X X X X",
167};
168
169Q_GLOBAL_STATIC_WITH_ARGS(QPixmap,qt_drag_default_pixmap,(default_pm))
170
171QPixmap QPlatformDrag::defaultPixmap()
172{
173 return *qt_drag_default_pixmap();
174}
175
184{
185 return false;
186}
187
static QDragManager * self()
Definition qdnd.cpp:30
\inmodule QtGui
Definition qdrag.h:22
void actionChanged(Qt::DropAction action)
This signal is emitted when the action associated with the drag changes.
Qt::DropAction defaultAction() const
Returns the default proposed drop action for this drag operation.
Definition qdrag.cpp:322
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
Qt::DropAction cursor_drop_action
QPlatformDragQtResponse(bool accepted, Qt::DropAction acceptedAction, QRect answerRect)
The QPlatformDrag class provides an abstraction for drag.
virtual void cancelDrag()
Cancels the currently active drag (only for drags of the current application initiated by QPlatformDr...
virtual bool ownsDragObject() const
Returns bool indicating whether QPlatformDrag takes ownership and therefore responsibility of deletin...
QDrag * currentDrag() const
virtual Qt::DropAction defaultAction(Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const
void updateAction(Qt::DropAction action)
Called to notify QDrag about changes of the current action.
virtual ~QPlatformDrag()
QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction)
Qt::DropAction acceptedAction() const
\inmodule QtCore\reentrant
Definition qrect.h:30
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ ShiftModifier
@ ControlModifier
@ AltModifier
DropAction
@ CopyAction
@ IgnoreAction
@ MoveAction
@ LinkAction
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS)
#define qDebug
[1]
Definition qlogging.h:164
static const char *const default_pm[]
#define emit
#define Q_UNIMPLEMENTED()