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) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qplatformdrag.h"-
35-
36#include <QtGui/private/qdnd_p.h>-
37#include <QtGui/QKeyEvent>-
38#include <QtGui/QGuiApplication>-
39#include <QtCore/QEventLoop>-
40-
41QT_BEGIN_NAMESPACE-
42-
43#ifndef QT_NO_DRAGANDDROP-
44#ifdef QDND_DEBUG-
45# include <QtCore/QDebug>-
46#endif-
47-
48QPlatformDropQtResponse::QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction)-
49 : m_accepted(accepted)-
50 , m_accepted_action(acceptedAction)-
51{-
52}
never executed: end of block
0
53-
54bool QPlatformDropQtResponse::isAccepted() const-
55{-
56 return m_accepted;
never executed: return m_accepted;
0
57}-
58-
59Qt::DropAction QPlatformDropQtResponse::acceptedAction() const-
60{-
61 return m_accepted_action;
never executed: return m_accepted_action;
0
62}-
63-
64QPlatformDragQtResponse::QPlatformDragQtResponse(bool accepted, Qt::DropAction acceptedAction, QRect answerRect)-
65 : QPlatformDropQtResponse(accepted,acceptedAction)-
66 , m_answer_rect(answerRect)-
67{-
68}
never executed: end of block
0
69-
70QRect QPlatformDragQtResponse::answerRect() const-
71{-
72 return m_answer_rect;
never executed: return m_answer_rect;
0
73}-
74-
75class QPlatformDragPrivate {-
76public:-
77 QPlatformDragPrivate() : cursor_drop_action(Qt::IgnoreAction) {}
never executed: end of block
0
78-
79 Qt::DropAction cursor_drop_action;-
80};-
81-
82/*!-
83 \class QPlatformDrag-
84 \since 5.0-
85 \internal-
86 \preliminary-
87 \ingroup qpa-
88-
89 \brief The QPlatformDrag class provides an abstraction for drag.-
90 */-
91QPlatformDrag::QPlatformDrag() : d_ptr(new QPlatformDragPrivate)-
92{-
93}
never executed: end of block
0
94-
95QPlatformDrag::~QPlatformDrag()-
96{-
97 delete d_ptr;-
98}
never executed: end of block
0
99-
100QDrag *QPlatformDrag::currentDrag() const-
101{-
102 return QDragManager::self()->object();
never executed: return QDragManager::self()->object();
0
103}-
104-
105Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,-
106 Qt::KeyboardModifiers modifiers) const-
107{-
108#ifdef QDND_DEBUG-
109 qDebug() << "QDragManager::defaultAction(Qt::DropActions possibleActions)\nkeyboard modifiers : " << modifiers;-
110#endif-
111-
112 Qt::DropAction default_action = Qt::IgnoreAction;-
113-
114 if (currentDrag()) {
currentDrag()Description
TRUEnever evaluated
FALSEnever evaluated
0
115 default_action = currentDrag()->defaultAction();-
116 }
never executed: end of block
0
117-
118-
119 if (default_action == Qt::IgnoreAction) {
default_action...::IgnoreActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 //This means that the drag was initiated by QDrag::start and we need to-
121 //preserve the old behavior-
122 default_action = Qt::CopyAction;-
123 }
never executed: end of block
0
124-
125 if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
127 else if (modifiers & Qt::ControlModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
128 default_action = Qt::CopyAction;
never executed: default_action = Qt::CopyAction;
0
129 else if (modifiers & Qt::ShiftModifier)
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
130 default_action = Qt::MoveAction;
never executed: default_action = Qt::MoveAction;
0
131 else if (modifiers & Qt::AltModifier)
modifiers & Qt::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
132 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
133-
134#ifdef QDND_DEBUG-
135 qDebug() << "possible actions : " << possibleActions;-
136#endif-
137-
138 // Check if the action determined is allowed-
139 if (!(possibleActions & default_action)) {
!(possibleActi...efault_action)Description
TRUEnever evaluated
FALSEnever evaluated
0
140 if (possibleActions & Qt::CopyAction)
possibleAction...Qt::CopyActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
141 default_action = Qt::CopyAction;
never executed: default_action = Qt::CopyAction;
0
142 else if (possibleActions & Qt::MoveAction)
possibleAction...Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
143 default_action = Qt::MoveAction;
never executed: default_action = Qt::MoveAction;
0
144 else if (possibleActions & Qt::LinkAction)
possibleAction...Qt::LinkActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
145 default_action = Qt::LinkAction;
never executed: default_action = Qt::LinkAction;
0
146 else-
147 default_action = Qt::IgnoreAction;
never executed: default_action = Qt::IgnoreAction;
0
148 }-
149-
150#ifdef QDND_DEBUG-
151 qDebug() << "default action : " << default_action;-
152#endif-
153-
154 return default_action;
never executed: return default_action;
0
155}-
156-
157/*!-
158 \brief Called to notify QDrag about changes of the current action.-
159 */-
160-
161void QPlatformDrag::updateAction(Qt::DropAction action)-
162{-
163 Q_D(QPlatformDrag);-
164 if (d->cursor_drop_action != action) {
d->cursor_drop...tion != actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
165 d->cursor_drop_action = action;-
166 emit currentDrag()->actionChanged(action);-
167 }
never executed: end of block
0
168}
never executed: end of block
0
169-
170static const char *const default_pm[] = {-
171"13 9 3 1",-
172". c None",-
173" c #000000",-
174"X c #FFFFFF",-
175"X X X X X X X",-
176" X X X X X X ",-
177"X ......... X",-
178" X.........X ",-
179"X ......... X",-
180" X.........X ",-
181"X ......... X",-
182" X X X X X X ",-
183"X X X X X X X",-
184};-
185-
186Q_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
187-
188QPixmap QPlatformDrag::defaultPixmap()-
189{-
190 return *qt_drag_default_pixmap();
never executed: return *qt_drag_default_pixmap();
0
191}-
192-
193/*!-
194 \since 5.4-
195 \brief Returns bool indicating whether QPlatformDrag takes ownership-
196 and therefore responsibility of deleting the QDrag object passed in-
197 from QPlatformDrag::drag. This can be useful on platforms where QDrag-
198 object has to be kept around.-
199 */-
200bool QPlatformDrag::ownsDragObject() const-
201{-
202 return false;
never executed: return false;
0
203}-
204-
205#endif // QT_NO_DRAGANDDROP-
206-
207QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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