qflickgesture.cpp

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

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