OpenCoverage

qplatformdrag.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformdrag.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qplatformdrag.h"-
41-
42#include <QtGui/private/qdnd_p.h>-
43#include <QtGui/QKeyEvent>-
44#include <QtGui/QGuiApplication>-
45#include <QtCore/QEventLoop>-
46-
47QT_BEGIN_NAMESPACE-
48-
49#ifndef QT_NO_DRAGANDDROP-
50#ifdef QDND_DEBUG-
51# include <QtCore/QDebug>-
52#endif-
53-
54QPlatformDropQtResponse::QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction)-
55 : m_accepted(accepted)-
56 , m_accepted_action(acceptedAction)-
57{-
58}
never executed: end of block
0
59-
60bool QPlatformDropQtResponse::isAccepted() const-
61{-
62 return m_accepted;
never executed: return m_accepted;
0
63}-
64-
65Qt::DropAction QPlatformDropQtResponse::acceptedAction() const-
66{-
67 return m_accepted_action;
never executed: return m_accepted_action;
0
68}-
69-
70QPlatformDragQtResponse::QPlatformDragQtResponse(bool accepted, Qt::DropAction acceptedAction, QRect answerRect)-
71 : QPlatformDropQtResponse(accepted,acceptedAction)-
72 , m_answer_rect(answerRect)-
73{-
74}
never executed: end of block
0
75-
76QRect QPlatformDragQtResponse::answerRect() const-
77{-
78 return m_answer_rect;
never executed: return m_answer_rect;
0
79}-
80-
81class QPlatformDragPrivate {-
82public:-
83 QPlatformDragPrivate() : cursor_drop_action(Qt::IgnoreAction) {}
never executed: end of block
0
84-
85 Qt::DropAction cursor_drop_action;-
86};-
87-
88/*!-
89 \class QPlatformDrag-
90 \since 5.0-
91 \internal-
92 \preliminary-
93 \ingroup qpa-
94-
95 \brief The QPlatformDrag class provides an abstraction for drag.-
96 */-
97QPlatformDrag::QPlatformDrag() : d_ptr(new QPlatformDragPrivate)-
98{-
99}
never executed: end of block
0
100-
101QPlatformDrag::~QPlatformDrag()-
102{-
103 delete d_ptr;-
104}
never executed: end of block
0
105-
106QDrag *QPlatformDrag::currentDrag() const-
107{-
108 return QDragManager::self()->object();
never executed: return QDragManager::self()->object();
0
109}-
110-
111Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,-
112 Qt::KeyboardModifiers modifiers) const-
113{-
114#ifdef QDND_DEBUG-
115 qDebug() << "QDragManager::defaultAction(Qt::DropActions possibleActions)\nkeyboard modifiers : " << modifiers;-
116#endif-
117-
118 Qt::DropAction default_action = Qt::IgnoreAction;-
119-
120 if (currentDrag()) {
currentDrag()Description
TRUEnever evaluated
FALSEnever evaluated
0
121 default_action = currentDrag()->defaultAction();-
122 }
never executed: end of block
0
123-
124-
125 if (default_action == Qt::IgnoreAction) {
default_action...::IgnoreActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 //This means that the drag was initiated by QDrag::start and we need to-
127 //preserve the old behavior-
128 default_action = Qt::CopyAction;-
129 }
never executed: end of block
0
130-
131 if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
132 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
133 else if (modifiers & Qt::ControlModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
134 default_action = Qt::CopyAction;
never executed: default_action = Qt::CopyAction;
0
135 else if (modifiers & Qt::ShiftModifier)
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
136 default_action = Qt::MoveAction;
never executed: default_action = Qt::MoveAction;
0
137 else if (modifiers & Qt::AltModifier)
modifiers & Qt::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
138 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
139-
140#ifdef QDND_DEBUG-
141 qDebug() << "possible actions : " << possibleActions;-
142#endif-
143-
144 // Check if the action determined is allowed-
145 if (!(possibleActions & default_action)) {
!(possibleActi...efault_action)Description
TRUEnever evaluated
FALSEnever evaluated
0
146 if (possibleActions & Qt::CopyAction)
possibleAction...Qt::CopyActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
147 default_action = Qt::CopyAction;
never executed: default_action = Qt::CopyAction;
0
148 else if (possibleActions & Qt::MoveAction)
possibleAction...Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
149 default_action = Qt::MoveAction;
never executed: default_action = Qt::MoveAction;
0
150 else if (possibleActions & Qt::LinkAction)
possibleAction...Qt::LinkActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
152 else-
153 default_action = Qt::IgnoreAction;
never executed: default_action = Qt::IgnoreAction;
0
154 }-
155-
156#ifdef QDND_DEBUG-
157 qDebug() << "default action : " << default_action;-
158#endif-
159-
160 return default_action;
never executed: return default_action;
0
161}-
162-
163/*!-
164 \brief Cancels the currently active drag (only for drags of-
165 the current application initiated by QPlatformDrag::drag()).-
166-
167 The default implementation does nothing.-
168-
169 \since 5.6-
170 */-
171-
172void QPlatformDrag::cancelDrag()-
173{-
174 Q_UNIMPLEMENTED();-
175}
never executed: end of block
0
176-
177/*!-
178 \brief Called to notify QDrag about changes of the current action.-
179 */-
180-
181void QPlatformDrag::updateAction(Qt::DropAction action)-
182{-
183 Q_D(QPlatformDrag);-
184 if (d->cursor_drop_action != action) {
d->cursor_drop...tion != actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
185 d->cursor_drop_action = action;-
186 emit currentDrag()->actionChanged(action);-
187 }
never executed: end of block
0
188}
never executed: end of block
0
189-
190static const char *const default_pm[] = {-
191"13 9 3 1",-
192". c None",-
193" c #000000",-
194"X c #FFFFFF",-
195"X X X X X X X",-
196" X X X X X X ",-
197"X ......... X",-
198" X.........X ",-
199"X ......... X",-
200" X.........X ",-
201"X ......... X",-
202" X X X X X X ",-
203"X X X X X X X",-
204};-
205-
206Q_GLOBAL_STATIC_WITH_ARGS(QPixmap,qt_drag_default_pixmap,(default_pm))
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
207-
208QPixmap QPlatformDrag::defaultPixmap()-
209{-
210 return *qt_drag_default_pixmap();
never executed: return *qt_drag_default_pixmap();
0
211}-
212-
213/*!-
214 \since 5.4-
215 \brief Returns bool indicating whether QPlatformDrag takes ownership-
216 and therefore responsibility of deleting the QDrag object passed in-
217 from QPlatformDrag::drag. This can be useful on platforms where QDrag-
218 object has to be kept around.-
219 */-
220bool QPlatformDrag::ownsDragObject() const-
221{-
222 return false;
never executed: return false;
0
223}-
224-
225#endif // QT_NO_DRAGANDDROP-
226-
227QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9