util/qscroller.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); -
9QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s) -
10{ -
11 dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress; -
12 dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos; -
13 dbg << "\n Curve: type:" << s.curve.type() << "\n"; -
14 return dbg;
never executed: return dbg;
0
15} -
16 -
17 -
18 -
19 -
20 -
21 -
22 -
23inline bool operator<=(const QPointF &p, qreal f) -
24{ -
25 return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f);
never executed: return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f);
0
26} -
27 -
28 -
29inline bool operator<(const QPointF &p, qreal f) -
30{ -
31 return (qAbs(p.x()) < f) && (qAbs(p.y()) < f);
never executed: return (qAbs(p.x()) < f) && (qAbs(p.y()) < f);
0
32} -
33 -
34 -
35inline bool operator>=(const QPointF &p, qreal f) -
36{ -
37 return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f);
never executed: return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f);
0
38} -
39 -
40 -
41inline bool operator>(const QPointF &p, qreal f) -
42{ -
43 return (qAbs(p.x()) > f) || (qAbs(p.y()) > f);
never executed: return (qAbs(p.x()) > f) || (qAbs(p.y()) > f);
0
44} -
45 -
46 -
47inline QPointF qAbs(const QPointF &p) -
48{ -
49 return QPointF(qAbs(p.x()), qAbs(p.y()));
never executed: return QPointF(qAbs(p.x()), qAbs(p.y()));
0
50} -
51 -
52 -
53inline QPointF operator*(const QPointF &p1, const QPointF &p2) -
54{ -
55 return QPointF(p1.x() * p2.x(), p1.y() * p2.y());
never executed: return QPointF(p1.x() * p2.x(), p1.y() * p2.y());
0
56} -
57 -
58 -
59inline QPointF operator/(const QPointF &p1, const QPointF &p2) -
60{ -
61 return QPointF(p1.x() / p2.x(), p1.y() / p2.y());
executed: return QPointF(p1.x() / p2.x(), p1.y() / p2.y());
Execution Count:22
22
62} -
63 -
64inline QPointF clampToRect(const QPointF &p, const QRectF &rect) -
65{ -
66 qreal x = qBound(rect.left(), p.x(), rect.right()); -
67 qreal y = qBound(rect.top(), p.y(), rect.bottom()); -
68 return QPointF(x, y);
executed: return QPointF(x, y);
Execution Count:151
151
69} -
70 -
71 -
72inline int qSign(qreal r) -
73{ -
74 return (r < 0) ? -1 : ((r > 0) ? 1 : 0);
executed: return (r < 0) ? -1 : ((r > 0) ? 1 : 0);
Execution Count:15
15
75} -
76 -
77 -
78 -
79 -
80static qreal differentialForProgress(const QEasingCurve &curve, qreal pos) -
81{ -
82 const qreal dx = 0.01; -
83 qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx);
partially evaluated: (pos < qreal(0.5))
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
84 qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx);
partially evaluated: (pos >= qreal(0.5))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
85 qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx); -
86 -
87 -
88 -
89 return d;
executed: return d;
Execution Count:9
9
90} -
91 -
92 -
93 -
94 -
95static qreal progressForValue(const QEasingCurve &curve, qreal value) -
96{ -
97 if (curve.type() >= QEasingCurve::InElastic &&
partially evaluated: curve.type() >= QEasingCurve::InElastic
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
98 curve.type() < QEasingCurve::Custom) {
never evaluated: curve.type() < QEasingCurve::Custom
0
99 QMessageLogger("util/qscroller.cpp", 172, __PRETTY_FUNCTION__).warning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type()); -
100 return value;
never executed: return value;
0
101 } -
102 if (value < qreal(0) || value > qreal(1))
partially evaluated: value < qreal(0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: value > qreal(1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
103 return value;
never executed: return value;
0
104 -
105 qreal progress = value, left(0), right(1); -
106 for (int iterations = 6; iterations; --iterations) {
evaluated: iterations
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:8
8-48
107 qreal v = curve.valueForProgress(progress); -
108 if (v < value)
evaluated: v < value
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:40
8-40
109 left = progress;
executed: left = progress;
Execution Count:8
8
110 else if (v > value)
partially evaluated: v > value
TRUEFALSE
yes
Evaluation Count:40
no
Evaluation Count:0
0-40
111 right = progress;
executed: right = progress;
Execution Count:40
40
112 else -
113 break;
never executed: break;
0
114 progress = (left + right) / qreal(2); -
115 }
executed: }
Execution Count:48
48
116 return progress;
executed: return progress;
Execution Count:8
8
117} -
118 -
119 -
120 -
121class QScrollTimer : public QAbstractAnimation -
122{ -
123public: -
124 QScrollTimer(QScrollerPrivate *_d) -
125 : d(_d), ignoreUpdate(false), skip(0) -
126 { }
executed: }
Execution Count:8
8
127 -
128 int duration() const -
129 { -
130 return -1;
executed: return -1;
Execution Count:149
149
131 } -
132 -
133 void start() -
134 { -
135 -
136 -
137 ignoreUpdate = true; -
138 QAbstractAnimation::start(); -
139 ignoreUpdate = false; -
140 skip = 0; -
141 }
executed: }
Execution Count:11
11
142 -
143protected: -
144 void updateCurrentTime(int ) -
145 { -
146 if (!ignoreUpdate) {
evaluated: !ignoreUpdate
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:6
6-137
147 if (++skip >= d->frameRateSkip()) {
partially evaluated: ++skip >= d->frameRateSkip()
TRUEFALSE
yes
Evaluation Count:137
no
Evaluation Count:0
0-137
148 skip = 0; -
149 d->timerTick(); -
150 }
executed: }
Execution Count:137
137
151 }
executed: }
Execution Count:137
137
152 }
executed: }
Execution Count:143
143
153 -
154private: -
155 QScrollerPrivate *d; -
156 bool ignoreUpdate; -
157 int skip; -
158}; -
159typedef QMap<QObject *, QScroller *> ScrollerHash; -
160typedef QSet<QScroller *> ScrollerSet; -
161 -
162static ScrollerHash *qt_allScrollers() { static QGlobalStatic<ScrollerHash > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { ScrollerHash *x = new ScrollerHash; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<ScrollerHash > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:54
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:53
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-54
163static ScrollerSet *qt_activeScrollers() { static QGlobalStatic<ScrollerSet > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { ScrollerSet *x = new ScrollerSet; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<ScrollerSet > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:41
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:40
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-41
164 -
165 -
166 -
167 -
168 -
169 -
170bool QScroller::hasScroller(QObject *target) -
171{ -
172 return (qt_allScrollers()->value(target));
executed: return (qt_allScrollers()->value(target));
Execution Count:2
2
173} -
174QScroller *QScroller::scroller(QObject *target) -
175{ -
176 if (!target) {
evaluated: !target
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:22
1-22
177 QMessageLogger("util/qscroller.cpp", 309, __PRETTY_FUNCTION__).warning("QScroller::scroller() was called with a null target."); -
178 return 0;
executed: return 0;
Execution Count:1
1
179 } -
180 -
181 if (qt_allScrollers()->contains(target))
evaluated: qt_allScrollers()->contains(target)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
182 return qt_allScrollers()->value(target);
executed: return qt_allScrollers()->value(target);
Execution Count:14
14
183 -
184 QScroller *s = new QScroller(target); -
185 qt_allScrollers()->insert(target, s); -
186 return s;
executed: return s;
Execution Count:8
8
187} -
188 -
189 -
190 -
191 -
192 -
193const QScroller *QScroller::scroller(const QObject *target) -
194{ -
195 return scroller(const_cast<QObject*>(target));
executed: return scroller(const_cast<QObject*>(target));
Execution Count:1
1
196} -
197 -
198 -
199 -
200 -
201 -
202 -
203QList<QScroller *> QScroller::activeScrollers() -
204{ -
205 return qt_activeScrollers()->toList();
executed: return qt_activeScrollers()->toList();
Execution Count:7
7
206} -
207 -
208 -
209 -
210 -
211 -
212QObject *QScroller::target() const -
213{ -
214 const QScrollerPrivate * const d = d_func(); -
215 return d->target;
never executed: return d->target;
0
216} -
217QScrollerProperties QScroller::scrollerProperties() const -
218{ -
219 const QScrollerPrivate * const d = d_func(); -
220 return d->properties;
executed: return d->properties;
Execution Count:12
12
221} -
222 -
223void QScroller::setScrollerProperties(const QScrollerProperties &sp) -
224{ -
225 QScrollerPrivate * const d = d_func(); -
226 if (d->properties != sp) {
evaluated: d->properties != sp
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
227 d->properties = sp; -
228 scrollerPropertiesChanged(sp); -
229 -
230 -
231 -
232 d->recalcScrollingSegments(true); -
233 }
executed: }
Execution Count:4
4
234}
executed: }
Execution Count:5
5
235Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType) -
236{ -
237 -
238 QScroller *s = scroller(target); -
239 if (!s)
partially evaluated: !s
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
240 return Qt::GestureType(0);
never executed: return Qt::GestureType(0);
0
241 -
242 QScrollerPrivate *sp = s->d_ptr; -
243 if (sp->recognizer)
partially evaluated: sp->recognizer
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
244 ungrabGesture(target);
never executed: ungrabGesture(target);
0
245 -
246 Qt::MouseButton button; -
247 switch (scrollGestureType) { -
248 case LeftMouseButtonGesture : button = Qt::LeftButton; break;
never executed: break;
0
249 case RightMouseButtonGesture : button = Qt::RightButton; break;
never executed: break;
0
250 case MiddleMouseButtonGesture: button = Qt::MiddleButton; break;
never executed: break;
0
251 default : -
252 case TouchGesture : button = Qt::NoButton; break;
executed: break;
Execution Count:2
2
253 } -
254 -
255 sp->recognizer = new QFlickGestureRecognizer(button); -
256 sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer); -
257 -
258 if (target->isWidgetType()) {
partially evaluated: target->isWidgetType()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
259 QWidget *widget = static_cast<QWidget *>(target); -
260 widget->grabGesture(sp->recognizerType); -
261 if (scrollGestureType == TouchGesture)
partially evaluated: scrollGestureType == TouchGesture
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
262 widget->setAttribute(Qt::WA_AcceptTouchEvents);
executed: widget->setAttribute(Qt::WA_AcceptTouchEvents);
Execution Count:2
2
263 -
264 } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)
executed: }
Execution Count:2
0-2
265 if (scrollGestureType == TouchGesture)
never evaluated: scrollGestureType == TouchGesture
0
266 go->setAcceptTouchEvents(true);
never executed: go->setAcceptTouchEvents(true);
0
267 go->grabGesture(sp->recognizerType); -
268 -
269 }
never executed: }
0
270 return sp->recognizerType;
executed: return sp->recognizerType;
Execution Count:2
2
271} -
272 -
273 -
274 -
275 -
276 -
277 -
278 -
279Qt::GestureType QScroller::grabbedGesture(QObject *target) -
280{ -
281 QScroller *s = scroller(target); -
282 if (s && s->d_ptr)
never evaluated: s
never evaluated: s->d_ptr
0
283 return s->d_ptr->recognizerType;
never executed: return s->d_ptr->recognizerType;
0
284 else -
285 return Qt::GestureType(0);
never executed: return Qt::GestureType(0);
0
286} -
287 -
288 -
289 -
290 -
291 -
292 -
293 -
294void QScroller::ungrabGesture(QObject *target) -
295{ -
296 QScroller *s = scroller(target); -
297 if (!s)
never evaluated: !s
0
298 return;
never executed: return;
0
299 -
300 QScrollerPrivate *sp = s->d_ptr; -
301 if (!sp->recognizer)
never evaluated: !sp->recognizer
0
302 return;
never executed: return;
0
303 -
304 if (target->isWidgetType()) {
never evaluated: target->isWidgetType()
0
305 QWidget *widget = static_cast<QWidget *>(target); -
306 widget->ungrabGesture(sp->recognizerType); -
307 -
308 } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)
never executed: }
0
309 go->ungrabGesture(sp->recognizerType); -
310 -
311 }
never executed: }
0
312 -
313 QGestureRecognizer::unregisterRecognizer(sp->recognizerType); -
314 -
315 sp->recognizer = 0; -
316}
never executed: }
0
317 -
318 -
319 -
320 -
321 -
322 -
323QScroller::QScroller(QObject *target) -
324 : d_ptr(new QScrollerPrivate(this, target)) -
325{ -
326 qt_noop(); -
327 QScrollerPrivate * const d = d_func(); -
328 d->init(); -
329}
executed: }
Execution Count:8
8
330 -
331 -
332 -
333 -
334QScroller::~QScroller() -
335{ -
336 QScrollerPrivate * const d = d_func(); -
337 -
338 QGestureRecognizer::unregisterRecognizer(d->recognizerType); -
339 -
340 d->recognizer = 0; -
341 -
342 qt_allScrollers()->remove(d->target); -
343 qt_activeScrollers()->remove(this); -
344 -
345 delete d_ptr; -
346}
executed: }
Execution Count:8
8
347QScroller::State QScroller::state() const -
348{ -
349 const QScrollerPrivate * const d = d_func(); -
350 return d->state;
executed: return d->state;
Execution Count:171
171
351} -
352 -
353 -
354 -
355 -
356void QScroller::stop() -
357{ -
358 QScrollerPrivate * const d = d_func(); -
359 if (d->state != Inactive) {
never evaluated: d->state != Inactive
0
360 QPointF here = clampToRect(d->contentPosition, d->contentPosRange); -
361 qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal); -
362 qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical); -
363 QPointF snap = here; -
364 if (!qIsNaN(snapX))
never evaluated: !qIsNaN(snapX)
0
365 snap.setX(snapX);
never executed: snap.setX(snapX);
0
366 if (!qIsNaN(snapY))
never evaluated: !qIsNaN(snapY)
0
367 snap.setY(snapY);
never executed: snap.setY(snapY);
0
368 d->contentPosition = snap; -
369 d->overshootPosition = QPointF(0, 0); -
370 -
371 d->setState(Inactive); -
372 }
never executed: }
0
373}
never executed: }
0
374QPointF QScroller::pixelPerMeter() const -
375{ -
376 const QScrollerPrivate * const d = d_func(); -
377 QPointF ppm = d->pixelPerMeter; -
378 -
379 -
380 if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) {
partially evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
381 QTransform viewtr; -
382 -
383 if (go->scene() && !go->scene()->views().isEmpty())
never evaluated: go->scene()
never evaluated: !go->scene()->views().isEmpty()
0
384 viewtr = go->scene()->views().first()->viewportTransform();
never executed: viewtr = go->scene()->views().first()->viewportTransform();
0
385 QTransform tr = go->deviceTransform(viewtr); -
386 if (tr.isScaling()) {
never evaluated: tr.isScaling()
0
387 QPointF p0 = tr.map(QPointF(0, 0)); -
388 QPointF px = tr.map(QPointF(1, 0)); -
389 QPointF py = tr.map(QPointF(0, 1)); -
390 ppm.rx() /= QLineF(p0, px).length(); -
391 ppm.ry() /= QLineF(p0, py).length(); -
392 }
never executed: }
0
393 }
never executed: }
0
394 -
395 return ppm;
executed: return ppm;
Execution Count:31
31
396} -
397QPointF QScroller::velocity() const -
398{ -
399 const QScrollerPrivate * const d = d_func(); -
400 const QScrollerPropertiesPrivate *sp = d->properties.d.data(); -
401 -
402 switch (state()) { -
403 case Dragging: -
404 return d->releaseVelocity;
never executed: return d->releaseVelocity;
0
405 case Scrolling: { -
406 QPointF vel; -
407 qint64 now = d->monotonicTimer.elapsed(); -
408 -
409 if (!d->xSegments.isEmpty()) {
never evaluated: !d->xSegments.isEmpty()
0
410 const QScrollerPrivate::ScrollSegment &s = d->xSegments.head(); -
411 qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); -
412 qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); -
413 vel.setX(v); -
414 }
never executed: }
0
415 -
416 if (!d->ySegments.isEmpty()) {
never evaluated: !d->ySegments.isEmpty()
0
417 const QScrollerPrivate::ScrollSegment &s = d->ySegments.head(); -
418 qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); -
419 qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); -
420 vel.setY(v); -
421 }
never executed: }
0
422 return vel;
never executed: return vel;
0
423 } -
424 default: -
425 return QPointF(0, 0);
executed: return QPointF(0, 0);
Execution Count:5
5
426 } -
427}
never executed: }
0
428QPointF QScroller::finalPosition() const -
429{ -
430 const QScrollerPrivate * const d = d_func(); -
431 return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), 0
432 d->scrollingSegmentsEndPos(Qt::Vertical));
never executed: return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), d->scrollingSegmentsEndPos(Qt::Vertical));
0
433} -
434void QScroller::scrollTo(const QPointF &pos) -
435{ -
436 -
437 scrollTo(pos, 300); -
438}
never executed: }
0
439 -
440 -
441 -
442 -
443 -
444void QScroller::scrollTo(const QPointF &pos, int scrollTime) -
445{ -
446 QScrollerPrivate * const d = d_func(); -
447 -
448 if (d->state == Pressed || d->state == Dragging )
partially evaluated: d->state == Pressed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: d->state == Dragging
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
449 return;
never executed: return;
0
450 -
451 -
452 if (d->state == Inactive && !d->prepareScrolling(QPointF()))
partially evaluated: d->state == Inactive
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !d->prepareScrolling(QPointF())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
453 return;
never executed: return;
0
454 -
455 QPointF newpos = clampToRect(pos, d->contentPosRange); -
456 qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal); -
457 qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical); -
458 if (!qIsNaN(snapX))
partially evaluated: !qIsNaN(snapX)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
459 newpos.setX(snapX);
never executed: newpos.setX(snapX);
0
460 if (!qIsNaN(snapY))
partially evaluated: !qIsNaN(snapY)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
461 newpos.setY(snapY);
never executed: newpos.setY(snapY);
0
462 -
463 while (false) QMessageLogger("util/qscroller.cpp", 694, __PRETTY_FUNCTION__).debug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never executed: QMessageLogger("util/qscroller.cpp", 694, __PRETTY_FUNCTION__).debug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])";
0-1
464 -
465 if (newpos == d->contentPosition + d->overshootPosition)
partially evaluated: newpos == d->contentPosition + d->overshootPosition
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
466 return;
never executed: return;
0
467 -
468 QPointF vel = velocity(); -
469 -
470 if (scrollTime < 0)
partially evaluated: scrollTime < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
471 scrollTime = 0;
never executed: scrollTime = 0;
0
472 qreal time = qreal(scrollTime) / 1000; -
473 -
474 d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo); -
475 d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo); -
476 -
477 if (!scrollTime)
partially evaluated: !scrollTime
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
478 d->setContentPositionHelperScrolling();
never executed: d->setContentPositionHelperScrolling();
0
479 d->setState(scrollTime ? Scrolling : Inactive); -
480}
executed: }
Execution Count:1
1
481void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin) -
482{ -
483 -
484 ensureVisible(rect, xmargin, ymargin, 1000); -
485}
never executed: }
0
486 -
487 -
488 -
489 -
490 -
491void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime) -
492{ -
493 QScrollerPrivate * const d = d_func(); -
494 -
495 if (d->state == Pressed || d->state == Dragging )
never evaluated: d->state == Pressed
never evaluated: d->state == Dragging
0
496 return;
never executed: return;
0
497 -
498 if (d->state == Inactive && !d->prepareScrolling(QPointF()))
never evaluated: d->state == Inactive
never evaluated: !d->prepareScrolling(QPointF())
0
499 return;
never executed: return;
0
500 -
501 -
502 QPointF startPos = d->contentPosition + d->overshootPosition; -
503 startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), -
504 d->scrollingSegmentsEndPos(Qt::Vertical)); -
505 -
506 QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin, -
507 rect.width() + 2 * xmargin, rect.height() + 2 * ymargin); -
508 -
509 QSizeF visible = d->viewportSize; -
510 QRectF visibleRect(startPos, visible); -
511 -
512 while (false) QMessageLogger("util/qscroller.cpp", 759, __PRETTY_FUNCTION__).debug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
never evaluated: false
never executed: QMessageLogger("util/qscroller.cpp", 759, __PRETTY_FUNCTION__).debug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
0
513 while (false) QMessageLogger("util/qscroller.cpp", 760, __PRETTY_FUNCTION__).debug() << " --> content position:" << d->contentPosition;
never evaluated: false
never executed: QMessageLogger("util/qscroller.cpp", 760, __PRETTY_FUNCTION__).debug() << " --> content position:" << d->contentPosition;
0
514 -
515 if (visibleRect.contains(marginRect))
never evaluated: visibleRect.contains(marginRect)
0
516 return;
never executed: return;
0
517 -
518 QPointF newPos = startPos; -
519 -
520 if (visibleRect.width() < rect.width()) {
never evaluated: visibleRect.width() < rect.width()
0
521 -
522 if (rect.left() > visibleRect.left())
never evaluated: rect.left() > visibleRect.left()
0
523 newPos.setX(rect.left());
never executed: newPos.setX(rect.left());
0
524 else if (rect.right() < visibleRect.right())
never evaluated: rect.right() < visibleRect.right()
0
525 newPos.setX(rect.right() - visible.width());
never executed: newPos.setX(rect.right() - visible.width());
0
526 -
527 } else if (visibleRect.width() < marginRect.width()) {
never evaluated: visibleRect.width() < marginRect.width()
0
528 newPos.setX(rect.center().x() - visibleRect.width() / 2); -
529 } else if (marginRect.left() > visibleRect.left()) {
never evaluated: marginRect.left() > visibleRect.left()
never executed: }
0
530 newPos.setX(marginRect.left()); -
531 } else if (marginRect.right() < visibleRect.right()) {
never evaluated: marginRect.right() < visibleRect.right()
never executed: }
0
532 newPos.setX(marginRect.right() - visible.width()); -
533 }
never executed: }
0
534 -
535 if (visibleRect.height() < rect.height()) {
never evaluated: visibleRect.height() < rect.height()
0
536 -
537 if (rect.top() > visibleRect.top())
never evaluated: rect.top() > visibleRect.top()
0
538 newPos.setX(rect.top());
never executed: newPos.setX(rect.top());
0
539 else if (rect.bottom() < visibleRect.bottom())
never evaluated: rect.bottom() < visibleRect.bottom()
0
540 newPos.setX(rect.bottom() - visible.height());
never executed: newPos.setX(rect.bottom() - visible.height());
0
541 -
542 } else if (visibleRect.height() < marginRect.height()) {
never evaluated: visibleRect.height() < marginRect.height()
0
543 newPos.setY(rect.center().y() - visibleRect.height() / 2); -
544 } else if (marginRect.top() > visibleRect.top()) {
never evaluated: marginRect.top() > visibleRect.top()
never executed: }
0
545 newPos.setY(marginRect.top()); -
546 } else if (marginRect.bottom() < visibleRect.bottom()) {
never evaluated: marginRect.bottom() < visibleRect.bottom()
never executed: }
0
547 newPos.setY(marginRect.bottom() - visible.height()); -
548 }
never executed: }
0
549 -
550 -
551 newPos = clampToRect(newPos, d->contentPosRange); -
552 if (newPos == startPos)
never evaluated: newPos == startPos
0
553 return;
never executed: return;
0
554 -
555 scrollTo(newPos, scrollTime); -
556}
never executed: }
0
557void QScroller::resendPrepareEvent() -
558{ -
559 QScrollerPrivate * const d = d_func(); -
560 d->prepareScrolling(d->pressPosition); -
561}
never executed: }
0
562 -
563 -
564 -
565 -
566 -
567 -
568void QScroller::setSnapPositionsX(const QList<qreal> &positions) -
569{ -
570 QScrollerPrivate * const d = d_func(); -
571 d->snapPositionsX = positions; -
572 d->snapIntervalX = 0.0; -
573 -
574 d->recalcScrollingSegments(); -
575}
never executed: }
0
576void QScroller::setSnapPositionsX(qreal first, qreal interval) -
577{ -
578 QScrollerPrivate * const d = d_func(); -
579 d->snapFirstX = first; -
580 d->snapIntervalX = interval; -
581 d->snapPositionsX.clear(); -
582 -
583 d->recalcScrollingSegments(); -
584}
never executed: }
0
585 -
586 -
587 -
588 -
589 -
590 -
591void QScroller::setSnapPositionsY(const QList<qreal> &positions) -
592{ -
593 QScrollerPrivate * const d = d_func(); -
594 d->snapPositionsY = positions; -
595 d->snapIntervalY = 0.0; -
596 -
597 d->recalcScrollingSegments(); -
598}
never executed: }
0
599 -
600 -
601 -
602 -
603 -
604 -
605 -
606void QScroller::setSnapPositionsY(qreal first, qreal interval) -
607{ -
608 QScrollerPrivate * const d = d_func(); -
609 d->snapFirstY = first; -
610 d->snapIntervalY = interval; -
611 d->snapPositionsY.clear(); -
612 -
613 d->recalcScrollingSegments(); -
614}
never executed: }
0
615 -
616 -
617 -
618 -
619 -
620QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target) -
621 : target(_target) -
622 -
623 , recognizer(0) -
624 , recognizerType(Qt::CustomGesture) -
625 -
626 , state(QScroller::Inactive) -
627 , firstScroll(true) -
628 , pressTimestamp(0) -
629 , lastTimestamp(0) -
630 , snapFirstX(-1.0) -
631 , snapIntervalX(0.0) -
632 , snapFirstY(-1.0) -
633 , snapIntervalY(0.0) -
634 -
635 , scrollTimer(new QScrollTimer(this)) -
636 -
637 , q_ptr(q) -
638{ -
639 connect(target, "2""destroyed(QObject*)", this, "1""targetDestroyed()"); -
640}
executed: }
Execution Count:8
8
641 -
642void QScrollerPrivate::init() -
643{ -
644 setDpiFromWidget(0); -
645 monotonicTimer.start(); -
646}
executed: }
Execution Count:8
8
647 -
648void QScrollerPrivate::sendEvent(QObject *o, QEvent *e) -
649{ -
650 qt_sendSpontaneousEvent(o, e); -
651}
executed: }
Execution Count:151
151
652 -
653const char *QScrollerPrivate::stateName(QScroller::State state) -
654{ -
655 switch (state) { -
656 case QScroller::Inactive: return "inactive";
never executed: return "inactive";
0
657 case QScroller::Pressed: return "pressed";
never executed: return "pressed";
0
658 case QScroller::Dragging: return "dragging";
never executed: return "dragging";
0
659 case QScroller::Scrolling: return "scrolling";
never executed: return "scrolling";
0
660 default: return "(invalid)";
never executed: return "(invalid)";
0
661 } -
662}
never executed: }
0
663 -
664const char *QScrollerPrivate::inputName(QScroller::Input input) -
665{ -
666 switch (input) { -
667 case QScroller::InputPress: return "press";
never executed: return "press";
0
668 case QScroller::InputMove: return "move";
never executed: return "move";
0
669 case QScroller::InputRelease: return "release";
never executed: return "release";
0
670 default: return "(invalid)";
never executed: return "(invalid)";
0
671 } -
672}
never executed: }
0
673 -
674void QScrollerPrivate::targetDestroyed() -
675{ -
676 -
677 scrollTimer->stop(); -
678 -
679 delete q_ptr; -
680}
executed: }
Execution Count:8
8
681 -
682void QScrollerPrivate::timerTick() -
683{ -
684 struct timerevent { -
685 QScroller::State state; -
686 typedef void (QScrollerPrivate::*timerhandler_t)(); -
687 timerhandler_t handler; -
688 }; -
689 -
690 timerevent timerevents[] = { -
691 { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging }, -
692 { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling }, -
693 }; -
694 -
695 for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) {
partially evaluated: i < int(sizeof(timerevents) / sizeof(*timerevents))
TRUEFALSE
yes
Evaluation Count:269
no
Evaluation Count:0
0-269
696 timerevent *te = timerevents + i; -
697 -
698 if (state == te->state) {
evaluated: state == te->state
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:132
132-137
699 (this->*te->handler)(); -
700 return;
executed: return;
Execution Count:137
137
701 } -
702 }
executed: }
Execution Count:132
132
703 -
704 -
705 scrollTimer->stop(); -
706 -
707}
never executed: }
0
708bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp) -
709{ -
710 QScrollerPrivate * const d = d_func(); -
711 -
712 while (false) QMessageLogger("util/qscroller.cpp", 988, __PRETTY_FUNCTION__).debug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
never executed: QMessageLogger("util/qscroller.cpp", 988, __PRETTY_FUNCTION__).debug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
713 struct statechange { -
714 State state; -
715 Input input; -
716 typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp); -
717 inputhandler_t handler; -
718 }; -
719 -
720 statechange statechanges[] = { -
721 { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive }, -
722 { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed }, -
723 { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed }, -
724 { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging }, -
725 { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging }, -
726 { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling } -
727 }; -
728 -
729 for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) {
evaluated: i < int(sizeof(statechanges) / sizeof(*statechanges))
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:2
2-58
730 statechange *sc = statechanges + i; -
731 -
732 if (d->state == sc->state && input == sc->input)
evaluated: d->state == sc->state
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:32
evaluated: input == sc->input
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:7
7-32
733 return (d->*sc->handler)(position - d->overshootPosition, timestamp);
executed: return (d->*sc->handler)(position - d->overshootPosition, timestamp);
Execution Count:19
19
734 }
executed: }
Execution Count:39
39
735 return false;
executed: return false;
Execution Count:2
2
736} -
737 -
738 -
739 -
740 -
741QPointF QScrollerPrivate::realDpi(int screen) -
742{ -
743 QWidget *w = QApplication::desktop()->screen(screen); -
744 return QPointF(w->physicalDpiX(), w->physicalDpiY());
executed: return QPointF(w->physicalDpiX(), w->physicalDpiY());
Execution Count:16
16
745} -
746 -
747 -
748 -
749 -
750 -
751 -
752 -
753QPointF QScrollerPrivate::dpi() const -
754{ -
755 return pixelPerMeter * qreal(0.0254);
never executed: return pixelPerMeter * qreal(0.0254);
0
756} -
757 -
758 -
759 -
760 -
761 -
762 -
763 -
764void QScrollerPrivate::setDpi(const QPointF &dpi) -
765{ -
766 pixelPerMeter = dpi / qreal(0.0254); -
767}
executed: }
Execution Count:16
16
768 -
769 -
770 -
771 -
772void QScrollerPrivate::setDpiFromWidget(QWidget *widget) -
773{ -
774 QDesktopWidget *dw = QApplication::desktop(); -
775 setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen())); -
776}
executed: }
Execution Count:16
16
777 -
778 -
779 -
780 -
781 -
782void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime) -
783{ -
784 if (deltaTime <= 0)
partially evaluated: deltaTime <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
785 return;
never executed: return;
0
786 -
787 QScroller * const q = q_func(); -
788 QPointF ppm = q->pixelPerMeter(); -
789 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
790 QPointF deltaPixel = deltaPixelRaw; -
791 -
792 while (false) QMessageLogger("util/qscroller.cpp", 1090, __PRETTY_FUNCTION__).debug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
never executed: QMessageLogger("util/qscroller.cpp", 1090, __PRETTY_FUNCTION__).debug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
793 -
794 -
795 if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5))
partially evaluated: ((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
796 deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength();
never executed: deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength();
0
797 -
798 QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm; -
799 -
800 -
801 -
802 qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50); -
803 -
804 -
805 -
806 if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) {
evaluated: (releaseVelocity != QPointF(0, 0))
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
partially evaluated: (deltaTime < 100)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
807 while (false) QMessageLogger("util/qscroller.cpp", 1105, __PRETTY_FUNCTION__).debug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing);
never executed: QMessageLogger("util/qscroller.cpp", 1105, __PRETTY_FUNCTION__).debug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
808 -
809 -
810 if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x())))
partially evaluated: !newv.x()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: (qSign(releaseVelocity.x()) == qSign(newv.x()))
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
811 newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing));
executed: newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing));
Execution Count:5
5
812 if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y())))
evaluated: !newv.y()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
partially evaluated: (qSign(releaseVelocity.y()) == qSign(newv.y()))
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-4
813 newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing));
executed: newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing));
Execution Count:5
5
814 } else
executed: }
Execution Count:5
5
815 while (false) QMessageLogger("util/qscroller.cpp", 1113, __PRETTY_FUNCTION__).debug() << "NO SMOOTHING to " << newv;
never executed: QMessageLogger("util/qscroller.cpp", 1113, __PRETTY_FUNCTION__).debug() << "NO SMOOTHING to " << newv;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
816 -
817 releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity)); -
818 releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity)); -
819 -
820 while (false) QMessageLogger("util/qscroller.cpp", 1118, __PRETTY_FUNCTION__).debug() << " --> new velocity:" << releaseVelocity;
never executed: QMessageLogger("util/qscroller.cpp", 1118, __PRETTY_FUNCTION__).debug() << " --> new velocity:" << releaseVelocity;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
821}
executed: }
Execution Count:10
10
822 -
823void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation) -
824{ -
825 if (startPos == stopPos || deltaPos == 0)
partially evaluated: startPos == stopPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
partially evaluated: deltaPos == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
826 return;
never executed: return;
0
827 -
828 ScrollSegment s; -
829 if (orientation == Qt::Horizontal && !xSegments.isEmpty())
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:4
evaluated: !xSegments.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
3-9
830 s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress;
executed: s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress;
Execution Count:3
3
831 else if (orientation == Qt::Vertical && !ySegments.isEmpty())
evaluated: orientation == Qt::Vertical
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
evaluated: !ySegments.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-6
832 s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress;
executed: s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress;
Execution Count:2
2
833 else -
834 s.startTime = monotonicTimer.elapsed();
executed: s.startTime = monotonicTimer.elapsed();
Execution Count:8
8
835 -
836 s.startPos = startPos; -
837 s.deltaPos = deltaPos; -
838 s.stopPos = stopPos; -
839 s.deltaTime = deltaTime * 1000; -
840 s.stopProgress = stopProgress; -
841 s.curve.setType(curve); -
842 s.type = type; -
843 -
844 if (orientation == Qt::Horizontal)
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:4
4-9
845 xSegments.enqueue(s);
executed: xSegments.enqueue(s);
Execution Count:9
9
846 else -
847 ySegments.enqueue(s);
executed: ySegments.enqueue(s);
Execution Count:4
4
848 -
849 while (false) QMessageLogger("util/qscroller.cpp", 1147, __PRETTY_FUNCTION__).debug() << "+++ Added a new ScrollSegment: " << s;
never executed: QMessageLogger("util/qscroller.cpp", 1147, __PRETTY_FUNCTION__).debug() << "+++ Added a new ScrollSegment: " << s;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
850}
executed: }
Execution Count:13
13
851 -
852 -
853 -
854 -
855 -
856void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc) -
857{ -
858 QScroller * const q = q_func(); -
859 QPointF ppm = q->pixelPerMeter(); -
860 -
861 releaseVelocity = q->velocity(); -
862 -
863 if (forceRecalc ||
partially evaluated: forceRecalc
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
864 !scrollingSegmentsValid(Qt::Horizontal) ||
never evaluated: !scrollingSegmentsValid(Qt::Horizontal)
0
865 !scrollingSegmentsValid(Qt::Vertical))
never evaluated: !scrollingSegmentsValid(Qt::Vertical)
0
866 createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm);
executed: createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm);
Execution Count:4
4
867}
executed: }
Execution Count:4
4
868 -
869 -
870 -
871 -
872qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const -
873{ -
874 if (orientation == Qt::Horizontal) {
never evaluated: orientation == Qt::Horizontal
0
875 if (xSegments.isEmpty())
never evaluated: xSegments.isEmpty()
0
876 return contentPosition.x() + overshootPosition.x();
never executed: return contentPosition.x() + overshootPosition.x();
0
877 else -
878 return xSegments.last().stopPos;
never executed: return xSegments.last().stopPos;
0
879 } else { -
880 if (ySegments.isEmpty())
never evaluated: ySegments.isEmpty()
0
881 return contentPosition.y() + overshootPosition.y();
never executed: return contentPosition.y() + overshootPosition.y();
0
882 else -
883 return ySegments.last().stopPos;
never executed: return ySegments.last().stopPos;
0
884 } -
885} -
886 -
887 -
888 -
889 -
890bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation) -
891{ -
892 QQueue<ScrollSegment> *segments; -
893 qreal minPos; -
894 qreal maxPos; -
895 -
896 if (orientation == Qt::Horizontal) {
never evaluated: orientation == Qt::Horizontal
0
897 segments = &xSegments; -
898 minPos = contentPosRange.left(); -
899 maxPos = contentPosRange.right(); -
900 } else {
never executed: }
0
901 segments = &ySegments; -
902 minPos = contentPosRange.top(); -
903 maxPos = contentPosRange.bottom(); -
904 }
never executed: }
0
905 -
906 if (segments->isEmpty())
never evaluated: segments->isEmpty()
0
907 return true;
never executed: return true;
0
908 -
909 const ScrollSegment &last = segments->last(); -
910 qreal stopPos = last.stopPos; -
911 -
912 if (last.type == ScrollTypeScrollTo)
never evaluated: last.type == ScrollTypeScrollTo
0
913 return true;
never executed: return true;
0
914 -
915 if (last.type == ScrollTypeOvershoot &&
never evaluated: last.type == ScrollTypeOvershoot
0
916 (stopPos != minPos && stopPos != maxPos))
never evaluated: stopPos != minPos
never evaluated: stopPos != maxPos
0
917 return false;
never executed: return false;
0
918 -
919 if (stopPos < minPos || stopPos > maxPos)
never evaluated: stopPos < minPos
never evaluated: stopPos > maxPos
0
920 return false;
never executed: return false;
0
921 -
922 if (stopPos == minPos || stopPos == maxPos)
never evaluated: stopPos == minPos
never evaluated: stopPos == maxPos
0
923 return true;
never executed: return true;
0
924 -
925 qreal nextSnap = nextSnapPos(stopPos, 0, orientation); -
926 if (!qIsNaN(nextSnap) && stopPos != nextSnap)
never evaluated: !qIsNaN(nextSnap)
never evaluated: stopPos != nextSnap
0
927 return false;
never executed: return false;
0
928 -
929 return true;
never executed: return true;
0
930} -
931 -
932 -
933 -
934 -
935void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type) -
936{ -
937 (void)v;; -
938 -
939 if (orientation == Qt::Horizontal)
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
940 xSegments.clear();
executed: xSegments.clear();
Execution Count:1
1
941 else -
942 ySegments.clear();
executed: ySegments.clear();
Execution Count:1
1
943 -
944 while (false) QMessageLogger("util/qscroller.cpp", 1242, __PRETTY_FUNCTION__).debug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation);
never executed: QMessageLogger("util/qscroller.cpp", 1242, __PRETTY_FUNCTION__).debug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
945 -
946 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
947 -
948 qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x()
evaluated: (orientation == Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
949 : contentPosition.y() + overshootPosition.y(); -
950 qreal deltaPos = (endPos - startPos) / 2; -
951 -
952 pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation); -
953 pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); -
954}
executed: }
Execution Count:2
2
955 -
956 -
957 -
958void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, -
959 qreal deltaTime, qreal deltaPos, -
960 Qt::Orientation orientation) -
961{ -
962 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
963 -
964 QScrollerProperties::OvershootPolicy policy; -
965 qreal minPos; -
966 qreal maxPos; -
967 qreal viewSize; -
968 -
969 if (orientation == Qt::Horizontal) {
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:9
9
970 xSegments.clear(); -
971 policy = sp->hOvershootPolicy; -
972 minPos = contentPosRange.left(); -
973 maxPos = contentPosRange.right(); -
974 viewSize = viewportSize.width(); -
975 } else {
executed: }
Execution Count:9
9
976 ySegments.clear(); -
977 policy = sp->vOvershootPolicy; -
978 minPos = contentPosRange.top(); -
979 maxPos = contentPosRange.bottom(); -
980 viewSize = viewportSize.height(); -
981 }
executed: }
Execution Count:9
9
982 -
983 bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn); -
984 bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor;
evaluated: (policy == QScrollerProperties::OvershootAlwaysOff)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:16
evaluated: !sp->overshootScrollDistanceFactor
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
2-16
985 bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos);
evaluated: !noOvershoot
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:6
evaluated: alwaysOvershoot
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
evaluated: maxPos
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
2-12
986 -
987 while (false) QMessageLogger("util/qscroller.cpp", 1285, __PRETTY_FUNCTION__).debug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation);
never executed: QMessageLogger("util/qscroller.cpp", 1285, __PRETTY_FUNCTION__).debug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
988 -
989 while (false) QMessageLogger("util/qscroller.cpp", 1287, __PRETTY_FUNCTION__).debug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type();
never executed: QMessageLogger("util/qscroller.cpp", 1287, __PRETTY_FUNCTION__).debug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
990 -
991 qreal endPos = startPos + deltaPos; -
992 -
993 while (false) QMessageLogger("util/qscroller.cpp", 1291, __PRETTY_FUNCTION__).debug() << " Real Delta:" << deltaPos;
never executed: QMessageLogger("util/qscroller.cpp", 1291, __PRETTY_FUNCTION__).debug() << " Real Delta:" << deltaPos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
994 -
995 -
996 if ((startPos < minPos && endPos < minPos) ||
evaluated: startPos < minPos
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
partially evaluated: endPos < minPos
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-17
997 (startPos > maxPos && endPos > maxPos)) {
partially evaluated: startPos > maxPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
never evaluated: endPos > maxPos
0-17
998 qreal stopPos = endPos < minPos ? minPos : maxPos;
partially evaluated: endPos < minPos
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
999 qreal oDeltaTime = sp->overshootScrollTime; -
1000 -
1001 pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); -
1002 return;
executed: return;
Execution Count:1
1
1003 } -
1004 -
1005 -
1006 qreal nextSnap = nextSnapPos(endPos, 0, orientation); -
1007 qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); -
1008 qreal higherSnapPos = nextSnapPos(startPos, 1, orientation); -
1009 -
1010 while (false) QMessageLogger("util/qscroller.cpp", 1308, __PRETTY_FUNCTION__).debug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
never executed: QMessageLogger("util/qscroller.cpp", 1308, __PRETTY_FUNCTION__).debug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1011 -
1012 -
1013 if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos))
partially evaluated: nextSnap > higherSnapPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
partially evaluated: qIsNaN(higherSnapPos)
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
1014 higherSnapPos = nextSnap;
executed: higherSnapPos = nextSnap;
Execution Count:17
17
1015 if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos))
partially evaluated: nextSnap < lowerSnapPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
partially evaluated: qIsNaN(lowerSnapPos)
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
1016 lowerSnapPos = nextSnap;
executed: lowerSnapPos = nextSnap;
Execution Count:17
17
1017 -
1018 if (qAbs(v) < sp->minimumVelocity) {
evaluated: qAbs(v) < sp->minimumVelocity
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:5
5-12
1019 -
1020 while (false) QMessageLogger("util/qscroller.cpp", 1318, __PRETTY_FUNCTION__).debug() << "### below minimum Vel" << orientation;
never executed: QMessageLogger("util/qscroller.cpp", 1318, __PRETTY_FUNCTION__).debug() << "### below minimum Vel" << orientation;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1021 -
1022 -
1023 if (qIsNaN(nextSnap) || nextSnap == startPos)
partially evaluated: qIsNaN(nextSnap)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
never evaluated: nextSnap == startPos
0-12
1024 return;
executed: return;
Execution Count:12
12
1025 -
1026 -
1027 -
1028 qreal snapDistance = higherSnapPos - lowerSnapPos; -
1029 -
1030 qreal pressDistance = (orientation == Qt::Horizontal) ?
never evaluated: (orientation == Qt::Horizontal)
0
1031 lastPosition.x() - pressPosition.x() : -
1032 lastPosition.y() - pressPosition.y(); -
1033 -
1034 -
1035 if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance)
never evaluated: sp->snapPositionRatio == 0.0
never evaluated: qAbs(pressDistance / sp->snapPositionRatio) > snapDistance
0
1036 endPos = nextSnap;
never executed: endPos = nextSnap;
0
1037 else if (pressDistance < 0.0)
never evaluated: pressDistance < 0.0
0
1038 endPos = lowerSnapPos;
never executed: endPos = lowerSnapPos;
0
1039 else -
1040 endPos = higherSnapPos;
never executed: endPos = higherSnapPos;
0
1041 -
1042 deltaPos = endPos - startPos; -
1043 qreal midPos = startPos + deltaPos * qreal(0.3); -
1044 pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation); -
1045 pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation); -
1046 return;
never executed: return;
0
1047 } -
1048 -
1049 -
1050 if (v > 0 && !qIsNaN(higherSnapPos)) {
partially evaluated: v > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: !qIsNaN(higherSnapPos)
0-5
1051 -
1052 if (endPos - startPos)
never evaluated: endPos - startPos
0
1053 deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos));
never executed: deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos));
0
1054 if (deltaTime > sp->snapTime)
never evaluated: deltaTime > sp->snapTime
0
1055 deltaTime = sp->snapTime;
never executed: deltaTime = sp->snapTime;
0
1056 endPos = higherSnapPos; -
1057 -
1058 } else if (v < 0 && !qIsNaN(lowerSnapPos)) {
never executed: }
partially evaluated: v < 0
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: !qIsNaN(lowerSnapPos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1059 -
1060 if (endPos - startPos)
never evaluated: endPos - startPos
0
1061 deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos));
never executed: deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos));
0
1062 if (deltaTime > sp->snapTime)
never evaluated: deltaTime > sp->snapTime
0
1063 deltaTime = sp->snapTime;
never executed: deltaTime = sp->snapTime;
0
1064 endPos = lowerSnapPos; -
1065 -
1066 -
1067 } else if (endPos < minPos || endPos > maxPos) {
never executed: }
partially evaluated: endPos < minPos
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
never evaluated: endPos > maxPos
0-5
1068 qreal stopPos = endPos < minPos ? minPos : maxPos;
partially evaluated: endPos < minPos
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1069 -
1070 while (false) QMessageLogger("util/qscroller.cpp", 1368, __PRETTY_FUNCTION__).debug() << "Overshoot: delta:" << (stopPos - startPos);
never executed: QMessageLogger("util/qscroller.cpp", 1368, __PRETTY_FUNCTION__).debug() << "Overshoot: delta:" << (stopPos - startPos);
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1071 -
1072 qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos)); -
1073 -
1074 if (!canOvershoot) {
evaluated: !canOvershoot
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
1075 while (false) QMessageLogger("util/qscroller.cpp", 1373, __PRETTY_FUNCTION__).debug() << "Overshoot stopp:" << stopProgress;
never executed: QMessageLogger("util/qscroller.cpp", 1373, __PRETTY_FUNCTION__).debug() << "Overshoot stopp:" << stopProgress;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1076 -
1077 pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation); -
1078 } else {
executed: }
Execution Count:2
2
1079 qreal oDeltaTime = sp->overshootScrollTime; -
1080 qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1)); -
1081 qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos; -
1082 qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor); -
1083 -
1084 while (false) QMessageLogger("util/qscroller.cpp", 1382, __PRETTY_FUNCTION__).debug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
never executed: QMessageLogger("util/qscroller.cpp", 1382, __PRETTY_FUNCTION__).debug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1085 -
1086 if (qAbs(oDistance) > qAbs(oMaxDistance)) {
partially evaluated: qAbs(oDistance) > qAbs(oMaxDistance)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1087 oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos)); -
1088 oDistance = oMaxDistance; -
1089 while (false) QMessageLogger("util/qscroller.cpp", 1387, __PRETTY_FUNCTION__).debug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
never executed: QMessageLogger("util/qscroller.cpp", 1387, __PRETTY_FUNCTION__).debug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1090 }
executed: }
Execution Count:3
3
1091 -
1092 pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation); -
1093 pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation); -
1094 }
executed: }
Execution Count:3
3
1095 return;
executed: return;
Execution Count:5
5
1096 } -
1097 -
1098 pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); -
1099}
never executed: }
0
1100 -
1101 -
1102void QScrollerPrivate::createScrollingSegments(const QPointF &v, -
1103 const QPointF &startPos, -
1104 const QPointF &ppm) -
1105{ -
1106 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1107 QVector2D vel(v); -
1108 qreal deltaTime = (qreal(2) * vel.length()) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); -
1109 QPointF deltaPos = (vel.normalized() * QVector2D(ppm)).toPointF() * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor; -
1110 -
1111 createScrollingSegments(v.x(), startPos.x(), deltaTime, deltaPos.x(), -
1112 Qt::Horizontal); -
1113 createScrollingSegments(v.y(), startPos.y(), deltaTime, deltaPos.y(), -
1114 Qt::Vertical); -
1115}
executed: }
Execution Count:9
9
1116 -
1117 -
1118 -
1119 -
1120 -
1121bool QScrollerPrivate::prepareScrolling(const QPointF &position) -
1122{ -
1123 QScrollPrepareEvent spe(position); -
1124 spe.ignore(); -
1125 sendEvent(target, &spe); -
1126 -
1127 while (false) QMessageLogger("util/qscroller.cpp", 1440, __PRETTY_FUNCTION__).debug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos();
never executed: QMessageLogger("util/qscroller.cpp", 1440, __PRETTY_FUNCTION__).debug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos();
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1128 if (spe.isAccepted()) {
partially evaluated: spe.isAccepted()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1129 QPointF oldContentPos = contentPosition + overshootPosition; -
1130 QPointF contentDelta = spe.contentPos() - oldContentPos; -
1131 -
1132 viewportSize = spe.viewportSize(); -
1133 contentPosRange = spe.contentPosRange(); -
1134 if (contentPosRange.width() < 0)
partially evaluated: contentPosRange.width() < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1135 contentPosRange.setWidth(0);
never executed: contentPosRange.setWidth(0);
0
1136 if (contentPosRange.height() < 0)
partially evaluated: contentPosRange.height() < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1137 contentPosRange.setHeight(0);
never executed: contentPosRange.setHeight(0);
0
1138 contentPosition = clampToRect(spe.contentPos(), contentPosRange); -
1139 overshootPosition = spe.contentPos() - contentPosition; -
1140 -
1141 -
1142 if (contentDelta != QPointF(0, 0)) {
evaluated: contentDelta != QPointF(0, 0)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
1143 -
1144 for (int i = 0; i < xSegments.count(); i++)
partially evaluated: i < xSegments.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1145 xSegments[i].startPos -= contentDelta.x();
never executed: xSegments[i].startPos -= contentDelta.x();
0
1146 -
1147 for (int i = 0; i < ySegments.count(); i++)
partially evaluated: i < ySegments.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1148 ySegments[i].startPos -= contentDelta.y();
never executed: ySegments[i].startPos -= contentDelta.y();
0
1149 }
executed: }
Execution Count:6
6
1150 -
1151 if (QWidget *w = qobject_cast<QWidget *>(target))
partially evaluated: QWidget *w = qobject_cast<QWidget *>(target)
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1152 setDpiFromWidget(w);
executed: setDpiFromWidget(w);
Execution Count:8
8
1153 -
1154 if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) {
partially evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1155 -
1156 if (go->scene() && !go->scene()->views().isEmpty())
never evaluated: go->scene()
never evaluated: !go->scene()->views().isEmpty()
0
1157 setDpiFromWidget(go->scene()->views().first());
never executed: setDpiFromWidget(go->scene()->views().first());
0
1158 }
never executed: }
0
1159 -
1160 -
1161 if (state == QScroller::Scrolling) {
partially evaluated: state == QScroller::Scrolling
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1162 recalcScrollingSegments(); -
1163 }
never executed: }
0
1164 return true;
executed: return true;
Execution Count:8
8
1165 } -
1166 -
1167 return false;
never executed: return false;
0
1168} -
1169 -
1170void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp) -
1171{ -
1172 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1173 -
1174 QPointF deltaPixel = position - lastPosition; -
1175 qint64 deltaTime = timestamp - lastTimestamp; -
1176 -
1177 if (sp->axisLockThreshold) {
partially evaluated: sp->axisLockThreshold
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1178 int dx = qAbs(deltaPixel.x()); -
1179 int dy = qAbs(deltaPixel.y()); -
1180 if (dx || dy) {
never evaluated: dx
never evaluated: dy
0
1181 bool vertical = (dy > dx); -
1182 qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx); -
1183 -
1184 if (alpha <= sp->axisLockThreshold) {
never evaluated: alpha <= sp->axisLockThreshold
0
1185 if (vertical)
never evaluated: vertical
0
1186 deltaPixel.setX(0);
never executed: deltaPixel.setX(0);
0
1187 else -
1188 deltaPixel.setY(0);
never executed: deltaPixel.setY(0);
0
1189 } -
1190 }
never executed: }
0
1191 }
never executed: }
0
1192 -
1193 -
1194 updateVelocity(deltaPixel, deltaTime); -
1195 -
1196 -
1197 QRectF max = contentPosRange; -
1198 bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
evaluated: (max.width() > 0)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
partially evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-8
1199 bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
partially evaluated: (max.height() > 0)
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
never evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
0-10
1200 -
1201 if (!canScrollX) {
partially evaluated: !canScrollX
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1202 deltaPixel.setX(0); -
1203 releaseVelocity.setX(0); -
1204 }
never executed: }
0
1205 if (!canScrollY) {
partially evaluated: !canScrollY
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1206 deltaPixel.setY(0); -
1207 releaseVelocity.setY(0); -
1208 }
never executed: }
0
1209 -
1210 -
1211 -
1212 -
1213 -
1214 -
1215 dragDistance += deltaPixel; -
1216 -
1217 -
1218 -
1219 lastPosition = position; -
1220 lastTimestamp = timestamp; -
1221}
executed: }
Execution Count:10
10
1222 -
1223bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp) -
1224{ -
1225 if (prepareScrolling(position)) {
partially evaluated: prepareScrolling(position)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1226 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1227 -
1228 if (!contentPosRange.isNull() ||
partially evaluated: !contentPosRange.isNull()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1229 (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) ||
never evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
0
1230 (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) {
never evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
0
1231 -
1232 lastPosition = pressPosition = position; -
1233 lastTimestamp = pressTimestamp = timestamp; -
1234 setState(QScroller::Pressed); -
1235 }
executed: }
Execution Count:7
7
1236 }
executed: }
Execution Count:7
7
1237 return false;
executed: return false;
Execution Count:7
7
1238} -
1239 -
1240bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64) -
1241{ -
1242 if (overshootPosition != QPointF(0.0, 0.0)) {
never evaluated: overshootPosition != QPointF(0.0, 0.0)
0
1243 setState(QScroller::Scrolling); -
1244 return true;
never executed: return true;
0
1245 } else { -
1246 setState(QScroller::Inactive); -
1247 return false;
never executed: return false;
0
1248 } -
1249} -
1250 -
1251bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp) -
1252{ -
1253 QScroller * const q = q_func(); -
1254 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1255 QPointF ppm = q->pixelPerMeter(); -
1256 -
1257 QPointF deltaPixel = position - pressPosition; -
1258 -
1259 bool moveAborted = false; -
1260 bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance); -
1261 -
1262 -
1263 if (moveStarted) {
partially evaluated: moveStarted
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1264 QRectF max = contentPosRange; -
1265 bool canScrollX = (max.width() > 0); -
1266 bool canScrollY = (max.height() > 0); -
1267 -
1268 if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
evaluated: sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1269 canScrollX = true;
executed: canScrollX = true;
Execution Count:2
2
1270 if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
partially evaluated: sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1271 canScrollY = true;
never executed: canScrollY = true;
0
1272 -
1273 if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) {
partially evaluated: qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1274 if (!canScrollY)
never evaluated: !canScrollY
0
1275 moveAborted = true;
never executed: moveAborted = true;
0
1276 } else {
never executed: }
0
1277 if (!canScrollX)
evaluated: !canScrollX
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1278 moveAborted = true;
executed: moveAborted = true;
Execution Count:2
2
1279 }
executed: }
Execution Count:7
7
1280 } -
1281 -
1282 if (moveAborted) {
evaluated: moveAborted
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1283 setState(QScroller::Inactive); -
1284 moveStarted = false; -
1285 -
1286 } else if (moveStarted) {
executed: }
Execution Count:2
partially evaluated: moveStarted
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1287 setState(QScroller::Dragging); -
1288 -
1289 -
1290 deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength()); -
1291 -
1292 if (deltaPixel != QPointF(0, 0)) {
partially evaluated: deltaPixel != QPointF(0, 0)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1293 -
1294 handleDrag(pressPosition + deltaPixel, timestamp); -
1295 }
executed: }
Execution Count:5
5
1296 }
executed: }
Execution Count:5
5
1297 return moveStarted;
executed: return moveStarted;
Execution Count:7
7
1298} -
1299 -
1300bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp) -
1301{ -
1302 -
1303 handleDrag(position, timestamp); -
1304 return true;
never executed: return true;
0
1305} -
1306 -
1307void QScrollerPrivate::timerEventWhileDragging() -
1308{ -
1309 if (dragDistance != QPointF(0, 0)) {
partially evaluated: dragDistance != QPointF(0, 0)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1310 while (false) QMessageLogger("util/qscroller.cpp", 1623, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance;
never executed: QMessageLogger("util/qscroller.cpp", 1623, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1311 -
1312 setContentPositionHelperDragging(-dragDistance); -
1313 dragDistance = QPointF(0, 0); -
1314 }
executed: }
Execution Count:5
5
1315}
executed: }
Execution Count:5
5
1316 -
1317bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp) -
1318{ -
1319 QScroller * const q = q_func(); -
1320 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1321 -
1322 -
1323 handleDrag(position, timestamp); -
1324 -
1325 -
1326 -
1327 QPointF deltaPixel = position - pressPosition; -
1328 if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) {
partially evaluated: ((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1329 -
1330 -
1331 if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime &&
partially evaluated: (oldVelocity != QPointF(0, 0))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: sp->acceleratingFlickMaximumTime
0-5
1332 ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) {
never evaluated: ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))
0
1333 -
1334 -
1335 int signX = 0, signY = 0; -
1336 if (releaseVelocity.x())
never evaluated: releaseVelocity.x()
0
1337 signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
never executed: signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
never evaluated: (releaseVelocity.x() > 0) == (oldVelocity.x() > 0)
0
1338 if (releaseVelocity.y())
never evaluated: releaseVelocity.y()
0
1339 signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;
never executed: signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;
never evaluated: (releaseVelocity.y() > 0) == (oldVelocity.y() > 0)
0
1340 -
1341 if (signX > 0)
never evaluated: signX > 0
0
1342 releaseVelocity.setX(qBound(-sp->maximumVelocity, 0
1343 oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, 0
1344 sp->maximumVelocity));
never executed: releaseVelocity.setX(qBound(-sp->maximumVelocity, oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity));
0
1345 if (signY > 0)
never evaluated: signY > 0
0
1346 releaseVelocity.setY(qBound(-sp->maximumVelocity, 0
1347 oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, 0
1348 sp->maximumVelocity));
never executed: releaseVelocity.setY(qBound(-sp->maximumVelocity, oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity));
0
1349 }
never executed: }
0
1350 }
executed: }
Execution Count:5
5
1351 -
1352 QPointF ppm = q->pixelPerMeter(); -
1353 createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); -
1354 -
1355 while (false) QMessageLogger("util/qscroller.cpp", 1668, __PRETTY_FUNCTION__).debug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition;
never executed: QMessageLogger("util/qscroller.cpp", 1668, __PRETTY_FUNCTION__).debug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1356 -
1357 if (xSegments.isEmpty() && ySegments.isEmpty())
partially evaluated: xSegments.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: ySegments.isEmpty()
0-5
1358 setState(QScroller::Inactive);
never executed: setState(QScroller::Inactive);
0
1359 else -
1360 setState(QScroller::Scrolling);
executed: setState(QScroller::Scrolling);
Execution Count:5
5
1361 -
1362 return true;
executed: return true;
Execution Count:5
5
1363} -
1364 -
1365void QScrollerPrivate::timerEventWhileScrolling() -
1366{ -
1367 while (false) QMessageLogger("util/qscroller.cpp", 1680, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileScrolling()";
never executed: QMessageLogger("util/qscroller.cpp", 1680, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileScrolling()";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
1368 -
1369 setContentPositionHelperScrolling(); -
1370 if (xSegments.isEmpty() && ySegments.isEmpty())
evaluated: xSegments.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:126
partially evaluated: ySegments.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-126
1371 setState(QScroller::Inactive);
executed: setState(QScroller::Inactive);
Execution Count:6
6
1372}
executed: }
Execution Count:132
132
1373 -
1374bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp) -
1375{ -
1376 QScroller * const q = q_func(); -
1377 -
1378 if ((q->velocity() <= properties.d->maximumClickThroughVelocity) &&
never evaluated: (q->velocity() <= properties.d->maximumClickThroughVelocity)
0
1379 (overshootPosition == QPointF(0.0, 0.0))) {
never evaluated: (overshootPosition == QPointF(0.0, 0.0))
0
1380 setState(QScroller::Inactive); -
1381 return false;
never executed: return false;
0
1382 } else { -
1383 lastPosition = pressPosition = position; -
1384 lastTimestamp = pressTimestamp = timestamp; -
1385 setState(QScroller::Pressed); -
1386 setState(QScroller::Dragging); -
1387 return true;
never executed: return true;
0
1388 } -
1389} -
1390 -
1391 -
1392 -
1393 -
1394void QScrollerPrivate::setState(QScroller::State newstate) -
1395{ -
1396 QScroller * const q = q_func(); -
1397 bool sendLastScroll = false; -
1398 -
1399 if (state == newstate)
partially evaluated: state == newstate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1400 return;
never executed: return;
0
1401 -
1402 while (false) QMessageLogger("util/qscroller.cpp", 1715, __PRETTY_FUNCTION__).debug() << q << "QScroller::setState(" << stateName(newstate) << ")";
never executed: QMessageLogger("util/qscroller.cpp", 1715, __PRETTY_FUNCTION__).debug() << q << "QScroller::setState(" << stateName(newstate) << ")";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1403 -
1404 switch (newstate) { -
1405 case QScroller::Inactive: -
1406 -
1407 scrollTimer->stop(); -
1408 -
1409 -
1410 -
1411 if (!firstScroll)
evaluated: !firstScroll
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
1412 sendLastScroll = true;
executed: sendLastScroll = true;
Execution Count:6
6
1413 -
1414 releaseVelocity = QPointF(0, 0); -
1415 break;
executed: break;
Execution Count:8
8
1416 -
1417 case QScroller::Pressed: -
1418 -
1419 scrollTimer->stop(); -
1420 -
1421 -
1422 oldVelocity = releaseVelocity; -
1423 releaseVelocity = QPointF(0, 0); -
1424 break;
executed: break;
Execution Count:7
7
1425 -
1426 case QScroller::Dragging: -
1427 dragDistance = QPointF(0, 0); -
1428 -
1429 if (state == QScroller::Pressed)
partially evaluated: state == QScroller::Pressed
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1430 scrollTimer->start();
executed: scrollTimer->start();
Execution Count:5
5
1431 -
1432 break;
executed: break;
Execution Count:5
5
1433 -
1434 case QScroller::Scrolling: -
1435 -
1436 scrollTimer->start(); -
1437 -
1438 break;
executed: break;
Execution Count:6
6
1439 } -
1440 -
1441 qSwap(state, newstate); -
1442 -
1443 if (sendLastScroll) {
evaluated: sendLastScroll
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:20
6-20
1444 QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished); -
1445 sendEvent(target, &se); -
1446 firstScroll = true; -
1447 }
executed: }
Execution Count:6
6
1448 if (state == QScroller::Dragging || state == QScroller::Scrolling)
evaluated: state == QScroller::Dragging
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:21
evaluated: state == QScroller::Scrolling
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:15
5-21
1449 qt_activeScrollers()->insert(q);
executed: qt_activeScrollers()->insert(q);
Execution Count:11
11
1450 else -
1451 qt_activeScrollers()->remove(q);
executed: qt_activeScrollers()->remove(q);
Execution Count:15
15
1452 q->stateChanged(state); -
1453}
executed: }
Execution Count:26
26
1454void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos) -
1455{ -
1456 const QScrollerPropertiesPrivate *sp = properties.d.data(); -
1457 -
1458 if (sp->overshootDragResistanceFactor)
partially evaluated: sp->overshootDragResistanceFactor
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1459 overshootPosition /= sp->overshootDragResistanceFactor;
executed: overshootPosition /= sp->overshootDragResistanceFactor;
Execution Count:5
5
1460 -
1461 QPointF oldPos = contentPosition + overshootPosition; -
1462 QPointF newPos = oldPos + deltaPos; -
1463 -
1464 while (false) QMessageLogger("util/qscroller.cpp", 1791, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])";
never executed: QMessageLogger("util/qscroller.cpp", 1791, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1465 while (false) QMessageLogger("util/qscroller.cpp", 1792, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
never executed: QMessageLogger("util/qscroller.cpp", 1792, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1466 -
1467 QPointF oldClampedPos = clampToRect(oldPos, contentPosRange); -
1468 QPointF newClampedPos = clampToRect(newPos, contentPosRange); -
1469 -
1470 -
1471 bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); -
1472 bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); -
1473 bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1474 ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
partially evaluated: (state == QScroller::Dragging)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: !sp->overshootDragResistanceFactor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1475 !sp->overshootDragDistanceFactor;
evaluated: !sp->overshootDragDistanceFactor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1476 bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
partially evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1477 ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
partially evaluated: (state == QScroller::Dragging)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: !sp->overshootDragResistanceFactor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1478 !sp->overshootDragDistanceFactor;
evaluated: !sp->overshootDragDistanceFactor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1479 bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width());
evaluated: !noOvershootX
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
evaluated: alwaysOvershootX
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: contentPosRange.width()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-3
1480 bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height());
evaluated: !noOvershootY
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
partially evaluated: alwaysOvershootY
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: contentPosRange.height()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1481 -
1482 qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0;
evaluated: (canOvershootX)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
1483 qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0;
evaluated: (canOvershootY)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1484 -
1485 qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0;
evaluated: (canOvershootX)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
1486 qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0;
evaluated: (canOvershootY)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1487 -
1488 qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor; -
1489 qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor; -
1490 -
1491 while (false) QMessageLogger("util/qscroller.cpp", 1818, __PRETTY_FUNCTION__).debug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy;
never executed: QMessageLogger("util/qscroller.cpp", 1818, __PRETTY_FUNCTION__).debug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1492 while (false) QMessageLogger("util/qscroller.cpp", 1819, __PRETTY_FUNCTION__).debug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX;
never executed: QMessageLogger("util/qscroller.cpp", 1819, __PRETTY_FUNCTION__).debug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1493 -
1494 if (sp->overshootDragResistanceFactor) {
partially evaluated: sp->overshootDragResistanceFactor
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1495 oldOvershootX *= sp->overshootDragResistanceFactor; -
1496 oldOvershootY *= sp->overshootDragResistanceFactor; -
1497 newOvershootX *= sp->overshootDragResistanceFactor; -
1498 newOvershootY *= sp->overshootDragResistanceFactor; -
1499 }
executed: }
Execution Count:5
5
1500 -
1501 -
1502 -
1503 newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX); -
1504 newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY); -
1505 -
1506 overshootPosition.setX(newOvershootX); -
1507 overshootPosition.setY(newOvershootY); -
1508 contentPosition = newClampedPos; -
1509 -
1510 QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); -
1511 sendEvent(target, &se); -
1512 firstScroll = false; -
1513 -
1514 while (false) QMessageLogger("util/qscroller.cpp", 1841, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition <<
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1515 "- overshoot x/y?:" << overshootPosition;
never executed: QMessageLogger("util/qscroller.cpp", 1841, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition << "- overshoot x/y?:" << overshootPosition;
0
1516}
executed: }
Execution Count:5
5
1517 -
1518 -
1519qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos) -
1520{ -
1521 qreal pos = oldPos; -
1522 -
1523 -
1524 while (!segments.isEmpty()) {
evaluated: !segments.isEmpty()
TRUEFALSE
yes
Evaluation Count:191
yes
Evaluation Count:86
86-191
1525 const ScrollSegment s = segments.head(); -
1526 -
1527 if ((s.startTime + s.deltaTime * s.stopProgress) <= now) {
evaluated: (s.startTime + s.deltaTime * s.stopProgress) <= now
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:178
13-178
1528 segments.dequeue(); -
1529 pos = s.stopPos; -
1530 } else if (s.startTime <= now) {
executed: }
Execution Count:13
partially evaluated: s.startTime <= now
TRUEFALSE
yes
Evaluation Count:178
no
Evaluation Count:0
0-178
1531 qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); -
1532 pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress); -
1533 if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) {
evaluated: s.deltaPos > 0
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:57
57-121
1534 segments.dequeue(); -
1535 pos = s.stopPos; -
1536 } else {
never executed: }
0
1537 break;
executed: break;
Execution Count:178
178
1538 } -
1539 } else { -
1540 break;
never executed: break;
0
1541 } -
1542 } -
1543 return pos;
executed: return pos;
Execution Count:264
264
1544} -
1545 -
1546void QScrollerPrivate::setContentPositionHelperScrolling() -
1547{ -
1548 qint64 now = monotonicTimer.elapsed(); -
1549 QPointF newPos = contentPosition + overshootPosition; -
1550 -
1551 newPos.setX(nextSegmentPosition(xSegments, now, newPos.x())); -
1552 newPos.setY(nextSegmentPosition(ySegments, now, newPos.y())); -
1553 -
1554 -
1555 while (false) QMessageLogger("util/qscroller.cpp", 1882, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperScrolling()";
never executed: QMessageLogger("util/qscroller.cpp", 1882, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperScrolling()";
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
1556 while (false) QMessageLogger("util/qscroller.cpp", 1883, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
never executed: QMessageLogger("util/qscroller.cpp", 1883, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
1557 -
1558 QPointF newClampedPos = clampToRect(newPos, contentPosRange); -
1559 -
1560 overshootPosition = newPos - newClampedPos; -
1561 contentPosition = newClampedPos; -
1562 -
1563 QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); -
1564 sendEvent(target, &se); -
1565 firstScroll = false; -
1566 -
1567 while (false) QMessageLogger("util/qscroller.cpp", 1894, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition;
never executed: QMessageLogger("util/qscroller.cpp", 1894, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition;
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
1568}
executed: }
Execution Count:132
132
1569qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation) -
1570{ -
1571 qreal bestSnapPos = (::qQNaN()); -
1572 qreal bestSnapPosDist = (::qInf()); -
1573 -
1574 qreal minPos; -
1575 qreal maxPos; -
1576 -
1577 if (orientation == Qt::Horizontal) {
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:28
25-28
1578 minPos = contentPosRange.left(); -
1579 maxPos = contentPosRange.right(); -
1580 } else {
executed: }
Execution Count:25
25
1581 minPos = contentPosRange.top(); -
1582 maxPos = contentPosRange.bottom(); -
1583 }
executed: }
Execution Count:28
28
1584 -
1585 if (orientation == Qt::Horizontal) {
evaluated: orientation == Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:28
25-28
1586 -
1587 for (QForeachContainer<__typeof__(snapPositionsX)> _container_(snapPositionsX); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (qreal snapPos = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
1588 qreal snapPosDist = snapPos - p; -
1589 if ((dir > 0 && snapPosDist < 0) ||
never evaluated: dir > 0
never evaluated: snapPosDist < 0
0
1590 (dir < 0 && snapPosDist > 0))
never evaluated: dir < 0
never evaluated: snapPosDist > 0
0
1591 continue;
never executed: continue;
0
1592 if (snapPos < minPos || snapPos > maxPos )
never evaluated: snapPos < minPos
never evaluated: snapPos > maxPos
0
1593 continue;
never executed: continue;
0
1594 -
1595 if (qIsNaN(bestSnapPos) ||
never evaluated: qIsNaN(bestSnapPos)
0
1596 qAbs(snapPosDist) < bestSnapPosDist ) {
never evaluated: qAbs(snapPosDist) < bestSnapPosDist
0
1597 bestSnapPos = snapPos; -
1598 bestSnapPosDist = qAbs(snapPosDist); -
1599 }
never executed: }
0
1600 }
never executed: }
0
1601 -
1602 -
1603 if (snapIntervalX > 0.0) {
partially evaluated: snapIntervalX > 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1604 qreal first = minPos + snapFirstX; -
1605 qreal snapPos; -
1606 if (dir > 0)
never evaluated: dir > 0
0
1607 snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first;
never executed: snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first;
0
1608 else if (dir < 0)
never evaluated: dir < 0
0
1609 snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first;
never executed: snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first;
0
1610 else if (p <= first)
never evaluated: p <= first
0
1611 snapPos = first;
never executed: snapPos = first;
0
1612 else -
1613 { -
1614 qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first; -
1615 if (p >= last)
never evaluated: p >= last
0
1616 snapPos = last;
never executed: snapPos = last;
0
1617 else -
1618 snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first;
never executed: snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first;
0
1619 } -
1620 -
1621 if (snapPos >= first && snapPos <= maxPos ) {
never evaluated: snapPos >= first
never evaluated: snapPos <= maxPos
0
1622 qreal snapPosDist = snapPos - p; -
1623 -
1624 if (qIsNaN(bestSnapPos) ||
never evaluated: qIsNaN(bestSnapPos)
0
1625 qAbs(snapPosDist) < bestSnapPosDist ) {
never evaluated: qAbs(snapPosDist) < bestSnapPosDist
0
1626 bestSnapPos = snapPos; -
1627 bestSnapPosDist = qAbs(snapPosDist); -
1628 }
never executed: }
0
1629 }
never executed: }
0
1630 }
never executed: }
0
1631 -
1632 } else {
executed: }
Execution Count:25
25
1633 -
1634 for (QForeachContainer<__typeof__(snapPositionsY)> _container_(snapPositionsY); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (qreal snapPos = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
1635 qreal snapPosDist = snapPos - p; -
1636 if ((dir > 0 && snapPosDist < 0) ||
never evaluated: dir > 0
never evaluated: snapPosDist < 0
0
1637 (dir < 0 && snapPosDist > 0))
never evaluated: dir < 0
never evaluated: snapPosDist > 0
0
1638 continue;
never executed: continue;
0
1639 if (snapPos < minPos || snapPos > maxPos )
never evaluated: snapPos < minPos
never evaluated: snapPos > maxPos
0
1640 continue;
never executed: continue;
0
1641 -
1642 if (qIsNaN(bestSnapPos) ||
never evaluated: qIsNaN(bestSnapPos)
0
1643 qAbs(snapPosDist) < bestSnapPosDist) {
never evaluated: qAbs(snapPosDist) < bestSnapPosDist
0
1644 bestSnapPos = snapPos; -
1645 bestSnapPosDist = qAbs(snapPosDist); -
1646 }
never executed: }
0
1647 }
never executed: }
0
1648 -
1649 -
1650 if (snapIntervalY > 0.0) {
partially evaluated: snapIntervalY > 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:28
0-28
1651 qreal first = minPos + snapFirstY; -
1652 qreal snapPos; -
1653 if (dir > 0)
never evaluated: dir > 0
0
1654 snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first;
never executed: snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first;
0
1655 else if (dir < 0)
never evaluated: dir < 0
0
1656 snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first;
never executed: snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first;
0
1657 else if (p <= first)
never evaluated: p <= first
0
1658 snapPos = first;
never executed: snapPos = first;
0
1659 else -
1660 { -
1661 qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first; -
1662 if (p >= last)
never evaluated: p >= last
0
1663 snapPos = last;
never executed: snapPos = last;
0
1664 else -
1665 snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first;
never executed: snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first;
0
1666 } -
1667 -
1668 if (snapPos >= first && snapPos <= maxPos ) {
never evaluated: snapPos >= first
never evaluated: snapPos <= maxPos
0
1669 qreal snapPosDist = snapPos - p; -
1670 -
1671 if (qIsNaN(bestSnapPos) ||
never evaluated: qIsNaN(bestSnapPos)
0
1672 qAbs(snapPosDist) < bestSnapPosDist) {
never evaluated: qAbs(snapPosDist) < bestSnapPosDist
0
1673 bestSnapPos = snapPos; -
1674 bestSnapPosDist = qAbs(snapPosDist); -
1675 }
never executed: }
0
1676 }
never executed: }
0
1677 }
never executed: }
0
1678 }
executed: }
Execution Count:28
28
1679 -
1680 return bestSnapPos;
executed: return bestSnapPos;
Execution Count:53
53
1681} -
1682 -
1683 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial