OpenCoverage

qquickdroparea.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickdroparea.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 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#include "qquickdroparea_p.h"-
41#include "qquickdrag_p.h"-
42#include "qquickitem_p.h"-
43-
44#include <private/qv4arraybuffer_p.h>-
45-
46#if QT_CONFIG(draganddrop)-
47-
48QT_BEGIN_NAMESPACE-
49-
50QQuickDropAreaDrag::QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent)-
51 : QObject(parent)-
52 , d(d)-
53{-
54}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
6
55-
56QQuickDropAreaDrag::~QQuickDropAreaDrag()-
57{-
58}-
59-
60class QQuickDropAreaPrivate : public QQuickItemPrivate-
61{-
62 Q_DECLARE_PUBLIC(QQuickDropArea)-
63-
64public:-
65 QQuickDropAreaPrivate();-
66 ~QQuickDropAreaPrivate();-
67-
68 bool hasMatchingKey(const QStringList &keys) const;-
69-
70 QStringList getKeys(const QMimeData *mimeData) const;-
71-
72 QStringList keys;-
73 QRegExp keyRegExp;-
74 QPointF dragPosition;-
75 QQuickDropAreaDrag *drag;-
76 QPointer<QObject> source;-
77 bool containsDrag;-
78};-
79-
80QQuickDropAreaPrivate::QQuickDropAreaPrivate()-
81 : drag(nullptr)-
82 , containsDrag(false)-
83{-
84}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
85-
86QQuickDropAreaPrivate::~QQuickDropAreaPrivate()-
87{-
88 delete drag;-
89}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
90-
91/*!-
92 \qmltype DropArea-
93 \instantiates QQuickDropArea-
94 \inqmlmodule QtQuick-
95 \ingroup qtquick-input-
96 \brief For specifying drag and drop handling in an area.-
97-
98 A DropArea is an invisible item which receives events when other items are-
99 dragged over it.-
100-
101 The \l Drag attached property can be used to notify the DropArea when an Item is-
102 dragged over it.-
103-
104 The \l keys property can be used to filter drag events which don't include-
105 a matching key.-
106-
107 The \l drag.source property is communicated to the source of a drag event as-
108 the recipient of a drop on the drag target.-
109-
110 \sa {Qt Quick Examples - Drag and Drop}, {Qt Quick Examples - externaldraganddrop}-
111*/-
112-
113QQuickDropArea::QQuickDropArea(QQuickItem *parent)-
114 : QQuickItem(*new QQuickDropAreaPrivate, parent)-
115{-
116 setFlags(ItemAcceptsDrops);-
117}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
118-
119QQuickDropArea::~QQuickDropArea()-
120{-
121}-
122-
123/*!-
124 \qmlproperty bool QtQuick::DropArea::containsDrag-
125-
126 This property identifies whether the DropArea currently contains any-
127 dragged items.-
128*/-
129-
130bool QQuickDropArea::containsDrag() const-
131{-
132 Q_D(const QQuickDropArea);-
133 return d->containsDrag;
executed 240 times by 2 tests: return d->containsDrag;
Executed by:
  • tst_examples
  • tst_qquickdroparea
240
134}-
135-
136/*!-
137 \qmlproperty stringlist QtQuick::DropArea::keys-
138-
139 This property holds a list of drag keys a DropArea will accept.-
140-
141 If no keys are listed the DropArea will accept events from any drag source,-
142 otherwise the drag source must have at least one compatible key.-
143-
144 \sa QtQuick::Drag::keys-
145*/-
146-
147QStringList QQuickDropArea::keys() const-
148{-
149 Q_D(const QQuickDropArea);-
150 return d->keys;
executed 46 times by 1 test: return d->keys;
Executed by:
  • tst_qquickdroparea
46
151}-
152-
153void QQuickDropArea::setKeys(const QStringList &keys)-
154{-
155 Q_D(QQuickDropArea);-
156 if (d->keys != keys) {
d->keys != keysDescription
TRUEevaluated 60 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickdroparea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
2-60
157 d->keys = keys;-
158-
159 if (keys.isEmpty()) {
keys.isEmpty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickdroparea
4-56
160 d->keyRegExp = QRegExp();-
161 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
4
162 QString pattern = QLatin1Char('(') + QRegExp::escape(keys.first());-
163 for (int i = 1; i < keys.count(); ++i)
i < keys.count()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickdroparea
8-56
164 pattern += QLatin1Char('|') + QRegExp::escape(keys.at(i));
executed 8 times by 1 test: pattern += QLatin1Char('|') + QRegExp::escape(keys.at(i));
Executed by:
  • tst_qquickdroparea
8
165 pattern += QLatin1Char(')');-
166 d->keyRegExp = QRegExp(pattern.replace(QLatin1String("\\*"), QLatin1String(".+")));-
167 }
executed 56 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
56
168 emit keysChanged();-
169 }
executed 60 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
60
170}
executed 62 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
62
171-
172QQuickDropAreaDrag *QQuickDropArea::drag()-
173{-
174 Q_D(QQuickDropArea);-
175 if (!d->drag)
!d->dragDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquickdroparea
6-74
176 d->drag = new QQuickDropAreaDrag(d);
executed 6 times by 1 test: d->drag = new QQuickDropAreaDrag(d);
Executed by:
  • tst_qquickdroparea
6
177 return d->drag;
executed 80 times by 1 test: return d->drag;
Executed by:
  • tst_qquickdroparea
80
178}-
179-
180/*!-
181 \qmlproperty Object QtQuick::DropArea::drag.source-
182-
183 This property holds the source of a drag.-
184*/-
185-
186QObject *QQuickDropAreaDrag::source() const-
187{-
188 return d->source;
executed 20 times by 1 test: return d->source;
Executed by:
  • tst_qquickdroparea
20
189}-
190-
191/*!-
192 \qmlpropertygroup QtQuick::DropArea::drag-
193 \qmlproperty qreal QtQuick::DropArea::drag.x-
194 \qmlproperty qreal QtQuick::DropArea::drag.y-
195-
196 These properties hold the coordinates of the last drag event.-
197*/-
198-
199qreal QQuickDropAreaDrag::x() const-
200{-
201 return d->dragPosition.x();
executed 30 times by 1 test: return d->dragPosition.x();
Executed by:
  • tst_qquickdroparea
30
202}-
203-
204qreal QQuickDropAreaDrag::y() const-
205{-
206 return d->dragPosition.y();
executed 30 times by 1 test: return d->dragPosition.y();
Executed by:
  • tst_qquickdroparea
30
207}-
208-
209/*!-
210 \qmlsignal QtQuick::DropArea::positionChanged(DragEvent drag)-
211-
212 This signal is emitted when the position of a drag has changed.-
213-
214 The corresponding handler is \c onPositionChanged.-
215*/-
216-
217void QQuickDropArea::dragMoveEvent(QDragMoveEvent *event)-
218{-
219 Q_D(QQuickDropArea);-
220 if (!d->containsDrag)
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 140 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
0-140
221 return;
never executed: return;
0
222-
223 d->dragPosition = event->pos();-
224 if (d->drag)
d->dragDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
10-130
225 emit d->drag->positionChanged();
executed 10 times by 1 test: d->drag->positionChanged();
Executed by:
  • tst_qquickdroparea
10
226-
227 event->accept();-
228 QQuickDropEvent dragTargetEvent(d, event);-
229 emit positionChanged(&dragTargetEvent);-
230}
executed 140 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
140
231-
232bool QQuickDropAreaPrivate::hasMatchingKey(const QStringList &keys) const-
233{-
234 if (keyRegExp.isEmpty())
keyRegExp.isEmpty()Description
TRUEevaluated 64 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquickdroparea
58-64
235 return true;
executed 64 times by 2 tests: return true;
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
64
236-
237 QRegExp copy = keyRegExp;-
238 for (const QString &key : keys) {-
239 if (copy.exactMatch(key))
copy.exactMatch(key)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickdroparea
26-42
240 return true;
executed 42 times by 1 test: return true;
Executed by:
  • tst_qquickdroparea
42
241 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
26
242 return false;
executed 16 times by 1 test: return false;
Executed by:
  • tst_qquickdroparea
16
243}-
244-
245QStringList QQuickDropAreaPrivate::getKeys(const QMimeData *mimeData) const-
246{-
247 if (const QQuickDragMimeData *dragMime = qobject_cast<const QQuickDragMimeData *>(mimeData))
const QQuickDr...a *>(mimeData)Description
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickdroparea
50-98
248 return dragMime->keys();
executed 98 times by 2 tests: return dragMime->keys();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
98
249 return mimeData->formats();
executed 50 times by 1 test: return mimeData->formats();
Executed by:
  • tst_qquickdroparea
50
250}-
251-
252/*!-
253 \qmlsignal QtQuick::DropArea::entered(DragEvent drag)-
254-
255 This signal is emitted when a \a drag enters the bounds of a DropArea.-
256-
257 The corresponding handler is \c onEntered.-
258*/-
259-
260void QQuickDropArea::dragEnterEvent(QDragEnterEvent *event)-
261{-
262 Q_D(QQuickDropArea);-
263 const QMimeData *mimeData = event->mimeData();-
264 if (!d->effectiveEnable || d->containsDrag || !mimeData || !d->hasMatchingKey(d->getKeys(mimeData)))
!d->effectiveEnableDescription
TRUEnever evaluated
FALSEevaluated 138 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
d->containsDragDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
!mimeDataDescription
TRUEnever evaluated
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
!d->hasMatchin...eys(mimeData))Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 106 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
0-138
265 return;
executed 32 times by 1 test: return;
Executed by:
  • tst_qquickdroparea
32
266-
267 d->dragPosition = event->pos();-
268-
269 event->accept();-
270-
271 QQuickDropEvent dragTargetEvent(d, event);-
272 emit entered(&dragTargetEvent);-
273 if (!event->isAccepted())
!event->isAccepted()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 104 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
2-104
274 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickdroparea
2
275-
276 d->containsDrag = true;-
277 if (QQuickDragMimeData *dragMime = qobject_cast<QQuickDragMimeData *>(const_cast<QMimeData *>(mimeData)))
QQuickDragMime... *>(mimeData))Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickdroparea
30-74
278 d->source = dragMime->source();
executed 74 times by 2 tests: d->source = dragMime->source();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
74
279 else-
280 d->source = event->source();
executed 30 times by 1 test: d->source = event->source();
Executed by:
  • tst_qquickdroparea
30
281 d->dragPosition = event->pos();-
282 if (d->drag) {
d->dragDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 96 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
8-96
283 emit d->drag->positionChanged();-
284 emit d->drag->sourceChanged();-
285 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
8
286 emit containsDragChanged();-
287}
executed 104 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
104
288-
289/*!-
290 \qmlsignal QtQuick::DropArea::exited()-
291-
292 This signal is emitted when a drag exits the bounds of a DropArea.-
293-
294 The corresponding handler is \c onExited.-
295*/-
296-
297void QQuickDropArea::dragLeaveEvent(QDragLeaveEvent *)-
298{-
299 Q_D(QQuickDropArea);-
300 if (!d->containsDrag)
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
0-72
301 return;
never executed: return;
0
302-
303 emit exited();-
304-
305 d->containsDrag = false;-
306 d->source = nullptr;-
307 emit containsDragChanged();-
308 if (d->drag)
d->dragDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 66 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
6-66
309 emit d->drag->sourceChanged();
executed 6 times by 1 test: d->drag->sourceChanged();
Executed by:
  • tst_qquickdroparea
6
310}
executed 72 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
72
311-
312/*!-
313 \qmlsignal QtQuick::DropArea::dropped(DragEvent drop)-
314-
315 This signal is emitted when a drop event occurs within the bounds of-
316 a DropArea.-
317-
318 The corresponding handler is \c onDropped.-
319*/-
320-
321void QQuickDropArea::dropEvent(QDropEvent *event)-
322{-
323 Q_D(QQuickDropArea);-
324 if (!d->containsDrag)
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickdroparea
0-28
325 return;
never executed: return;
0
326-
327 QQuickDropEvent dragTargetEvent(d, event);-
328 emit dropped(&dragTargetEvent);-
329-
330 d->containsDrag = false;-
331 d->source = nullptr;-
332 emit containsDragChanged();-
333 if (d->drag)
d->dragDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickdroparea
2-26
334 emit d->drag->sourceChanged();
executed 2 times by 1 test: d->drag->sourceChanged();
Executed by:
  • tst_qquickdroparea
2
335}
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
28
336-
337/*!-
338 \qmltype DragEvent-
339 \instantiates QQuickDropEvent-
340 \inqmlmodule QtQuick-
341 \ingroup qtquick-input-events-
342 \brief Provides information about a drag event.-
343-
344 The position of the drag event can be obtained from the \l x and \l y-
345 properties, and the \l keys property identifies the drag keys of the event-
346 \l {drag.source}{source}.-
347-
348 The existence of specific drag types can be determined using the \l hasColor,-
349 \l hasHtml, \l hasText, and \l hasUrls properties.-
350-
351 The list of all supplied formats can be determined using the \l formats property.-
352-
353 Specific drag types can be obtained using the \l colorData, \l html, \l text,-
354 and \l urls properties.-
355-
356 A string version of any available mimeType can be obtained using \l getDataAsString.-
357*/-
358-
359/*!-
360 \qmlproperty real QtQuick::DragEvent::x-
361-
362 This property holds the x coordinate of a drag event.-
363*/-
364-
365/*!-
366 \qmlproperty real QtQuick::DragEvent::y-
367-
368 This property holds the y coordinate of a drag event.-
369*/-
370-
371/*!-
372 \qmlproperty Object QtQuick::DragEvent::drag.source-
373-
374 This property holds the source of a drag event.-
375*/-
376-
377/*!-
378 \qmlproperty stringlist QtQuick::DragEvent::keys-
379-
380 This property holds a list of keys identifying the data type or source of a-
381 drag event.-
382*/-
383-
384/*!-
385 \qmlproperty enumeration QtQuick::DragEvent::action-
386-
387 This property holds the action that the \l {drag.source}{source} is to perform on an accepted drop.-
388-
389 The drop action may be one of:-
390-
391 \list-
392 \li Qt.CopyAction Copy the data to the target.-
393 \li Qt.MoveAction Move the data from the source to the target.-
394 \li Qt.LinkAction Create a link from the source to the target.-
395 \li Qt.IgnoreAction Ignore the action (do nothing with the data).-
396 \endlist-
397*/-
398-
399/*!-
400 \qmlproperty flags QtQuick::DragEvent::supportedActions-
401-
402 This property holds the set of \l {action}{actions} supported by the-
403 drag source.-
404*/-
405-
406/*!-
407 \qmlproperty flags QtQuick::DragEvent::proposedAction-
408 \since 5.2-
409-
410 This property holds the set of \l {action}{actions} proposed by the-
411 drag source.-
412*/-
413-
414/*!-
415 \qmlproperty bool QtQuick::DragEvent::accepted-
416-
417 This property holds whether the drag event was accepted by a handler.-
418-
419 The default value is true.-
420*/-
421-
422/*!-
423 \qmlmethod QtQuick::DragEvent::accept()-
424 \qmlmethod QtQuick::DragEvent::accept(enumeration action)-
425-
426 Accepts the drag event.-
427-
428 If an \a action is specified it will overwrite the value of the \l action property.-
429*/-
430-
431/*!-
432 \qmlmethod QtQuick::DragEvent::acceptProposedAction()-
433 \since 5.2-
434-
435 Accepts the drag event with the \l proposedAction.-
436*/-
437-
438/*!-
439 \qmlproperty bool QtQuick::DragEvent::hasColor-
440 \since 5.2-
441-
442 This property holds whether the drag event contains a color item.-
443*/-
444-
445/*!-
446 \qmlproperty bool QtQuick::DragEvent::hasHtml-
447 \since 5.2-
448-
449 This property holds whether the drag event contains a html item.-
450*/-
451-
452/*!-
453 \qmlproperty bool QtQuick::DragEvent::hasText-
454 \since 5.2-
455-
456 This property holds whether the drag event contains a text item.-
457*/-
458-
459/*!-
460 \qmlproperty bool QtQuick::DragEvent::hasUrls-
461 \since 5.2-
462-
463 This property holds whether the drag event contains one or more url items.-
464*/-
465-
466/*!-
467 \qmlproperty color QtQuick::DragEvent::colorData-
468 \since 5.2-
469-
470 This property holds color data, if any.-
471*/-
472-
473/*!-
474 \qmlproperty string QtQuick::DragEvent::html-
475 \since 5.2-
476-
477 This property holds html data, if any.-
478*/-
479-
480/*!-
481 \qmlproperty string QtQuick::DragEvent::text-
482 \since 5.2-
483-
484 This property holds text data, if any.-
485*/-
486-
487/*!-
488 \qmlproperty urllist QtQuick::DragEvent::urls-
489 \since 5.2-
490-
491 This property holds a list of urls, if any.-
492*/-
493-
494/*!-
495 \qmlproperty stringlist QtQuick::DragEvent::formats-
496 \since 5.2-
497-
498 This property holds a list of mime type formats contained in the drag data.-
499*/-
500-
501/*!-
502 \qmlmethod string QtQuick::DragEvent::getDataAsString(string format)-
503 \since 5.2-
504-
505 Returns the data for the given \a format converted to a string. \a format should be one contained in the \l formats property.-
506*/-
507-
508/*!-
509 \qmlmethod string QtQuick::DragEvent::getDataAsArrayBuffer(string format)-
510 \since 5.5-
511-
512 Returns the data for the given \a format into an ArrayBuffer, which can-
513 easily be translated into a QByteArray. \a format should be one contained in the \l formats property.-
514*/-
515-
516QObject *QQuickDropEvent::source() const-
517{-
518 if (const QQuickDragMimeData *dragMime = qobject_cast<const QQuickDragMimeData *>(event->mimeData()))
const QQuickDr...t->mimeData())Description
TRUEevaluated 104 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEnever evaluated
0-104
519 return dragMime->source();
executed 104 times by 2 tests: return dragMime->source();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
104
520 else-
521 return event->source();
never executed: return event->source();
0
522}-
523-
524QStringList QQuickDropEvent::keys() const-
525{-
526 return d->getKeys(event->mimeData());
executed 26 times by 1 test: return d->getKeys(event->mimeData());
Executed by:
  • tst_qquickdroparea
26
527}-
528-
529bool QQuickDropEvent::hasColor() const-
530{-
531 return event->mimeData()->hasColor();
never executed: return event->mimeData()->hasColor();
0
532}-
533-
534bool QQuickDropEvent::hasHtml() const-
535{-
536 return event->mimeData()->hasHtml();
never executed: return event->mimeData()->hasHtml();
0
537}-
538-
539bool QQuickDropEvent::hasText() const-
540{-
541 return event->mimeData()->hasText();
never executed: return event->mimeData()->hasText();
0
542}-
543-
544bool QQuickDropEvent::hasUrls() const-
545{-
546 return event->mimeData()->hasUrls();
never executed: return event->mimeData()->hasUrls();
0
547}-
548-
549QVariant QQuickDropEvent::colorData() const-
550{-
551 return event->mimeData()->colorData();
never executed: return event->mimeData()->colorData();
0
552}-
553-
554QString QQuickDropEvent::html() const-
555{-
556 return event->mimeData()->html();
never executed: return event->mimeData()->html();
0
557}-
558-
559QString QQuickDropEvent::text() const-
560{-
561 return event->mimeData()->text();
never executed: return event->mimeData()->text();
0
562}-
563-
564QList<QUrl> QQuickDropEvent::urls() const-
565{-
566 return event->mimeData()->urls();
never executed: return event->mimeData()->urls();
0
567}-
568-
569QStringList QQuickDropEvent::formats() const-
570{-
571 return event->mimeData()->formats();
never executed: return event->mimeData()->formats();
0
572}-
573-
574void QQuickDropEvent::getDataAsString(QQmlV4Function *args)-
575{-
576 if (args->length() != 0) {
args->length() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
577 QV4::ExecutionEngine *v4 = args->v4engine();-
578 QV4::Scope scope(v4);-
579 QV4::ScopedValue v(scope, (*args)[0]);-
580 QString format = v->toQString();-
581 QString rv = QString::fromUtf8(event->mimeData()->data(format));-
582 args->setReturnValue(v4->newString(rv)->asReturnedValue());-
583 }
never executed: end of block
0
584}
never executed: end of block
0
585-
586void QQuickDropEvent::getDataAsArrayBuffer(QQmlV4Function *args)-
587{-
588 if (args->length() != 0) {
args->length() != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEnever evaluated
0-2
589 QV4::ExecutionEngine *v4 = args->v4engine();-
590 QV4::Scope scope(v4);-
591 QV4::ScopedValue v(scope, (*args)[0]);-
592 const QString format = v->toQString();-
593 args->setReturnValue(v4->newArrayBuffer(event->mimeData()->data(format))->asReturnedValue());-
594 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
595}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
596-
597void QQuickDropEvent::acceptProposedAction(QQmlV4Function *)-
598{-
599 event->acceptProposedAction();-
600}
never executed: end of block
0
601-
602void QQuickDropEvent::accept(QQmlV4Function *args)-
603{-
604 Qt::DropAction action = event->dropAction();-
605-
606 if (args->length() >= 1) {
args->length() >= 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 108 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
2-108
607 QV4::Scope scope(args->v4engine());-
608 QV4::ScopedValue v(scope, (*args)[0]);-
609 if (v->isInt32())
v->isInt32()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEnever evaluated
0-2
610 action = Qt::DropAction(v->integerValue());
executed 2 times by 1 test: action = Qt::DropAction(v->integerValue());
Executed by:
  • tst_qquickdroparea
2
611 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
612-
613 // get action from arguments.-
614 event->setDropAction(action);-
615 event->accept();-
616}
executed 110 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
110
617-
618-
619QT_END_NAMESPACE-
620-
621#include "moc_qquickdroparea_p.cpp"-
622-
623#endif // draganddrop-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0