qscroller.cpp

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

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