OpenCoverage

qquickdrag_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickdrag_p.h
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 QtQuick 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#ifndef QQUICKDRAG_P_H-
41#define QQUICKDRAG_P_H-
42-
43//-
44// W A R N I N G-
45// --------------
46//-
47// This file is not part of the Qt API. It exists purely as an-
48// implementation detail. This header file may change from version to-
49// version without notice, or even be removed.-
50//-
51// We mean it.-
52//-
53-
54#include <QtQuick/qquickitem.h>-
55-
56#include <private/qv8engine_p.h>-
57#include <private/qqmlguard_p.h>-
58-
59#include <QtCore/qmimedata.h>-
60#include <QtCore/qstringlist.h>-
61#include <QtCore/qurl.h>-
62-
63#if QT_CONFIG(draganddrop)-
64-
65QT_BEGIN_NAMESPACE-
66-
67class QQuickItem;-
68class QQuickDrag;-
69class QQuickDragPrivate;-
70-
71class QQuickDragGrabber-
72{-
73 class Item : public QQmlGuard<QQuickItem>-
74 {-
75 public:-
76 Item(QQuickItem *item) : QQmlGuard<QQuickItem>(item) {}
executed 218 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
218
77-
78 QIntrusiveListNode node;-
79 protected:-
80 void objectDestroyed(QQuickItem *) override { delete this; }
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
8
81 };-
82-
83 typedef QIntrusiveList<Item, &Item::node> ItemList;-
84-
85public:-
86 QQuickDragGrabber() : m_target(nullptr) {}
executed 5756 times by 90 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
5756
87 ~QQuickDragGrabber() { while (!m_items.isEmpty()) delete m_items.first(); }
executed 5720 times by 89 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickdynamicpropertyanimation
  • ...
executed 10 times by 1 test: delete m_items.first();
Executed by:
  • tst_qquickdrag
!m_items.isEmpty()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickdrag
FALSEevaluated 5720 times by 89 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickdynamicpropertyanimation
  • ...
10-5720
88-
89-
90 QObject *target() const-
91 {-
92 if (m_target)
m_targetDescription
TRUEevaluated 38 times by 2 tests
Evaluated by:
  • tst_qquickdrag
  • tst_qquickdroparea
FALSEevaluated 560 times by 3 tests
Evaluated by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
38-560
93 return m_target;
executed 38 times by 2 tests: return m_target;
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
38
94 else if (!m_items.isEmpty())
!m_items.isEmpty()Description
TRUEevaluated 532 times by 3 tests
Evaluated by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEevaluated 28 times by 2 tests
Evaluated by:
  • tst_qquickdrag
  • tst_qquickdroparea
28-532
95 return *m_items.first();
executed 532 times by 3 tests: return *m_items.first();
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
532
96 else-
97 return nullptr;
executed 28 times by 2 tests: return nullptr;
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
28
98 }-
99 void setTarget(QObject *target) { m_target = target; }
executed 50 times by 2 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
50
100 void resetTarget() { m_target = nullptr; }
executed 752 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
752
101-
102 bool isEmpty() const { return m_items.isEmpty(); }
never executed: return m_items.isEmpty();
0
103-
104 typedef ItemList::iterator iterator;-
105 iterator begin() { return m_items.begin(); }
executed 752 times by 3 tests: return m_items.begin();
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
752
106 iterator end() { return m_items.end(); }
executed 1598 times by 3 tests: return m_items.end();
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
1598
107-
108 void grab(QQuickItem *item) { m_items.insert(new Item(item)); }
executed 218 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
218
109 iterator release(iterator at) { Item *item = *at; at = at.erase(); delete item; return at; }
executed 200 times by 3 tests: return at;
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
200
110-
111private:-
112-
113 ItemList m_items;-
114 QObject *m_target;-
115};-
116-
117class QQuickDropEventEx : public QDropEvent-
118{-
119public:-
120 void setProposedAction(Qt::DropAction action) { default_action = action; drop_action = action; }
executed 432 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
432
121-
122 static void setProposedAction(QDropEvent *event, Qt::DropAction action) {-
123 static_cast<QQuickDropEventEx *>(event)->setProposedAction(action);-
124 }
executed 432 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
432
125-
126 void copyActions(const QDropEvent &from) {-
127 default_action = from.proposedAction(); drop_action = from.dropAction(); }
executed 1952 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
1952
128-
129 static void copyActions(QDropEvent *to, const QDropEvent &from) {-
130 static_cast<QQuickDropEventEx *>(to)->copyActions(from);-
131 }
executed 1952 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
1952
132};-
133-
134class QQuickDragMimeData : public QMimeData-
135{-
136 Q_OBJECT-
137public:-
138 QQuickDragMimeData()-
139 : m_source(nullptr)-
140 {-
141 }
executed 90 times by 3 tests: end of block
Executed by:
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
90
142-
143 QStringList keys() const { return m_keys; }
executed 98 times by 2 tests: return m_keys;
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
98
144 QObject *source() const { return m_source; }
executed 178 times by 2 tests: return m_source;
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
178
145-
146private:-
147 QObject *m_source;-
148 Qt::DropActions m_supportedActions;-
149 QStringList m_keys;-
150-
151 friend class QQuickDragAttached;-
152 friend class QQuickDragAttachedPrivate;-
153};-
154-
155class QQmlV4Function;-
156class QQuickDragAttached;-
157class Q_AUTOTEST_EXPORT QQuickDrag : public QObject-
158{-
159 Q_OBJECT-
160-
161 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)-
162 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)-
163 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)-
164 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)-
165 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)-
166 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)-
167 Q_PROPERTY(bool active READ active NOTIFY activeChanged)-
168 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)-
169 Q_PROPERTY(bool smoothed READ smoothed WRITE setSmoothed NOTIFY smoothedChanged)-
170 // Note, threshold was added in QtQuick 2.2 but REVISION is not supported (or needed) for grouped-
171 // properties See QTBUG-33179-
172 Q_PROPERTY(qreal threshold READ threshold WRITE setThreshold NOTIFY thresholdChanged RESET resetThreshold)-
173 //### consider drag and drop-
174-
175public:-
176 QQuickDrag(QObject *parent=nullptr);-
177 ~QQuickDrag();-
178-
179 enum DragType { None, Automatic, Internal };-
180 Q_ENUM(DragType)-
181-
182 QQuickItem *target() const;-
183 void setTarget(QQuickItem *target);-
184 void resetTarget();-
185-
186 enum Axis { XAxis=0x01, YAxis=0x02, XAndYAxis=0x03, XandYAxis=XAndYAxis };-
187 Q_ENUM(Axis)-
188 Axis axis() const;-
189 void setAxis(Axis);-
190-
191 qreal xmin() const;-
192 void setXmin(qreal);-
193 qreal xmax() const;-
194 void setXmax(qreal);-
195 qreal ymin() const;-
196 void setYmin(qreal);-
197 qreal ymax() const;-
198 void setYmax(qreal);-
199-
200 bool smoothed() const;-
201 void setSmoothed(bool smooth);-
202-
203 qreal threshold() const;-
204 void setThreshold(qreal);-
205 void resetThreshold();-
206-
207 bool active() const;-
208 void setActive(bool);-
209-
210 bool filterChildren() const;-
211 void setFilterChildren(bool);-
212-
213 static QQuickDragAttached *qmlAttachedProperties(QObject *obj);-
214-
215Q_SIGNALS:-
216 void targetChanged();-
217 void axisChanged();-
218 void minimumXChanged();-
219 void maximumXChanged();-
220 void minimumYChanged();-
221 void maximumYChanged();-
222 void activeChanged();-
223 void filterChildrenChanged();-
224 void smoothedChanged();-
225 void thresholdChanged();-
226-
227private:-
228 QQuickItem *_target;-
229 Axis _axis;-
230 qreal _xmin;-
231 qreal _xmax;-
232 qreal _ymin;-
233 qreal _ymax;-
234 bool _active : 1;-
235 bool _filterChildren: 1;-
236 bool _smoothed : 1;-
237 qreal _threshold;-
238 Q_DISABLE_COPY(QQuickDrag)-
239};-
240-
241class QQuickDragAttachedPrivate;-
242class QQuickDragAttached : public QObject-
243{-
244 Q_OBJECT-
245 Q_DECLARE_PRIVATE(QQuickDragAttached)
executed 2398 times by 4 tests: return reinterpret_cast<QQuickDragAttachedPrivate *>(qGetPtrHelper(d_ptr));
Executed by:
  • tst_examples
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquicklistview
executed 914 times by 3 tests: return reinterpret_cast<const QQuickDragAttachedPrivate *>(qGetPtrHelper(d_ptr));
Executed by:
  • tst_examples
  • tst_qquickdrag
  • tst_qquicklistview
914-2398
246-
247 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)-
248 Q_PROPERTY(QObject *source READ source WRITE setSource NOTIFY sourceChanged RESET resetSource)-
249 Q_PROPERTY(QObject *target READ target NOTIFY targetChanged)-
250 Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot NOTIFY hotSpotChanged)-
251 Q_PROPERTY(QUrl imageSource READ imageSource WRITE setImageSource NOTIFY imageSourceChanged)-
252 Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)-
253 Q_PROPERTY(QVariantMap mimeData READ mimeData WRITE setMimeData NOTIFY mimeDataChanged)-
254 Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged)-
255 Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction WRITE setProposedAction NOTIFY proposedActionChanged)-
256 Q_PROPERTY(QQuickDrag::DragType dragType READ dragType WRITE setDragType NOTIFY dragTypeChanged)-
257public:-
258 QQuickDragAttached(QObject *parent);-
259 ~QQuickDragAttached();-
260-
261 bool isActive() const;-
262 void setActive(bool active);-
263-
264 QObject *source() const;-
265 void setSource(QObject *item);-
266 void resetSource();-
267-
268 QObject *target() const;-
269-
270 QPointF hotSpot() const;-
271 void setHotSpot(const QPointF &hotSpot);-
272-
273 QUrl imageSource() const;-
274 void setImageSource(const QUrl &url);-
275-
276 QStringList keys() const;-
277 void setKeys(const QStringList &keys);-
278-
279 QVariantMap mimeData() const;-
280 void setMimeData(const QVariantMap &mimeData);-
281-
282 Qt::DropActions supportedActions() const;-
283 void setSupportedActions(Qt::DropActions actions);-
284-
285 Qt::DropAction proposedAction() const;-
286 void setProposedAction(Qt::DropAction action);-
287-
288 QQuickDrag::DragType dragType() const;-
289 void setDragType(QQuickDrag::DragType dragType);-
290-
291 Q_INVOKABLE int drop();-
292-
293 bool event(QEvent *event) override;-
294-
295public Q_SLOTS:-
296 void start(QQmlV4Function *);-
297 void startDrag(QQmlV4Function *);-
298 void cancel();-
299-
300Q_SIGNALS:-
301 void dragStarted();-
302 void dragFinished(Qt::DropAction dropAction);-
303-
304 void activeChanged();-
305 void sourceChanged();-
306 void targetChanged();-
307 void hotSpotChanged();-
308 void imageSourceChanged();-
309 void keysChanged();-
310 void mimeDataChanged();-
311 void supportedActionsChanged();-
312 void proposedActionChanged();-
313 void dragTypeChanged();-
314};-
315-
316QT_END_NAMESPACE-
317-
318QML_DECLARE_TYPE(QQuickDrag)-
319QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)-
320-
321#endif // draganddrop-
322-
323#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0