OpenCoverage

qquickdroparea.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickdroparea.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7QQuickDropAreaDrag::QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent)-
8 : QObject(parent)-
9 , d(d)-
10{-
11}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
6
12-
13QQuickDropAreaDrag::~QQuickDropAreaDrag()-
14{-
15}-
16-
17class QQuickDropAreaPrivate : public QQuickItemPrivate-
18{-
19 inline QQuickDropArea* q_func() { return static_cast<QQuickDropArea *>(q_ptr); } inline const QQuickDropArea* q_func() const { return static_cast<const QQuickDropArea *>(q_ptr); } friend class QQuickDropArea;-
20-
21public:-
22 QQuickDropAreaPrivate();-
23 ~QQuickDropAreaPrivate();-
24-
25 bool hasMatchingKey(const QStringList &keys) const;-
26-
27 QStringList getKeys(const QMimeData *mimeData) const;-
28-
29 QStringList keys;-
30 QRegExp keyRegExp;-
31 QPointF dragPosition;-
32 QQuickDropAreaDrag *drag;-
33 QPointer<QObject> source;-
34 bool containsDrag;-
35};-
36-
37QQuickDropAreaPrivate::QQuickDropAreaPrivate()-
38 : drag(nullptr)-
39 , containsDrag(false)-
40{-
41}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
42-
43QQuickDropAreaPrivate::~QQuickDropAreaPrivate()-
44{-
45 delete drag;-
46}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
47QQuickDropArea::QQuickDropArea(QQuickItem *parent)-
48 : QQuickItem(*new QQuickDropAreaPrivate, parent)-
49{-
50 setFlags(ItemAcceptsDrops);-
51}
executed 214 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
  • tst_qquicklistview
214
52-
53QQuickDropArea::~QQuickDropArea()-
54{-
55}-
56bool QQuickDropArea::containsDrag() const-
57{-
58 const QQuickDropAreaPrivate * const d = d_func();-
59 return
executed 240 times by 2 tests: return d->containsDrag;
Executed by:
  • tst_examples
  • tst_qquickdroparea
d->containsDrag;
executed 240 times by 2 tests: return d->containsDrag;
Executed by:
  • tst_examples
  • tst_qquickdroparea
240
60}-
61QStringList QQuickDropArea::keys() const-
62{-
63 const QQuickDropAreaPrivate * const d = d_func();-
64 return
executed 46 times by 1 test: return d->keys;
Executed by:
  • tst_qquickdroparea
d->keys;
executed 46 times by 1 test: return d->keys;
Executed by:
  • tst_qquickdroparea
46
65}-
66-
67void QQuickDropArea::setKeys(const QStringList &keys)-
68{-
69 QQuickDropAreaPrivate * const d = d_func();-
70 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
71 d->keys = keys;-
72-
73 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
74 d->keyRegExp = QRegExp();-
75 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
else {
4
76 QString pattern = QLatin1Char('(') + QRegExp::escape(keys.first());-
77 for (int i = 1; i < keys.count()
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
; ++i)
8-56
78 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
79 pattern += QLatin1Char(')');-
80 d->keyRegExp = QRegExp(pattern.replace(QLatin1String("\\*"), QLatin1String(".+")));-
81 }
executed 56 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
56
82 keysChanged();-
83 }
executed 60 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
60
84}
executed 62 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickdroparea
62
85-
86QQuickDropAreaDrag *QQuickDropArea::drag()-
87{-
88 QQuickDropAreaPrivate * const d = d_func();-
89 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
90 d->drag = new QQuickDropAreaDrag(d);
executed 6 times by 1 test: d->drag = new QQuickDropAreaDrag(d);
Executed by:
  • tst_qquickdroparea
6
91 return
executed 80 times by 1 test: return d->drag;
Executed by:
  • tst_qquickdroparea
d->drag;
executed 80 times by 1 test: return d->drag;
Executed by:
  • tst_qquickdroparea
80
92}-
93-
94-
95-
96-
97-
98-
99-
100QObject *QQuickDropAreaDrag::source() const-
101{-
102 return
executed 20 times by 1 test: return d->source;
Executed by:
  • tst_qquickdroparea
d->source;
executed 20 times by 1 test: return d->source;
Executed by:
  • tst_qquickdroparea
20
103}-
104qreal QQuickDropAreaDrag::x() const-
105{-
106 return
executed 30 times by 1 test: return d->dragPosition.x();
Executed by:
  • tst_qquickdroparea
d->dragPosition.x();
executed 30 times by 1 test: return d->dragPosition.x();
Executed by:
  • tst_qquickdroparea
30
107}-
108-
109qreal QQuickDropAreaDrag::y() const-
110{-
111 return
executed 30 times by 1 test: return d->dragPosition.y();
Executed by:
  • tst_qquickdroparea
d->dragPosition.y();
executed 30 times by 1 test: return d->dragPosition.y();
Executed by:
  • tst_qquickdroparea
30
112}-
113void QQuickDropArea::dragMoveEvent(QDragMoveEvent *event)-
114{-
115 QQuickDropAreaPrivate * const d = d_func();-
116 if (!d->containsDrag
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 140 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
)
0-140
117 return;
never executed: return;
0
118-
119 d->dragPosition = event->pos();-
120 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
121 d->drag->positionChanged();
executed 10 times by 1 test: d->drag->positionChanged();
Executed by:
  • tst_qquickdroparea
10
122-
123 event->accept();-
124 QQuickDropEvent dragTargetEvent(d, event);-
125 positionChanged(&dragTargetEvent);-
126}
executed 140 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
140
127-
128bool QQuickDropAreaPrivate::hasMatchingKey(const QStringList &keys) const-
129{-
130 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
131 return
executed 64 times by 2 tests: return true;
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
true;
executed 64 times by 2 tests: return true;
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
64
132-
133 QRegExp copy = keyRegExp;-
134 for (const QString &key : keys) {-
135 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
136 return
executed 42 times by 1 test: return true;
Executed by:
  • tst_qquickdroparea
true;
executed 42 times by 1 test: return true;
Executed by:
  • tst_qquickdroparea
42
137 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
26
138 return
executed 16 times by 1 test: return false;
Executed by:
  • tst_qquickdroparea
false;
executed 16 times by 1 test: return false;
Executed by:
  • tst_qquickdroparea
16
139}-
140-
141QStringList QQuickDropAreaPrivate::getKeys(const QMimeData *mimeData) const-
142{-
143 if (const
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
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
144 return
executed 98 times by 2 tests: return dragMime->keys();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
dragMime->keys();
executed 98 times by 2 tests: return dragMime->keys();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
98
145 return
executed 50 times by 1 test: return mimeData->formats();
Executed by:
  • tst_qquickdroparea
mimeData->formats();
executed 50 times by 1 test: return mimeData->formats();
Executed by:
  • tst_qquickdroparea
50
146}-
147void QQuickDropArea::dragEnterEvent(QDragEnterEvent *event)-
148{-
149 QQuickDropAreaPrivate * const d = d_func();-
150 const QMimeData *mimeData = event->mimeData();-
151 if (!d->effectiveEnable
!d->effectiveEnableDescription
TRUEnever evaluated
FALSEevaluated 138 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
|| d->containsDrag
d->containsDragDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
|| !mimeData
!mimeDataDescription
TRUEnever evaluated
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
|| !d->hasMatchingKey(d->getKeys(mimeData))
!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
152 return;
executed 32 times by 1 test: return;
Executed by:
  • tst_qquickdroparea
32
153-
154 d->dragPosition = event->pos();-
155-
156 event->accept();-
157-
158 QQuickDropEvent dragTargetEvent(d, event);-
159 entered(&dragTargetEvent);-
160 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
161 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickdroparea
2
162-
163 d->containsDrag = true;-
164 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
165 d->source = dragMime->source();
executed 74 times by 2 tests: d->source = dragMime->source();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
74
166 else-
167 d->source = event->source();
executed 30 times by 1 test: d->source = event->source();
Executed by:
  • tst_qquickdroparea
30
168 d->dragPosition = event->pos();-
169 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
170 d->drag->positionChanged();-
171 d->drag->sourceChanged();-
172 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
8
173 containsDragChanged();-
174}
executed 104 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
104
175void QQuickDropArea::dragLeaveEvent(QDragLeaveEvent *)-
176{-
177 QQuickDropAreaPrivate * const d = d_func();-
178 if (!d->containsDrag
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
)
0-72
179 return;
never executed: return;
0
180-
181 exited();-
182-
183 d->containsDrag = false;-
184 d->source = nullptr;-
185 containsDragChanged();-
186 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
187 d->drag->sourceChanged();
executed 6 times by 1 test: d->drag->sourceChanged();
Executed by:
  • tst_qquickdroparea
6
188}
executed 72 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
72
189void QQuickDropArea::dropEvent(QDropEvent *event)-
190{-
191 QQuickDropAreaPrivate * const d = d_func();-
192 if (!d->containsDrag
!d->containsDragDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickdroparea
)
0-28
193 return;
never executed: return;
0
194-
195 QQuickDropEvent dragTargetEvent(d, event);-
196 dropped(&dragTargetEvent);-
197-
198 d->containsDrag = false;-
199 d->source = nullptr;-
200 containsDragChanged();-
201 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
202 d->drag->sourceChanged();
executed 2 times by 1 test: d->drag->sourceChanged();
Executed by:
  • tst_qquickdroparea
2
203}
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
28
204QObject *QQuickDropEvent::source() const-
205{-
206 if (const
const QQuickDr...t->mimeData())Description
TRUEevaluated 104 times by 2 tests
Evaluated by:
  • tst_qquickdroparea
  • tst_qquicklistview
FALSEnever evaluated
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
207 return
executed 104 times by 2 tests: return dragMime->source();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
dragMime->source();
executed 104 times by 2 tests: return dragMime->source();
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
104
208 else-
209 return
never executed: return event->source();
event->source();
never executed: return event->source();
0
210}-
211-
212QStringList QQuickDropEvent::keys() const-
213{-
214 return
executed 26 times by 1 test: return d->getKeys(event->mimeData());
Executed by:
  • tst_qquickdroparea
d->getKeys(event->mimeData());
executed 26 times by 1 test: return d->getKeys(event->mimeData());
Executed by:
  • tst_qquickdroparea
26
215}-
216-
217bool QQuickDropEvent::hasColor() const-
218{-
219 return
never executed: return event->mimeData()->hasColor();
event->mimeData()->hasColor();
never executed: return event->mimeData()->hasColor();
0
220}-
221-
222bool QQuickDropEvent::hasHtml() const-
223{-
224 return
never executed: return event->mimeData()->hasHtml();
event->mimeData()->hasHtml();
never executed: return event->mimeData()->hasHtml();
0
225}-
226-
227bool QQuickDropEvent::hasText() const-
228{-
229 return
never executed: return event->mimeData()->hasText();
event->mimeData()->hasText();
never executed: return event->mimeData()->hasText();
0
230}-
231-
232bool QQuickDropEvent::hasUrls() const-
233{-
234 return
never executed: return event->mimeData()->hasUrls();
event->mimeData()->hasUrls();
never executed: return event->mimeData()->hasUrls();
0
235}-
236-
237QVariant QQuickDropEvent::colorData() const-
238{-
239 return
never executed: return event->mimeData()->colorData();
event->mimeData()->colorData();
never executed: return event->mimeData()->colorData();
0
240}-
241-
242QString QQuickDropEvent::html() const-
243{-
244 return
never executed: return event->mimeData()->html();
event->mimeData()->html();
never executed: return event->mimeData()->html();
0
245}-
246-
247QString QQuickDropEvent::text() const-
248{-
249 return
never executed: return event->mimeData()->text();
event->mimeData()->text();
never executed: return event->mimeData()->text();
0
250}-
251-
252QList<QUrl> QQuickDropEvent::urls() const-
253{-
254 return
never executed: return event->mimeData()->urls();
event->mimeData()->urls();
never executed: return event->mimeData()->urls();
0
255}-
256-
257QStringList QQuickDropEvent::formats() const-
258{-
259 return
never executed: return event->mimeData()->formats();
event->mimeData()->formats();
never executed: return event->mimeData()->formats();
0
260}-
261-
262void QQuickDropEvent::getDataAsString(QQmlV4Function *args)-
263{-
264 if (args->length() != 0
args->length() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
265 QV4::ExecutionEngine *v4 = args->v4engine();-
266 QV4::Scope scope(v4);-
267 QV4::ScopedValue v(scope, (*args)[0]);-
268 QString format = v->toQString();-
269 QString rv = QString::fromUtf8(event->mimeData()->data(format));-
270 args->setReturnValue(v4->newString(rv)->asReturnedValue());-
271 }
never executed: end of block
0
272}
never executed: end of block
0
273-
274void QQuickDropEvent::getDataAsArrayBuffer(QQmlV4Function *args)-
275{-
276 if (args->length() != 0
args->length() != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEnever evaluated
) {
0-2
277 QV4::ExecutionEngine *v4 = args->v4engine();-
278 QV4::Scope scope(v4);-
279 QV4::ScopedValue v(scope, (*args)[0]);-
280 const QString format = v->toQString();-
281 args->setReturnValue(v4->newArrayBuffer(event->mimeData()->data(format))->asReturnedValue());-
282 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
283}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
284-
285void QQuickDropEvent::acceptProposedAction(QQmlV4Function *)-
286{-
287 event->acceptProposedAction();-
288}
never executed: end of block
0
289-
290void QQuickDropEvent::accept(QQmlV4Function *args)-
291{-
292 Qt::DropAction action = event->dropAction();-
293-
294 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
295 QV4::Scope scope(args->v4engine());-
296 QV4::ScopedValue v(scope, (*args)[0]);-
297 if (v->isInt32()
v->isInt32()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdroparea
FALSEnever evaluated
)
0-2
298 action = Qt::DropAction(v->integerValue());
executed 2 times by 1 test: action = Qt::DropAction(v->integerValue());
Executed by:
  • tst_qquickdroparea
2
299 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdroparea
2
300-
301-
302 event->setDropAction(action);-
303 event->accept();-
304}
executed 110 times by 2 tests: end of block
Executed by:
  • tst_qquickdroparea
  • tst_qquicklistview
110
305-
306-
307-
308-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0