util/qflickgesture.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); -
6 -
7static QMouseEvent *copyMouseEvent(QEvent *e) -
8{ -
9 switch (e->type()) { -
10 case QEvent::MouseButtonPress: -
11 case QEvent::MouseButtonRelease: -
12 case QEvent::MouseMove: { -
13 QMouseEvent *me = static_cast<QMouseEvent *>(e); -
14 return new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
never executed: return new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
0
15 } -
16 -
17 case QEvent::GraphicsSceneMousePress: -
18 case QEvent::GraphicsSceneMouseRelease: -
19 case QEvent::GraphicsSceneMouseMove: { -
20 QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(e); -
21 -
22 QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
never evaluated: me->type() == QEvent::GraphicsSceneMousePress
0
23 (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove); -
24 return new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
never executed: return new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
0
25 } -
26 -
27 default: -
28 return 0;
never executed: return 0;
0
29 } -
30}
never executed: }
0
31 -
32class PressDelayHandler : public QObject -
33{ -
34private: -
35 PressDelayHandler(QObject *parent = 0) -
36 : QObject(parent) -
37 , pressDelayTimer(0) -
38 , sendingEvent(false) -
39 , mouseButton(Qt::NoButton) -
40 , mouseTarget(0) -
41 { }
executed: }
Execution Count:1
1
42 -
43 static PressDelayHandler *inst; -
44 -
45public: -
46 enum { -
47 UngrabMouseBefore = 1, -
48 RegrabMouseAfterwards = 2 -
49 }; -
50 -
51 static PressDelayHandler *instance() -
52 { -
53 static PressDelayHandler *inst = 0; -
54 if (!inst)
evaluated: !inst
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:175
1-175
55 inst = new PressDelayHandler(QCoreApplication::instance());
executed: inst = new PressDelayHandler(QCoreApplication::instance());
Execution Count:1
1
56 return inst;
executed: return inst;
Execution Count:176
176
57 } -
58 -
59 bool shouldEventBeIgnored(QEvent *) const -
60 { -
61 return sendingEvent;
executed: return sendingEvent;
Execution Count:176
176
62 } -
63 -
64 bool isDelaying() const -
65 { -
66 return !pressDelayEvent.isNull();
never executed: return !pressDelayEvent.isNull();
0
67 } -
68 -
69 void pressed(QEvent *e, int delay) -
70 { -
71 if (!pressDelayEvent) {
never evaluated: !pressDelayEvent
0
72 pressDelayEvent.reset(copyMouseEvent(e)); -
73 pressDelayTimer = startTimer(delay); -
74 mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos()); -
75 mouseButton = pressDelayEvent->button(); -
76 while (false) QMessageLogger("util/qflickgesture.cpp", 157, __PRETTY_FUNCTION__).debug() << "QFG: consuming/delaying mouse press";
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 157, __PRETTY_FUNCTION__).debug() << "QFG: consuming/delaying mouse press";
0
77 } else {
never executed: }
0
78 while (false) QMessageLogger("util/qflickgesture.cpp", 159, __PRETTY_FUNCTION__).debug() << "QFG: NOT consuming/delaying mouse press";
never executed: QMessageLogger("util/qflickgesture.cpp", 159, __PRETTY_FUNCTION__).debug() << "QFG: NOT consuming/delaying mouse press";
never evaluated: false
0
79 }
never executed: }
0
80 e->setAccepted(true); -
81 }
never executed: }
0
82 -
83 bool released(QEvent *e, bool scrollerWasActive, bool scrollerIsActive) -
84 { -
85 -
86 bool result = scrollerWasActive || scrollerIsActive;
never evaluated: scrollerWasActive
never evaluated: scrollerIsActive
0
87 -
88 -
89 if (pressDelayTimer) {
never evaluated: pressDelayTimer
0
90 killTimer(pressDelayTimer); -
91 pressDelayTimer = 0; -
92 }
never executed: }
0
93 -
94 if (pressDelayEvent && mouseTarget && !scrollerIsActive) {
never evaluated: pressDelayEvent
never evaluated: mouseTarget
never evaluated: !scrollerIsActive
0
95 QScopedPointer<QMouseEvent> releaseEvent(copyMouseEvent(e)); -
96 -
97 while (false) QMessageLogger("util/qflickgesture.cpp", 178, __PRETTY_FUNCTION__).debug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget;
never executed: QMessageLogger("util/qflickgesture.cpp", 178, __PRETTY_FUNCTION__).debug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget;
never evaluated: false
0
98 sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore); -
99 -
100 while (false) QMessageLogger("util/qflickgesture.cpp", 181, __PRETTY_FUNCTION__).debug() << "QFG: faking mouse release (due to release) for " << mouseTarget;
never executed: QMessageLogger("util/qflickgesture.cpp", 181, __PRETTY_FUNCTION__).debug() << "QFG: faking mouse release (due to release) for " << mouseTarget;
never evaluated: false
0
101 sendMouseEvent(releaseEvent.data()); -
102 -
103 result = true; -
104 } else if (mouseTarget && scrollerIsActive) {
never executed: }
never evaluated: mouseTarget
never evaluated: scrollerIsActive
0
105 -
106 sendMouseEvent(0, UngrabMouseBefore); -
107 }
never executed: }
0
108 pressDelayEvent.reset(0); -
109 mouseTarget = 0; -
110 return result;
never executed: return result;
0
111 } -
112 -
113 void scrollerWasIntercepted() -
114 { -
115 while (false) QMessageLogger("util/qflickgesture.cpp", 196, __PRETTY_FUNCTION__).debug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 196, __PRETTY_FUNCTION__).debug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
0
116 if (pressDelayEvent) {
never evaluated: pressDelayEvent
0
117 -
118 if (pressDelayTimer) {
never evaluated: pressDelayTimer
0
119 killTimer(pressDelayTimer); -
120 pressDelayTimer = 0; -
121 }
never executed: }
0
122 pressDelayEvent.reset(0); -
123 }
never executed: }
0
124 mouseTarget = 0; -
125 }
never executed: }
0
126 -
127 void scrollerBecameActive() -
128 { -
129 if (pressDelayEvent) {
never evaluated: pressDelayEvent
0
130 -
131 while (false) QMessageLogger("util/qflickgesture.cpp", 212, __PRETTY_FUNCTION__).debug() << "QFG: deleting delayed mouse press, since scroller is active now";
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 212, __PRETTY_FUNCTION__).debug() << "QFG: deleting delayed mouse press, since scroller is active now";
0
132 if (pressDelayTimer) {
never evaluated: pressDelayTimer
0
133 killTimer(pressDelayTimer); -
134 pressDelayTimer = 0; -
135 }
never executed: }
0
136 pressDelayEvent.reset(0); -
137 mouseTarget = 0; -
138 } else if (mouseTarget) {
never evaluated: mouseTarget
never executed: }
0
139 QPoint farFarAway(-((1<<24)-1), -((1<<24)-1)); -
140 -
141 while (false) QMessageLogger("util/qflickgesture.cpp", 239, __PRETTY_FUNCTION__).debug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 239, __PRETTY_FUNCTION__).debug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
0
142 QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway, -
143 mouseButton, QApplication::mouseButtons() & ~mouseButton, -
144 QApplication::keyboardModifiers()); -
145 sendMouseEvent(&re, RegrabMouseAfterwards); -
146 -
147 }
never executed: }
0
148 } -
149 -
150protected: -
151 void timerEvent(QTimerEvent *e) -
152 { -
153 if (e->timerId() == pressDelayTimer) {
never evaluated: e->timerId() == pressDelayTimer
0
154 if (pressDelayEvent && mouseTarget) {
never evaluated: pressDelayEvent
never evaluated: mouseTarget
0
155 while (false) QMessageLogger("util/qflickgesture.cpp", 253, __PRETTY_FUNCTION__).debug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 253, __PRETTY_FUNCTION__).debug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
0
156 sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore); -
157 }
never executed: }
0
158 pressDelayEvent.reset(0); -
159 -
160 if (pressDelayTimer) {
never evaluated: pressDelayTimer
0
161 killTimer(pressDelayTimer); -
162 pressDelayTimer = 0; -
163 }
never executed: }
0
164 }
never executed: }
0
165 }
never executed: }
0
166 -
167 void sendMouseEvent(QMouseEvent *me, int flags = 0) -
168 { -
169 if (mouseTarget) {
never evaluated: mouseTarget
0
170 sendingEvent = true; -
171 -
172 -
173 QGraphicsItem *grabber = 0; -
174 if (mouseTarget->parentWidget()) {
never evaluated: mouseTarget->parentWidget()
0
175 if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
never evaluated: QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())
0
176 if (gv->scene())
never evaluated: gv->scene()
0
177 grabber = gv->scene()->mouseGrabberItem();
never executed: grabber = gv->scene()->mouseGrabberItem();
0
178 }
never executed: }
0
179 }
never executed: }
0
180 -
181 if (grabber && (flags & UngrabMouseBefore)) {
never evaluated: grabber
never evaluated: (flags & UngrabMouseBefore)
0
182 -
183 -
184 -
185 -
186 while (false) QMessageLogger("util/qflickgesture.cpp", 284, __PRETTY_FUNCTION__).debug() << "QFG: ungrabbing" << grabber;
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 284, __PRETTY_FUNCTION__).debug() << "QFG: ungrabbing" << grabber;
0
187 grabber->ungrabMouse(); -
188 }
never executed: }
0
189 -
190 -
191 if (me) {
never evaluated: me
0
192 QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), -
193 mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(), -
194 me->button(), me->buttons(), me->modifiers()); -
195 qt_sendSpontaneousEvent(mouseTarget, &copy); -
196 }
never executed: }
0
197 -
198 -
199 if (grabber && (flags & RegrabMouseAfterwards)) {
never evaluated: grabber
never evaluated: (flags & RegrabMouseAfterwards)
0
200 -
201 -
202 -
203 -
204 -
205 while (false) QMessageLogger("util/qflickgesture.cpp", 303, __PRETTY_FUNCTION__).debug() << "QFG: re-grabbing" << grabber;
never evaluated: false
never executed: QMessageLogger("util/qflickgesture.cpp", 303, __PRETTY_FUNCTION__).debug() << "QFG: re-grabbing" << grabber;
0
206 grabber->grabMouse(); -
207 }
never executed: }
0
208 -
209 sendingEvent = false; -
210 }
never executed: }
0
211 }
never executed: }
0
212 -
213 -
214private: -
215 int pressDelayTimer; -
216 QScopedPointer<QMouseEvent> pressDelayEvent; -
217 bool sendingEvent; -
218 Qt::MouseButton mouseButton; -
219 QPointer<QWidget> mouseTarget; -
220}; -
221QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent) -
222 : QGesture(*new QFlickGesturePrivate, parent) -
223{ -
224 d_func()->q_ptr = this; -
225 d_func()->receiver = receiver; -
226 d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0;
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: QScroller::hasScroller(receiver)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
227 d_func()->button = button; -
228}
executed: }
Execution Count:4
4
229 -
230QFlickGesture::~QFlickGesture() -
231{ } -
232 -
233QFlickGesturePrivate::QFlickGesturePrivate() -
234 : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false) -
235{ }
executed: }
Execution Count:4
4
236 -
237 -
238 -
239 -
240 -
241 -
242 -
243QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button) -
244{ -
245 this->button = button; -
246}
executed: }
Execution Count:2
2
247 -
248 -
249 -
250QGesture *QFlickGestureRecognizer::create(QObject *target) -
251{ -
252 -
253 QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target); -
254 if (go && button == Qt::NoButton) {
partially evaluated: go
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: button == Qt::NoButton
0-4
255 go->setAcceptTouchEvents(true); -
256 }
never executed: }
0
257 -
258 return new QFlickGesture(target, button);
executed: return new QFlickGesture(target, button);
Execution Count:4
4
259} -
260QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, -
261 QObject *watched, -
262 QEvent *event) -
263{ -
264 (void)watched;; -
265 -
266 static QElapsedTimer monotonicTimer; -
267 if (!monotonicTimer.isValid())
partially evaluated: !monotonicTimer.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:176
0-176
268 monotonicTimer.start();
never executed: monotonicTimer.start();
0
269 -
270 QFlickGesture *q = static_cast<QFlickGesture *>(state); -
271 QFlickGesturePrivate *d = q->d_func(); -
272 -
273 QScroller *scroller = d->receiverScroller; -
274 if (!scroller)
partially evaluated: !scroller
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:176
0-176
275 return Ignore;
never executed: return Ignore;
0
276 -
277 QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver); -
278 -
279 QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver); -
280 -
281 -
282 -
283 if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) {
partially evaluated: PressDelayHandler::instance()->shouldEventBeIgnored(event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:176
0-176
284 -
285 return Ignore;
never executed: return Ignore;
0
286 } -
287 -
288 const QMouseEvent *me = 0; -
289 -
290 const QGraphicsSceneMouseEvent *gsme = 0; -
291 -
292 const QTouchEvent *te = 0; -
293 QPoint globalPos; -
294 -
295 -
296 -
297 switch (event->type()) { -
298 case QEvent::MouseButtonPress: -
299 case QEvent::MouseButtonRelease: -
300 case QEvent::MouseMove: -
301 if (!receiverWidget)
never evaluated: !receiverWidget
0
302 return Ignore;
never executed: return Ignore;
0
303 if (button != Qt::NoButton) {
never evaluated: button != Qt::NoButton
0
304 me = static_cast<const QMouseEvent *>(event); -
305 globalPos = me->globalPos(); -
306 }
never executed: }
0
307 break;
never executed: break;
0
308 -
309 case QEvent::GraphicsSceneMousePress: -
310 case QEvent::GraphicsSceneMouseRelease: -
311 case QEvent::GraphicsSceneMouseMove: -
312 if (!receiverGraphicsObject)
never evaluated: !receiverGraphicsObject
0
313 return Ignore;
never executed: return Ignore;
0
314 if (button != Qt::NoButton) {
never evaluated: button != Qt::NoButton
0
315 gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); -
316 globalPos = gsme->screenPos(); -
317 }
never executed: }
0
318 break;
never executed: break;
0
319 -
320 case QEvent::TouchBegin: -
321 case QEvent::TouchEnd: -
322 case QEvent::TouchUpdate: -
323 if (button == Qt::NoButton) {
partially evaluated: button == Qt::NoButton
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
324 te = static_cast<const QTouchEvent *>(event); -
325 if (!te->touchPoints().isEmpty())
partially evaluated: !te->touchPoints().isEmpty()
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
326 globalPos = te->touchPoints().at(0).screenPos().toPoint();
executed: globalPos = te->touchPoints().at(0).screenPos().toPoint();
Execution Count:21
21
327 }
executed: }
Execution Count:21
21
328 break;
executed: break;
Execution Count:21
21
329 case QEvent::Wheel: -
330 if (d->macIgnoreWheel || (scroller->state() != QScroller::Inactive))
never evaluated: d->macIgnoreWheel
never evaluated: (scroller->state() != QScroller::Inactive)
0
331 return Ignore | ConsumeEventHint;
never executed: return Ignore | ConsumeEventHint;
0
332 break;
never executed: break;
0
333 -
334 -
335 case QEvent::MouseButtonDblClick: -
336 if (scroller->state() != QScroller::Inactive)
never evaluated: scroller->state() != QScroller::Inactive
0
337 return Ignore | ConsumeEventHint;
never executed: return Ignore | ConsumeEventHint;
0
338 break;
never executed: break;
0
339 -
340 default: -
341 break;
executed: break;
Execution Count:155
155
342 } -
343 -
344 if (!me
partially evaluated: !me
TRUEFALSE
yes
Evaluation Count:176
no
Evaluation Count:0
0-176
345 -
346 && !gsme
partially evaluated: !gsme
TRUEFALSE
yes
Evaluation Count:176
no
Evaluation Count:0
0-176
347 -
348 && !te)
evaluated: !te
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:21
21-155
349 return Ignore;
executed: return Ignore;
Execution Count:155
155
350 -
351 -
352 QPointF point; -
353 QScroller::Input inputType = (QScroller::Input) 0; -
354 -
355 switch (event->type()) { -
356 case QEvent::MouseButtonPress: -
357 if (me && me->button() == button && me->buttons() == button) {
never evaluated: me
never evaluated: me->button() == button
never evaluated: me->buttons() == button
0
358 point = me->globalPos(); -
359 inputType = QScroller::InputPress; -
360 } else if (me) {
never evaluated: me
never executed: }
0
361 scroller->stop(); -
362 return CancelGesture;
never executed: return CancelGesture;
0
363 } -
364 break;
never executed: break;
0
365 case QEvent::MouseButtonRelease: -
366 if (me && me->button() == button) {
never evaluated: me
never evaluated: me->button() == button
0
367 point = me->globalPos(); -
368 inputType = QScroller::InputRelease; -
369 }
never executed: }
0
370 break;
never executed: break;
0
371 case QEvent::MouseMove: -
372 if (me && me->buttons() == button) {
never evaluated: me
never evaluated: me->buttons() == button
0
373 point = me->globalPos(); -
374 inputType = QScroller::InputMove; -
375 }
never executed: }
0
376 break;
never executed: break;
0
377 -
378 -
379 case QEvent::GraphicsSceneMousePress: -
380 if (gsme && gsme->button() == button && gsme->buttons() == button) {
never evaluated: gsme
never evaluated: gsme->button() == button
never evaluated: gsme->buttons() == button
0
381 point = gsme->scenePos(); -
382 inputType = QScroller::InputPress; -
383 } else if (gsme) {
never evaluated: gsme
never executed: }
0
384 scroller->stop(); -
385 return CancelGesture;
never executed: return CancelGesture;
0
386 } -
387 break;
never executed: break;
0
388 case QEvent::GraphicsSceneMouseRelease: -
389 if (gsme && gsme->button() == button) {
never evaluated: gsme
never evaluated: gsme->button() == button
0
390 point = gsme->scenePos(); -
391 inputType = QScroller::InputRelease; -
392 }
never executed: }
0
393 break;
never executed: break;
0
394 case QEvent::GraphicsSceneMouseMove: -
395 if (gsme && gsme->buttons() == button) {
never evaluated: gsme
never evaluated: gsme->buttons() == button
0
396 point = gsme->scenePos(); -
397 inputType = QScroller::InputMove; -
398 }
never executed: }
0
399 break;
never executed: break;
0
400 -
401 -
402 case QEvent::TouchBegin: -
403 inputType = QScroller::InputPress; -
404 -
405 case QEvent::TouchEnd:
code before this statement executed: case QEvent::TouchEnd:
Execution Count:7
7
406 if (!inputType)
evaluated: !inputType
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
407 inputType = QScroller::InputRelease;
executed: inputType = QScroller::InputRelease;
Execution Count:7
7
408 -
409 case QEvent::TouchUpdate:
code before this statement executed: case QEvent::TouchUpdate:
Execution Count:14
14
410 if (!inputType)
evaluated: !inputType
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14
7-14
411 inputType = QScroller::InputMove;
executed: inputType = QScroller::InputMove;
Execution Count:7
7
412 -
413 if (te->device()->type() == QTouchDevice::TouchPad) {
partially evaluated: te->device()->type() == QTouchDevice::TouchPad
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
414 if (te->touchPoints().count() != 2)
never evaluated: te->touchPoints().count() != 2
0
415 return Ignore;
never executed: return Ignore;
0
416 -
417 point = te->touchPoints().at(0).startScenePos() + -
418 ((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) + -
419 (te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2; -
420 } else {
never executed: }
0
421 if (te->touchPoints().count() != 1)
partially evaluated: te->touchPoints().count() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
422 return Ignore;
never executed: return Ignore;
0
423 -
424 point = te->touchPoints().at(0).scenePos(); -
425 }
executed: }
Execution Count:21
21
426 break;
executed: break;
Execution Count:21
21
427 -
428 default: -
429 break;
never executed: break;
0
430 } -
431 -
432 -
433 if (inputType == QScroller::InputPress) {
evaluated: inputType == QScroller::InputPress
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:14
7-14
434 for (QForeachContainer<__typeof__(QScroller::activeScrollers())> _container_(QScroller::activeScrollers()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScroller *as = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
435 if (as != scroller) {
never evaluated: as != scroller
0
436 QRegion scrollerRegion; -
437 -
438 if (QWidget *w = qobject_cast<QWidget *>(as->target())) {
never evaluated: QWidget *w = qobject_cast<QWidget *>(as->target())
0
439 scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size()); -
440 -
441 } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) {
never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())
never executed: }
0
442 if (go->scene() && !go->scene()->views().isEmpty()) {
never evaluated: go->scene()
never evaluated: !go->scene()->views().isEmpty()
0
443 for (QForeachContainer<__typeof__(go->scene()->views())> _container_(go->scene()->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *gv = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
444 scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect())) 0
445 .translated(gv->mapToGlobal(QPoint(0, 0)));
never executed: scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect())) .translated(gv->mapToGlobal(QPoint(0, 0)));
0
446 }
never executed: }
0
447 -
448 }
never executed: }
0
449 -
450 if (scrollerRegion.contains(globalPos))
never evaluated: scrollerRegion.contains(globalPos)
0
451 return Ignore;
never executed: return Ignore;
0
452 }
never executed: }
0
453 }
never executed: }
0
454 }
executed: }
Execution Count:7
7
455 -
456 bool scrollerWasDragging = (scroller->state() == QScroller::Dragging); -
457 bool scrollerWasScrolling = (scroller->state() == QScroller::Scrolling); -
458 -
459 if (inputType) {
partially evaluated: inputType
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
460 if (QWidget *w = qobject_cast<QWidget *>(d->receiver))
partially evaluated: QWidget *w = qobject_cast<QWidget *>(d->receiver)
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
461 point = w->mapFromGlobal(point.toPoint());
executed: point = w->mapFromGlobal(point.toPoint());
Execution Count:21
21
462 -
463 else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver))
never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver)
0
464 point = go->mapFromScene(point);
never executed: point = go->mapFromScene(point);
0
465 -
466 -
467 -
468 scroller->handleInput(inputType, point, monotonicTimer.elapsed()); -
469 }
executed: }
Execution Count:21
21
470 -
471 -
472 Result result(0); -
473 bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
evaluated: scroller->state() == QScroller::Dragging
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:16
5-16
474 scroller->state() == QScroller::Scrolling);
evaluated: scroller->state() == QScroller::Scrolling
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:11
5-11
475 -
476 -
477 -
478 if ((me
partially evaluated: me
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
479 -
480 || gsme
partially evaluated: gsme
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
481 -
482 ) && scrollerIsActive)
never evaluated: scrollerIsActive
0
483 result |= ConsumeEventHint;
never executed: result |= ConsumeEventHint;
0
484 -
485 -
486 -
487 -
488 -
489 -
490 if (me
partially evaluated: me
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
491 -
492 || gsme
partially evaluated: gsme
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
493 -
494 ) { -
495 if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
never evaluated: !scrollerWasDragging
never evaluated: !scrollerWasScrolling
never evaluated: scrollerIsActive
0
496 PressDelayHandler::instance()->scrollerBecameActive();
never executed: PressDelayHandler::instance()->scrollerBecameActive();
0
497 else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
never evaluated: scrollerWasScrolling
never evaluated: scroller->state() == QScroller::Dragging
never evaluated: scroller->state() == QScroller::Inactive
0
498 PressDelayHandler::instance()->scrollerWasIntercepted();
never executed: PressDelayHandler::instance()->scrollerWasIntercepted();
0
499 } -
500 -
501 if (!inputType) {
partially evaluated: !inputType
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
502 result |= Ignore; -
503 } else {
never executed: }
0
504 switch (event->type()) { -
505 case QEvent::MouseButtonPress: -
506 -
507 case QEvent::GraphicsSceneMousePress: -
508 -
509 if (scroller->state() == QScroller::Pressed) {
never evaluated: scroller->state() == QScroller::Pressed
0
510 int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal()); -
511 if (pressDelay > 0) {
never evaluated: pressDelay > 0
0
512 result |= ConsumeEventHint; -
513 -
514 PressDelayHandler::instance()->pressed(event, pressDelay); -
515 event->accept(); -
516 }
never executed: }
0
517 }
never executed: }
0
518 -
519 case QEvent::TouchBegin:
code before this statement never executed: case QEvent::TouchBegin:
0
520 q->setHotSpot(globalPos); -
521 result |= scrollerIsActive ? TriggerGesture : MayBeGesture;
partially evaluated: scrollerIsActive
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
522 break;
executed: break;
Execution Count:7
7
523 -
524 case QEvent::MouseMove: -
525 -
526 case QEvent::GraphicsSceneMouseMove: -
527 -
528 if (PressDelayHandler::instance()->isDelaying())
never evaluated: PressDelayHandler::instance()->isDelaying()
0
529 result |= ConsumeEventHint;
never executed: result |= ConsumeEventHint;
0
530 -
531 case QEvent::TouchUpdate:
code before this statement never executed: case QEvent::TouchUpdate:
0
532 result |= scrollerIsActive ? TriggerGesture : Ignore;
evaluated: scrollerIsActive
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
533 break;
executed: break;
Execution Count:7
7
534 -
535 -
536 case QEvent::GraphicsSceneMouseRelease: -
537 -
538 case QEvent::MouseButtonRelease: -
539 if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive))
never evaluated: PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive)
0
540 result |= ConsumeEventHint;
never executed: result |= ConsumeEventHint;
0
541 -
542 case QEvent::TouchEnd:
code before this statement never executed: case QEvent::TouchEnd:
0
543 result |= scrollerIsActive ? FinishGesture : CancelGesture;
evaluated: scrollerIsActive
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
544 break;
executed: break;
Execution Count:7
7
545 -
546 default: -
547 result |= Ignore; -
548 break;
never executed: break;
0
549 } -
550 }
executed: }
Execution Count:21
21
551 return result;
executed: return result;
Execution Count:21
21
552} -
553 -
554 -
555 -
556 -
557void QFlickGestureRecognizer::reset(QGesture *state) -
558{ -
559 QGestureRecognizer::reset(state); -
560}
executed: }
Execution Count:12
12
561 -
562 -
563 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial