Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qevent.h" | - |
43 | #include "qwidget.h" | - |
44 | #include "qscroller.h" | - |
45 | #include "private/qflickgesture_p.h" | - |
46 | #include "private/qscroller_p.h" | - |
47 | #include "qscrollerproperties.h" | - |
48 | #include "private/qscrollerproperties_p.h" | - |
49 | #include "qnumeric.h" | - |
50 | #include "math.h" | - |
51 | | - |
52 | #include <QTime> | - |
53 | #include <QElapsedTimer> | - |
54 | #include <QMap> | - |
55 | #include <QApplication> | - |
56 | #include <QAbstractScrollArea> | - |
57 | #include <QGraphicsObject> | - |
58 | #include <QGraphicsScene> | - |
59 | #include <QGraphicsView> | - |
60 | #include <QDesktopWidget> | - |
61 | #include <QVector2D> | - |
62 | #include <QtCore/qmath.h> | - |
63 | #include <QtGui/qevent.h> | - |
64 | #include <qnumeric.h> | - |
65 | | - |
66 | #include <QtDebug> | - |
67 | | - |
68 | | - |
69 | | - |
70 | QT_BEGIN_NAMESPACE | - |
71 | | - |
72 | bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); | - |
73 | | - |
74 | //#define QSCROLLER_DEBUG | - |
75 | | - |
76 | #ifdef QSCROLLER_DEBUG | - |
77 | # define qScrollerDebug qDebug | - |
78 | #else | - |
79 | # define qScrollerDebug while (false) qDebug | - |
80 | #endif | - |
81 | | - |
82 | QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s) | - |
83 | { | - |
84 | dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress; never executed (the execution status of this line is deduced): dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress; | - |
85 | dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos; never executed (the execution status of this line is deduced): dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos; | - |
86 | dbg << "\n Curve: type:" << s.curve.type() << "\n"; never executed (the execution status of this line is deduced): dbg << "\n Curve: type:" << s.curve.type() << "\n"; | - |
87 | return dbg; never executed: return dbg; | 0 |
88 | } | - |
89 | | - |
90 | | - |
91 | // a few helper operators to make the code below a lot more readable: | - |
92 | // otherwise a lot of ifs would have to be multi-line to check both the x | - |
93 | // and y coordinate separately. | - |
94 | | - |
95 | // returns true only if the abs. value of BOTH x and y are <= f | - |
96 | inline bool operator<=(const QPointF &p, qreal f) | - |
97 | { | - |
98 | return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f); never executed: return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f); | 0 |
99 | } | - |
100 | | - |
101 | // returns true only if the abs. value of BOTH x and y are < f | - |
102 | inline bool operator<(const QPointF &p, qreal f) | - |
103 | { | - |
104 | return (qAbs(p.x()) < f) && (qAbs(p.y()) < f); never executed: return (qAbs(p.x()) < f) && (qAbs(p.y()) < f); | 0 |
105 | } | - |
106 | | - |
107 | // returns true if the abs. value of EITHER x or y are >= f | - |
108 | inline bool operator>=(const QPointF &p, qreal f) | - |
109 | { | - |
110 | return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f); never executed: return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f); | 0 |
111 | } | - |
112 | | - |
113 | // returns true if the abs. value of EITHER x or y are > f | - |
114 | inline bool operator>(const QPointF &p, qreal f) | - |
115 | { | - |
116 | return (qAbs(p.x()) > f) || (qAbs(p.y()) > f); never executed: return (qAbs(p.x()) > f) || (qAbs(p.y()) > f); | 0 |
117 | } | - |
118 | | - |
119 | // returns a new point with both coordinates having the abs. value of the original one | - |
120 | inline QPointF qAbs(const QPointF &p) | - |
121 | { | - |
122 | return QPointF(qAbs(p.x()), qAbs(p.y())); never executed: return QPointF(qAbs(p.x()), qAbs(p.y())); | 0 |
123 | } | - |
124 | | - |
125 | // returns a new point with all components of p1 multiplied by the corresponding components of p2 | - |
126 | inline QPointF operator*(const QPointF &p1, const QPointF &p2) | - |
127 | { | - |
128 | return QPointF(p1.x() * p2.x(), p1.y() * p2.y()); never executed: return QPointF(p1.x() * p2.x(), p1.y() * p2.y()); | 0 |
129 | } | - |
130 | | - |
131 | // returns a new point with all components of p1 divided by the corresponding components of p2 | - |
132 | inline QPointF operator/(const QPointF &p1, const QPointF &p2) | - |
133 | { | - |
134 | return QPointF(p1.x() / p2.x(), p1.y() / p2.y()); executed: return QPointF(p1.x() / p2.x(), p1.y() / p2.y()); Execution Count:22 | 22 |
135 | } | - |
136 | | - |
137 | inline QPointF clampToRect(const QPointF &p, const QRectF &rect) | - |
138 | { | - |
139 | qreal x = qBound(rect.left(), p.x(), rect.right()); executed (the execution status of this line is deduced): qreal x = qBound(rect.left(), p.x(), rect.right()); | - |
140 | qreal y = qBound(rect.top(), p.y(), rect.bottom()); executed (the execution status of this line is deduced): qreal y = qBound(rect.top(), p.y(), rect.bottom()); | - |
141 | return QPointF(x, y); executed: return QPointF(x, y); Execution Count:151 | 151 |
142 | } | - |
143 | | - |
144 | // returns -1, 0 or +1 according to r being <0, ==0 or >0 | - |
145 | inline int qSign(qreal r) | - |
146 | { | - |
147 | return (r < 0) ? -1 : ((r > 0) ? 1 : 0); executed: return (r < 0) ? -1 : ((r > 0) ? 1 : 0); Execution Count:15 | 15 |
148 | } | - |
149 | | - |
150 | // this version is not mathematically exact, but it just works for every | - |
151 | // easing curve type (even custom ones) | - |
152 | | - |
153 | static qreal differentialForProgress(const QEasingCurve &curve, qreal pos) | - |
154 | { | - |
155 | const qreal dx = 0.01; executed (the execution status of this line is deduced): const qreal dx = 0.01; | - |
156 | qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx); partially evaluated: (pos < qreal(0.5)) yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
157 | qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx); partially evaluated: (pos >= qreal(0.5)) no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
158 | qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx); executed (the execution status of this line is deduced): qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx); | - |
159 | | - |
160 | //qScrollerDebug() << "differentialForProgress(type: " << curve.type() << ", pos: " << pos << ") = " << d; | - |
161 | | - |
162 | return d; executed: return d; Execution Count:9 | 9 |
163 | } | - |
164 | | - |
165 | // this version is not mathematically exact, but it just works for every | - |
166 | // easing curve type (even custom ones) | - |
167 | | - |
168 | static qreal progressForValue(const QEasingCurve &curve, qreal value) | - |
169 | { | - |
170 | if (curve.type() >= QEasingCurve::InElastic && partially evaluated: curve.type() >= QEasingCurve::InElastic no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
171 | curve.type() < QEasingCurve::Custom) { never evaluated: curve.type() < QEasingCurve::Custom | 0 |
172 | qWarning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type()); never executed (the execution status of this line is deduced): QMessageLogger("util/qscroller.cpp", 172, __PRETTY_FUNCTION__).warning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type()); | - |
173 | return value; never executed: return value; | 0 |
174 | } | - |
175 | if (value < qreal(0) || value > qreal(1)) partially evaluated: value < qreal(0) no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: value > qreal(1) no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
176 | return value; never executed: return value; | 0 |
177 | | - |
178 | qreal progress = value, left(0), right(1); executed (the execution status of this line is deduced): qreal progress = value, left(0), right(1); | - |
179 | for (int iterations = 6; iterations; --iterations) { evaluated: iterations yes Evaluation Count:48 | yes Evaluation Count:8 |
| 8-48 |
180 | qreal v = curve.valueForProgress(progress); executed (the execution status of this line is deduced): qreal v = curve.valueForProgress(progress); | - |
181 | if (v < value) evaluated: v < value yes Evaluation Count:8 | yes Evaluation Count:40 |
| 8-40 |
182 | left = progress; executed: left = progress; Execution Count:8 | 8 |
183 | else if (v > value) partially evaluated: v > value yes Evaluation Count:40 | no Evaluation Count:0 |
| 0-40 |
184 | right = progress; executed: right = progress; Execution Count:40 | 40 |
185 | else | - |
186 | break; | 0 |
187 | progress = (left + right) / qreal(2); executed (the execution status of this line is deduced): progress = (left + right) / qreal(2); | - |
188 | } executed: } Execution Count:48 | 48 |
189 | return progress; executed: return progress; Execution Count:8 | 8 |
190 | } | - |
191 | | - |
192 | | - |
193 | #ifndef QT_NO_ANIMATION | - |
194 | class QScrollTimer : public QAbstractAnimation | - |
195 | { | - |
196 | public: | - |
197 | QScrollTimer(QScrollerPrivate *_d) | - |
198 | : d(_d), ignoreUpdate(false), skip(0) | - |
199 | { } executed: } Execution Count:8 | 8 |
200 | | - |
201 | int duration() const | - |
202 | { | - |
203 | return -1; executed: return -1; Execution Count:149 | 149 |
204 | } | - |
205 | | - |
206 | void start() | - |
207 | { | - |
208 | // QAbstractAnimation::start() will immediately call | - |
209 | // updateCurrentTime(), but our state is not set correctly yet | - |
210 | ignoreUpdate = true; executed (the execution status of this line is deduced): ignoreUpdate = true; | - |
211 | QAbstractAnimation::start(); executed (the execution status of this line is deduced): QAbstractAnimation::start(); | - |
212 | ignoreUpdate = false; executed (the execution status of this line is deduced): ignoreUpdate = false; | - |
213 | skip = 0; executed (the execution status of this line is deduced): skip = 0; | - |
214 | } executed: } Execution Count:11 | 11 |
215 | | - |
216 | protected: | - |
217 | void updateCurrentTime(int /*currentTime*/) | - |
218 | { | - |
219 | if (!ignoreUpdate) { evaluated: !ignoreUpdate yes Evaluation Count:137 | yes Evaluation Count:6 |
| 6-137 |
220 | if (++skip >= d->frameRateSkip()) { partially evaluated: ++skip >= d->frameRateSkip() yes Evaluation Count:137 | no Evaluation Count:0 |
| 0-137 |
221 | skip = 0; executed (the execution status of this line is deduced): skip = 0; | - |
222 | d->timerTick(); executed (the execution status of this line is deduced): d->timerTick(); | - |
223 | } executed: } Execution Count:137 | 137 |
224 | } executed: } Execution Count:137 | 137 |
225 | } executed: } Execution Count:143 | 143 |
226 | | - |
227 | private: | - |
228 | QScrollerPrivate *d; | - |
229 | bool ignoreUpdate; | - |
230 | int skip; | - |
231 | }; | - |
232 | #endif // QT_NO_ANIMATION | - |
233 | | - |
234 | /*! | - |
235 | \class QScroller | - |
236 | \brief The QScroller class enables kinetic scrolling for any scrolling widget or graphics item. | - |
237 | \since 5.0 | - |
238 | | - |
239 | \inmodule QtWidgets | - |
240 | | - |
241 | With kinetic scrolling, the user can push the widget in a given | - |
242 | direction and it will continue to scroll in this direction until it is | - |
243 | stopped either by the user or by friction. Aspects of inertia, friction | - |
244 | and other physical concepts can be changed in order to fine-tune an | - |
245 | intuitive user experience. | - |
246 | | - |
247 | The QScroller object is the object that stores the current position and | - |
248 | scrolling speed and takes care of updates. | - |
249 | QScroller can be triggered by a flick gesture | - |
250 | | - |
251 | \code | - |
252 | QWidget *w = ...; | - |
253 | QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture); | - |
254 | \endcode | - |
255 | | - |
256 | or directly like this: | - |
257 | | - |
258 | \code | - |
259 | QWidget *w = ...; | - |
260 | QScroller *scroller = QScroller::scroller(w); | - |
261 | scroller->scrollTo(QPointF(100, 100)); | - |
262 | \endcode | - |
263 | | - |
264 | The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to | - |
265 | update its geometry information and a QScrollEvent whenever the content of the object should | - |
266 | actually be scrolled. | - |
267 | | - |
268 | The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This | - |
269 | can be changed with QScrollerProperties::FrameRate on a per-QScroller basis. | - |
270 | | - |
271 | Several examples in the \c scroller examples directory show how QScroller, | - |
272 | QScrollEvent and the scroller gesture can be used. | - |
273 | | - |
274 | Even though this kinetic scroller has a large number of settings available via | - |
275 | QScrollerProperties, we recommend that you leave them all at their default, platform optimized | - |
276 | values. Before changing them you can experiment with the \c plot example in | - |
277 | the \c scroller examples directory. | - |
278 | | - |
279 | \sa QScrollEvent, QScrollPrepareEvent, QScrollerProperties | - |
280 | */ | - |
281 | | - |
282 | typedef QMap<QObject *, QScroller *> ScrollerHash; | - |
283 | typedef QSet<QScroller *> ScrollerSet; | - |
284 | | - |
285 | Q_GLOBAL_STATIC(ScrollerHash, qt_allScrollers) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:54 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:1 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:1 | yes Evaluation Count:53 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-54 |
286 | Q_GLOBAL_STATIC(ScrollerSet, qt_activeScrollers) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:41 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:1 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:1 | yes Evaluation Count:40 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-41 |
287 | | - |
288 | /*! | - |
289 | Returns \c true if a QScroller object was already created for \a target; \c false otherwise. | - |
290 | | - |
291 | \sa scroller() | - |
292 | */ | - |
293 | bool QScroller::hasScroller(QObject *target) | - |
294 | { | - |
295 | return (qt_allScrollers()->value(target)); executed: return (qt_allScrollers()->value(target)); Execution Count:2 | 2 |
296 | } | - |
297 | | - |
298 | /*! | - |
299 | Returns the scroller for the given \a target. | - |
300 | As long as the object exists this function will always return the same QScroller instance. | - |
301 | If no QScroller exists for the \a target, one will implicitly be created. | - |
302 | At no point more than one QScroller will be active on an object. | - |
303 | | - |
304 | \sa hasScroller(), target() | - |
305 | */ | - |
306 | QScroller *QScroller::scroller(QObject *target) | - |
307 | { | - |
308 | if (!target) { evaluated: !target yes Evaluation Count:1 | yes Evaluation Count:22 |
| 1-22 |
309 | qWarning("QScroller::scroller() was called with a null target."); executed (the execution status of this line is deduced): QMessageLogger("util/qscroller.cpp", 309, __PRETTY_FUNCTION__).warning("QScroller::scroller() was called with a null target."); | - |
310 | return 0; executed: return 0; Execution Count:1 | 1 |
311 | } | - |
312 | | - |
313 | if (qt_allScrollers()->contains(target)) evaluated: qt_allScrollers()->contains(target) yes Evaluation Count:14 | yes Evaluation Count:8 |
| 8-14 |
314 | return qt_allScrollers()->value(target); executed: return qt_allScrollers()->value(target); Execution Count:14 | 14 |
315 | | - |
316 | QScroller *s = new QScroller(target); executed (the execution status of this line is deduced): QScroller *s = new QScroller(target); | - |
317 | qt_allScrollers()->insert(target, s); executed (the execution status of this line is deduced): qt_allScrollers()->insert(target, s); | - |
318 | return s; executed: return s; Execution Count:8 | 8 |
319 | } | - |
320 | | - |
321 | /*! | - |
322 | \overload | - |
323 | This is the const version of scroller(). | - |
324 | */ | - |
325 | const QScroller *QScroller::scroller(const QObject *target) | - |
326 | { | - |
327 | return scroller(const_cast<QObject*>(target)); executed: return scroller(const_cast<QObject*>(target)); Execution Count:1 | 1 |
328 | } | - |
329 | | - |
330 | /*! | - |
331 | Returns an application wide list of currently active QScroller objects. | - |
332 | Active QScroller objects are in a state() that is not QScroller::Inactive. | - |
333 | This function is useful when writing your own gesture recognizer. | - |
334 | */ | - |
335 | QList<QScroller *> QScroller::activeScrollers() | - |
336 | { | - |
337 | return qt_activeScrollers()->toList(); executed: return qt_activeScrollers()->toList(); Execution Count:7 | 7 |
338 | } | - |
339 | | - |
340 | /*! | - |
341 | Returns the target object of this scroller. | - |
342 | \sa hasScroller(), scroller() | - |
343 | */ | - |
344 | QObject *QScroller::target() const | - |
345 | { | - |
346 | Q_D(const QScroller); never executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
347 | return d->target; never executed: return d->target; | 0 |
348 | } | - |
349 | | - |
350 | /*! | - |
351 | \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties); | - |
352 | | - |
353 | QScroller emits this signal whenever its scroller properties change. | - |
354 | \a newProperties are the new scroller properties. | - |
355 | | - |
356 | \sa scrollerProperties | - |
357 | */ | - |
358 | | - |
359 | | - |
360 | /*! \property QScroller::scrollerProperties | - |
361 | \brief The scroller properties of this scroller. | - |
362 | The properties are used by the QScroller to determine its scrolling behavior. | - |
363 | */ | - |
364 | QScrollerProperties QScroller::scrollerProperties() const | - |
365 | { | - |
366 | Q_D(const QScroller); executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
367 | return d->properties; executed: return d->properties; Execution Count:12 | 12 |
368 | } | - |
369 | | - |
370 | void QScroller::setScrollerProperties(const QScrollerProperties &sp) | - |
371 | { | - |
372 | Q_D(QScroller); executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
373 | if (d->properties != sp) { evaluated: d->properties != sp yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
374 | d->properties = sp; executed (the execution status of this line is deduced): d->properties = sp; | - |
375 | emit scrollerPropertiesChanged(sp); executed (the execution status of this line is deduced): scrollerPropertiesChanged(sp); | - |
376 | | - |
377 | // we need to force the recalculation here, since the overshootPolicy may have changed and | - |
378 | // existing segments may include an overshoot animation. | - |
379 | d->recalcScrollingSegments(true); executed (the execution status of this line is deduced): d->recalcScrollingSegments(true); | - |
380 | } executed: } Execution Count:4 | 4 |
381 | } executed: } Execution Count:5 | 5 |
382 | | - |
383 | #ifndef QT_NO_GESTURES | - |
384 | | - |
385 | /*! | - |
386 | Registers a custom scroll gesture recognizer, grabs it for the \a | - |
387 | target and returns the resulting gesture type. If \a scrollGestureType is | - |
388 | set to TouchGesture the gesture triggers on touch events. If it is set to | - |
389 | one of LeftMouseButtonGesture, RightMouseButtonGesture or | - |
390 | MiddleMouseButtonGesture it triggers on mouse events of the | - |
391 | corresponding button. | - |
392 | | - |
393 | Only one scroll gesture can be active on a single object at the same | - |
394 | time. If you call this function twice on the same object, it will | - |
395 | ungrab the existing gesture before grabbing the new one. | - |
396 | | - |
397 | \note To avoid unwanted side-effects, mouse events are consumed while | - |
398 | the gesture is triggered. Since the initial mouse press event is | - |
399 | not consumed, the gesture sends a fake mouse release event | - |
400 | at the global position \c{(INT_MIN, INT_MIN)}. This ensures that | - |
401 | internal states of the widget that received the original mouse press | - |
402 | are consistent. | - |
403 | | - |
404 | \sa ungrabGesture(), grabbedGesture() | - |
405 | */ | - |
406 | Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType) | - |
407 | { | - |
408 | // ensure that a scroller for target is created | - |
409 | QScroller *s = scroller(target); executed (the execution status of this line is deduced): QScroller *s = scroller(target); | - |
410 | if (!s) partially evaluated: !s no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
411 | return Qt::GestureType(0); never executed: return Qt::GestureType(0); | 0 |
412 | | - |
413 | QScrollerPrivate *sp = s->d_ptr; executed (the execution status of this line is deduced): QScrollerPrivate *sp = s->d_ptr; | - |
414 | if (sp->recognizer) partially evaluated: sp->recognizer no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
415 | ungrabGesture(target); // ungrab the old gesture never executed: ungrabGesture(target); | 0 |
416 | | - |
417 | Qt::MouseButton button; executed (the execution status of this line is deduced): Qt::MouseButton button; | - |
418 | switch (scrollGestureType) { | - |
419 | case LeftMouseButtonGesture : button = Qt::LeftButton; break; | 0 |
420 | case RightMouseButtonGesture : button = Qt::RightButton; break; | 0 |
421 | case MiddleMouseButtonGesture: button = Qt::MiddleButton; break; | 0 |
422 | default : | - |
423 | case TouchGesture : button = Qt::NoButton; break; // NoButton == Touch executed: break; Execution Count:2 | 2 |
424 | } | - |
425 | | - |
426 | sp->recognizer = new QFlickGestureRecognizer(button); never executed (the execution status of this line is deduced): sp->recognizer = new QFlickGestureRecognizer(button); | - |
427 | sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer); never executed (the execution status of this line is deduced): sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer); | - |
428 | | - |
429 | if (target->isWidgetType()) { partially evaluated: target->isWidgetType() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
430 | QWidget *widget = static_cast<QWidget *>(target); executed (the execution status of this line is deduced): QWidget *widget = static_cast<QWidget *>(target); | - |
431 | widget->grabGesture(sp->recognizerType); executed (the execution status of this line is deduced): widget->grabGesture(sp->recognizerType); | - |
432 | if (scrollGestureType == TouchGesture) partially evaluated: scrollGestureType == TouchGesture yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
433 | widget->setAttribute(Qt::WA_AcceptTouchEvents); executed: widget->setAttribute(Qt::WA_AcceptTouchEvents); Execution Count:2 | 2 |
434 | #ifndef QT_NO_GRAPHICSVIEW | - |
435 | } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) { executed: } Execution Count:2 never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target) | 0-2 |
436 | if (scrollGestureType == TouchGesture) never evaluated: scrollGestureType == TouchGesture | 0 |
437 | go->setAcceptTouchEvents(true); never executed: go->setAcceptTouchEvents(true); | 0 |
438 | go->grabGesture(sp->recognizerType); never executed (the execution status of this line is deduced): go->grabGesture(sp->recognizerType); | - |
439 | #endif // QT_NO_GRAPHICSVIEW | - |
440 | } | 0 |
441 | return sp->recognizerType; executed: return sp->recognizerType; Execution Count:2 | 2 |
442 | } | - |
443 | | - |
444 | /*! | - |
445 | Returns the gesture type currently grabbed for the \a target or 0 if no | - |
446 | gesture is grabbed. | - |
447 | | - |
448 | \sa grabGesture(), ungrabGesture() | - |
449 | */ | - |
450 | Qt::GestureType QScroller::grabbedGesture(QObject *target) | - |
451 | { | - |
452 | QScroller *s = scroller(target); never executed (the execution status of this line is deduced): QScroller *s = scroller(target); | - |
453 | if (s && s->d_ptr) never evaluated: s never evaluated: s->d_ptr | 0 |
454 | return s->d_ptr->recognizerType; never executed: return s->d_ptr->recognizerType; | 0 |
455 | else | - |
456 | return Qt::GestureType(0); never executed: return Qt::GestureType(0); | 0 |
457 | } | - |
458 | | - |
459 | /*! | - |
460 | Ungrabs the gesture for the \a target. | - |
461 | Does nothing if no gesture is grabbed. | - |
462 | | - |
463 | \sa grabGesture(), grabbedGesture() | - |
464 | */ | - |
465 | void QScroller::ungrabGesture(QObject *target) | - |
466 | { | - |
467 | QScroller *s = scroller(target); never executed (the execution status of this line is deduced): QScroller *s = scroller(target); | - |
468 | if (!s) | 0 |
469 | return; | 0 |
470 | | - |
471 | QScrollerPrivate *sp = s->d_ptr; never executed (the execution status of this line is deduced): QScrollerPrivate *sp = s->d_ptr; | - |
472 | if (!sp->recognizer) never evaluated: !sp->recognizer | 0 |
473 | return; // nothing to do | 0 |
474 | | - |
475 | if (target->isWidgetType()) { never evaluated: target->isWidgetType() | 0 |
476 | QWidget *widget = static_cast<QWidget *>(target); never executed (the execution status of this line is deduced): QWidget *widget = static_cast<QWidget *>(target); | - |
477 | widget->ungrabGesture(sp->recognizerType); never executed (the execution status of this line is deduced): widget->ungrabGesture(sp->recognizerType); | - |
478 | #ifndef QT_NO_GRAPHICSVIEW | - |
479 | } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) { never executed: } never evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target) | 0 |
480 | go->ungrabGesture(sp->recognizerType); never executed (the execution status of this line is deduced): go->ungrabGesture(sp->recognizerType); | - |
481 | #endif | - |
482 | } | 0 |
483 | | - |
484 | QGestureRecognizer::unregisterRecognizer(sp->recognizerType); never executed (the execution status of this line is deduced): QGestureRecognizer::unregisterRecognizer(sp->recognizerType); | - |
485 | // do not delete the recognizer. The QGestureManager is doing this. | - |
486 | sp->recognizer = 0; never executed (the execution status of this line is deduced): sp->recognizer = 0; | - |
487 | } | 0 |
488 | | - |
489 | #endif // QT_NO_GESTURES | - |
490 | | - |
491 | /*! | - |
492 | \internal | - |
493 | */ | - |
494 | QScroller::QScroller(QObject *target) | - |
495 | : d_ptr(new QScrollerPrivate(this, target)) | - |
496 | { | - |
497 | Q_ASSERT(target); // you can't create a scroller without a target in any normal way executed (the execution status of this line is deduced): qt_noop(); | - |
498 | Q_D(QScroller); executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
499 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
500 | } executed: } Execution Count:8 | 8 |
501 | | - |
502 | /*! | - |
503 | \internal | - |
504 | */ | - |
505 | QScroller::~QScroller() | - |
506 | { | - |
507 | Q_D(QScroller); executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
508 | #ifndef QT_NO_GESTURES | - |
509 | QGestureRecognizer::unregisterRecognizer(d->recognizerType); executed (the execution status of this line is deduced): QGestureRecognizer::unregisterRecognizer(d->recognizerType); | - |
510 | // do not delete the recognizer. The QGestureManager is doing this. | - |
511 | d->recognizer = 0; executed (the execution status of this line is deduced): d->recognizer = 0; | - |
512 | #endif | - |
513 | qt_allScrollers()->remove(d->target); executed (the execution status of this line is deduced): qt_allScrollers()->remove(d->target); | - |
514 | qt_activeScrollers()->remove(this); executed (the execution status of this line is deduced): qt_activeScrollers()->remove(this); | - |
515 | | - |
516 | delete d_ptr; executed (the execution status of this line is deduced): delete d_ptr; | - |
517 | } executed: } Execution Count:8 | 8 |
518 | | - |
519 | | - |
520 | /*! | - |
521 | \fn QScroller::stateChanged(QScroller::State newState); | - |
522 | | - |
523 | QScroller emits this signal whenever the state changes. \a newState is the new State. | - |
524 | | - |
525 | \sa state | - |
526 | */ | - |
527 | | - |
528 | /*! | - |
529 | \property QScroller::state | - |
530 | \brief the state of the scroller | - |
531 | | - |
532 | \sa QScroller::State | - |
533 | */ | - |
534 | QScroller::State QScroller::state() const | - |
535 | { | - |
536 | Q_D(const QScroller); executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
537 | return d->state; executed: return d->state; Execution Count:171 | 171 |
538 | } | - |
539 | | - |
540 | /*! | - |
541 | Stops the scroller and resets its state back to Inactive. | - |
542 | */ | - |
543 | void QScroller::stop() | - |
544 | { | - |
545 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
546 | if (d->state != Inactive) { never evaluated: d->state != Inactive | 0 |
547 | QPointF here = clampToRect(d->contentPosition, d->contentPosRange); never executed (the execution status of this line is deduced): QPointF here = clampToRect(d->contentPosition, d->contentPosRange); | - |
548 | qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal); never executed (the execution status of this line is deduced): qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal); | - |
549 | qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical); never executed (the execution status of this line is deduced): qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical); | - |
550 | QPointF snap = here; never executed (the execution status of this line is deduced): QPointF snap = here; | - |
551 | if (!qIsNaN(snapX)) never evaluated: !qIsNaN(snapX) | 0 |
552 | snap.setX(snapX); never executed: snap.setX(snapX); | 0 |
553 | if (!qIsNaN(snapY)) never evaluated: !qIsNaN(snapY) | 0 |
554 | snap.setY(snapY); never executed: snap.setY(snapY); | 0 |
555 | d->contentPosition = snap; never executed (the execution status of this line is deduced): d->contentPosition = snap; | - |
556 | d->overshootPosition = QPointF(0, 0); never executed (the execution status of this line is deduced): d->overshootPosition = QPointF(0, 0); | - |
557 | | - |
558 | d->setState(Inactive); never executed (the execution status of this line is deduced): d->setState(Inactive); | - |
559 | } | 0 |
560 | } | 0 |
561 | | - |
562 | /*! | - |
563 | Returns the pixel per meter metric for the scrolled widget. | - |
564 | | - |
565 | The value is reported for both the x and y axis separately by using a QPointF. | - |
566 | | - |
567 | \note Please note that this value should be physically correct. The actual DPI settings | - |
568 | that Qt returns for the display may be reported wrongly on purpose by the underlying | - |
569 | windowing system, for example on Mac OS X. | - |
570 | */ | - |
571 | QPointF QScroller::pixelPerMeter() const | - |
572 | { | - |
573 | Q_D(const QScroller); executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
574 | QPointF ppm = d->pixelPerMeter; executed (the execution status of this line is deduced): QPointF ppm = d->pixelPerMeter; | - |
575 | | - |
576 | #ifndef QT_NO_GRAPHICSVIEW | - |
577 | if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) { partially evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target) no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
578 | QTransform viewtr; never executed (the execution status of this line is deduced): QTransform viewtr; | - |
579 | //TODO: the first view isn't really correct - maybe use an additional field in the prepare event? | - |
580 | if (go->scene() && !go->scene()->views().isEmpty()) never evaluated: go->scene() never evaluated: !go->scene()->views().isEmpty() | 0 |
581 | viewtr = go->scene()->views().first()->viewportTransform(); never executed: viewtr = go->scene()->views().first()->viewportTransform(); | 0 |
582 | QTransform tr = go->deviceTransform(viewtr); never executed (the execution status of this line is deduced): QTransform tr = go->deviceTransform(viewtr); | - |
583 | if (tr.isScaling()) { never evaluated: tr.isScaling() | 0 |
584 | QPointF p0 = tr.map(QPointF(0, 0)); never executed (the execution status of this line is deduced): QPointF p0 = tr.map(QPointF(0, 0)); | - |
585 | QPointF px = tr.map(QPointF(1, 0)); never executed (the execution status of this line is deduced): QPointF px = tr.map(QPointF(1, 0)); | - |
586 | QPointF py = tr.map(QPointF(0, 1)); never executed (the execution status of this line is deduced): QPointF py = tr.map(QPointF(0, 1)); | - |
587 | ppm.rx() /= QLineF(p0, px).length(); never executed (the execution status of this line is deduced): ppm.rx() /= QLineF(p0, px).length(); | - |
588 | ppm.ry() /= QLineF(p0, py).length(); never executed (the execution status of this line is deduced): ppm.ry() /= QLineF(p0, py).length(); | - |
589 | } | 0 |
590 | } | 0 |
591 | #endif // QT_NO_GRAPHICSVIEW | - |
592 | return ppm; executed: return ppm; Execution Count:31 | 31 |
593 | } | - |
594 | | - |
595 | /*! | - |
596 | Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging. | - |
597 | Returns a zero velocity otherwise. | - |
598 | | - |
599 | The velocity is reported for both the x and y axis separately by using a QPointF. | - |
600 | | - |
601 | \sa pixelPerMeter() | - |
602 | */ | - |
603 | QPointF QScroller::velocity() const | - |
604 | { | - |
605 | Q_D(const QScroller); executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
606 | const QScrollerPropertiesPrivate *sp = d->properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = d->properties.d.data(); | - |
607 | | - |
608 | switch (state()) { | - |
609 | case Dragging: | - |
610 | return d->releaseVelocity; never executed: return d->releaseVelocity; | 0 |
611 | case Scrolling: { | - |
612 | QPointF vel; never executed (the execution status of this line is deduced): QPointF vel; | - |
613 | qint64 now = d->monotonicTimer.elapsed(); never executed (the execution status of this line is deduced): qint64 now = d->monotonicTimer.elapsed(); | - |
614 | | - |
615 | if (!d->xSegments.isEmpty()) { never evaluated: !d->xSegments.isEmpty() | 0 |
616 | const QScrollerPrivate::ScrollSegment &s = d->xSegments.head(); never executed (the execution status of this line is deduced): const QScrollerPrivate::ScrollSegment &s = d->xSegments.head(); | - |
617 | qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); never executed (the execution status of this line is deduced): qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); | - |
618 | qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); never executed (the execution status of this line is deduced): qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); | - |
619 | vel.setX(v); never executed (the execution status of this line is deduced): vel.setX(v); | - |
620 | } | 0 |
621 | | - |
622 | if (!d->ySegments.isEmpty()) { never evaluated: !d->ySegments.isEmpty() | 0 |
623 | const QScrollerPrivate::ScrollSegment &s = d->ySegments.head(); never executed (the execution status of this line is deduced): const QScrollerPrivate::ScrollSegment &s = d->ySegments.head(); | - |
624 | qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); never executed (the execution status of this line is deduced): qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); | - |
625 | qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); never executed (the execution status of this line is deduced): qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); | - |
626 | vel.setY(v); never executed (the execution status of this line is deduced): vel.setY(v); | - |
627 | } | 0 |
628 | return vel; never executed: return vel; | 0 |
629 | } | - |
630 | default: | - |
631 | return QPointF(0, 0); executed: return QPointF(0, 0); Execution Count:5 | 5 |
632 | } | - |
633 | } | 0 |
634 | | - |
635 | /*! | - |
636 | Returns the estimated final position for the current scroll movement. | - |
637 | Returns the current position if the scroller state is not Scrolling. | - |
638 | The result is undefined when the scroller state is Inactive. | - |
639 | | - |
640 | The target position is in pixel. | - |
641 | | - |
642 | \sa pixelPerMeter(), scrollTo() | - |
643 | */ | - |
644 | QPointF QScroller::finalPosition() const | - |
645 | { | - |
646 | Q_D(const QScroller); never executed (the execution status of this line is deduced): const QScrollerPrivate * const d = d_func(); | - |
647 | return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), never executed: return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), d->scrollingSegmentsEndPos(Qt::Vertical)); | 0 |
648 | d->scrollingSegmentsEndPos(Qt::Vertical)); never executed: return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), d->scrollingSegmentsEndPos(Qt::Vertical)); | 0 |
649 | } | - |
650 | | - |
651 | /*! | - |
652 | Starts scrolling the widget so that point \a pos is at the top-left position in | - |
653 | the viewport. | - |
654 | | - |
655 | The behaviour when scrolling outside the valid scroll area is undefined. | - |
656 | In this case the scroller might or might not overshoot. | - |
657 | | - |
658 | The scrolling speed will be calculated so that the given position will | - |
659 | be reached after a platform-defined time span. | - |
660 | | - |
661 | \a pos is given in viewport coordinates. | - |
662 | | - |
663 | \sa ensureVisible() | - |
664 | */ | - |
665 | void QScroller::scrollTo(const QPointF &pos) | - |
666 | { | - |
667 | // we could make this adjustable via QScrollerProperties | - |
668 | scrollTo(pos, 300); never executed (the execution status of this line is deduced): scrollTo(pos, 300); | - |
669 | } | 0 |
670 | | - |
671 | /*! \overload | - |
672 | | - |
673 | This version will reach its destination position in \a scrollTime milliseconds. | - |
674 | */ | - |
675 | void QScroller::scrollTo(const QPointF &pos, int scrollTime) | - |
676 | { | - |
677 | Q_D(QScroller); executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
678 | | - |
679 | if (d->state == Pressed || d->state == Dragging ) partially evaluated: d->state == Pressed no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: d->state == Dragging no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
680 | return; | 0 |
681 | | - |
682 | // no need to resend a prepare event if we are already scrolling | - |
683 | if (d->state == Inactive && !d->prepareScrolling(QPointF())) partially evaluated: d->state == Inactive yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: !d->prepareScrolling(QPointF()) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
684 | return; | 0 |
685 | | - |
686 | QPointF newpos = clampToRect(pos, d->contentPosRange); executed (the execution status of this line is deduced): QPointF newpos = clampToRect(pos, d->contentPosRange); | - |
687 | qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal); executed (the execution status of this line is deduced): qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal); | - |
688 | qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical); executed (the execution status of this line is deduced): qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical); | - |
689 | if (!qIsNaN(snapX)) partially evaluated: !qIsNaN(snapX) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
690 | newpos.setX(snapX); never executed: newpos.setX(snapX); | 0 |
691 | if (!qIsNaN(snapY)) partially evaluated: !qIsNaN(snapY) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
692 | newpos.setY(snapY); never executed: newpos.setY(snapY); | 0 |
693 | | - |
694 | qScrollerDebug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])"; never executed: QMessageLogger("util/qscroller.cpp", 694, __PRETTY_FUNCTION__).debug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
695 | | - |
696 | if (newpos == d->contentPosition + d->overshootPosition) partially evaluated: newpos == d->contentPosition + d->overshootPosition no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
697 | return; | 0 |
698 | | - |
699 | QPointF vel = velocity(); executed (the execution status of this line is deduced): QPointF vel = velocity(); | - |
700 | | - |
701 | if (scrollTime < 0) partially evaluated: scrollTime < 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
702 | scrollTime = 0; never executed: scrollTime = 0; | 0 |
703 | qreal time = qreal(scrollTime) / 1000; executed (the execution status of this line is deduced): qreal time = qreal(scrollTime) / 1000; | - |
704 | | - |
705 | d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo); executed (the execution status of this line is deduced): d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo); | - |
706 | d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo); executed (the execution status of this line is deduced): d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo); | - |
707 | | - |
708 | if (!scrollTime) partially evaluated: !scrollTime no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
709 | d->setContentPositionHelperScrolling(); never executed: d->setContentPositionHelperScrolling(); | 0 |
710 | d->setState(scrollTime ? Scrolling : Inactive); executed (the execution status of this line is deduced): d->setState(scrollTime ? Scrolling : Inactive); | - |
711 | } executed: } Execution Count:1 | 1 |
712 | | - |
713 | /*! | - |
714 | Starts scrolling so that the rectangle \a rect is visible inside the | - |
715 | viewport with additional margins specified in pixels by \a xmargin and \a ymargin around | - |
716 | the rect. | - |
717 | | - |
718 | In cases where it is not possible to fit the rect plus margins inside the viewport the contents | - |
719 | are scrolled so that as much as possible is visible from \a rect. | - |
720 | | - |
721 | The scrolling speed is calculated so that the given position is reached after a platform-defined | - |
722 | time span. | - |
723 | | - |
724 | This function performs the actual scrolling by calling scrollTo(). | - |
725 | | - |
726 | \sa scrollTo() | - |
727 | */ | - |
728 | void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin) | - |
729 | { | - |
730 | // we could make this adjustable via QScrollerProperties | - |
731 | ensureVisible(rect, xmargin, ymargin, 1000); never executed (the execution status of this line is deduced): ensureVisible(rect, xmargin, ymargin, 1000); | - |
732 | } | 0 |
733 | | - |
734 | /*! \overload | - |
735 | | - |
736 | This version will reach its destination position in \a scrollTime milliseconds. | - |
737 | */ | - |
738 | void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime) | - |
739 | { | - |
740 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
741 | | - |
742 | if (d->state == Pressed || d->state == Dragging ) never evaluated: d->state == Pressed never evaluated: d->state == Dragging | 0 |
743 | return; | 0 |
744 | | - |
745 | if (d->state == Inactive && !d->prepareScrolling(QPointF())) never evaluated: d->state == Inactive never evaluated: !d->prepareScrolling(QPointF()) | 0 |
746 | return; | 0 |
747 | | - |
748 | // -- calculate the current pos (or the position after the current scroll) | - |
749 | QPointF startPos = d->contentPosition + d->overshootPosition; never executed (the execution status of this line is deduced): QPointF startPos = d->contentPosition + d->overshootPosition; | - |
750 | startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), never executed (the execution status of this line is deduced): startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), | - |
751 | d->scrollingSegmentsEndPos(Qt::Vertical)); never executed (the execution status of this line is deduced): d->scrollingSegmentsEndPos(Qt::Vertical)); | - |
752 | | - |
753 | QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin, never executed (the execution status of this line is deduced): QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin, | - |
754 | rect.width() + 2 * xmargin, rect.height() + 2 * ymargin); never executed (the execution status of this line is deduced): rect.width() + 2 * xmargin, rect.height() + 2 * ymargin); | - |
755 | | - |
756 | QSizeF visible = d->viewportSize; never executed (the execution status of this line is deduced): QSizeF visible = d->viewportSize; | - |
757 | QRectF visibleRect(startPos, visible); never executed (the execution status of this line is deduced): QRectF visibleRect(startPos, visible); | - |
758 | | - |
759 | qScrollerDebug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])"; never executed: QMessageLogger("util/qscroller.cpp", 759, __PRETTY_FUNCTION__).debug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])"; never evaluated: false | 0 |
760 | qScrollerDebug() << " --> content position:" << d->contentPosition; never executed: QMessageLogger("util/qscroller.cpp", 760, __PRETTY_FUNCTION__).debug() << " --> content position:" << d->contentPosition; never evaluated: false | 0 |
761 | | - |
762 | if (visibleRect.contains(marginRect)) never evaluated: visibleRect.contains(marginRect) | 0 |
763 | return; | 0 |
764 | | - |
765 | QPointF newPos = startPos; never executed (the execution status of this line is deduced): QPointF newPos = startPos; | - |
766 | | - |
767 | if (visibleRect.width() < rect.width()) { never evaluated: visibleRect.width() < rect.width() | 0 |
768 | // at least try to move the rect into view | - |
769 | if (rect.left() > visibleRect.left()) never evaluated: rect.left() > visibleRect.left() | 0 |
770 | newPos.setX(rect.left()); never executed: newPos.setX(rect.left()); | 0 |
771 | else if (rect.right() < visibleRect.right()) never evaluated: rect.right() < visibleRect.right() | 0 |
772 | newPos.setX(rect.right() - visible.width()); never executed: newPos.setX(rect.right() - visible.width()); | 0 |
773 | | - |
774 | } else if (visibleRect.width() < marginRect.width()) { never evaluated: visibleRect.width() < marginRect.width() | 0 |
775 | newPos.setX(rect.center().x() - visibleRect.width() / 2); never executed (the execution status of this line is deduced): newPos.setX(rect.center().x() - visibleRect.width() / 2); | - |
776 | } else if (marginRect.left() > visibleRect.left()) { never executed: } never evaluated: marginRect.left() > visibleRect.left() | 0 |
777 | newPos.setX(marginRect.left()); never executed (the execution status of this line is deduced): newPos.setX(marginRect.left()); | - |
778 | } else if (marginRect.right() < visibleRect.right()) { never executed: } never evaluated: marginRect.right() < visibleRect.right() | 0 |
779 | newPos.setX(marginRect.right() - visible.width()); never executed (the execution status of this line is deduced): newPos.setX(marginRect.right() - visible.width()); | - |
780 | } | 0 |
781 | | - |
782 | if (visibleRect.height() < rect.height()) { never evaluated: visibleRect.height() < rect.height() | 0 |
783 | // at least try to move the rect into view | - |
784 | if (rect.top() > visibleRect.top()) never evaluated: rect.top() > visibleRect.top() | 0 |
785 | newPos.setX(rect.top()); never executed: newPos.setX(rect.top()); | 0 |
786 | else if (rect.bottom() < visibleRect.bottom()) never evaluated: rect.bottom() < visibleRect.bottom() | 0 |
787 | newPos.setX(rect.bottom() - visible.height()); never executed: newPos.setX(rect.bottom() - visible.height()); | 0 |
788 | | - |
789 | } else if (visibleRect.height() < marginRect.height()) { never evaluated: visibleRect.height() < marginRect.height() | 0 |
790 | newPos.setY(rect.center().y() - visibleRect.height() / 2); never executed (the execution status of this line is deduced): newPos.setY(rect.center().y() - visibleRect.height() / 2); | - |
791 | } else if (marginRect.top() > visibleRect.top()) { never executed: } never evaluated: marginRect.top() > visibleRect.top() | 0 |
792 | newPos.setY(marginRect.top()); never executed (the execution status of this line is deduced): newPos.setY(marginRect.top()); | - |
793 | } else if (marginRect.bottom() < visibleRect.bottom()) { never executed: } never evaluated: marginRect.bottom() < visibleRect.bottom() | 0 |
794 | newPos.setY(marginRect.bottom() - visible.height()); never executed (the execution status of this line is deduced): newPos.setY(marginRect.bottom() - visible.height()); | - |
795 | } | 0 |
796 | | - |
797 | // clamp to maximum content position | - |
798 | newPos = clampToRect(newPos, d->contentPosRange); never executed (the execution status of this line is deduced): newPos = clampToRect(newPos, d->contentPosRange); | - |
799 | if (newPos == startPos) never evaluated: newPos == startPos | 0 |
800 | return; | 0 |
801 | | - |
802 | scrollTo(newPos, scrollTime); never executed (the execution status of this line is deduced): scrollTo(newPos, scrollTime); | - |
803 | } | 0 |
804 | | - |
805 | /*! This function resends the QScrollPrepareEvent. | - |
806 | Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller. | - |
807 | This allows the receiver to re-set content position and content size while | - |
808 | scrolling. | - |
809 | Calling this function while in the Inactive state is useless as the prepare event | - |
810 | is sent again before scrolling starts. | - |
811 | */ | - |
812 | void QScroller::resendPrepareEvent() | - |
813 | { | - |
814 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
815 | d->prepareScrolling(d->pressPosition); never executed (the execution status of this line is deduced): d->prepareScrolling(d->pressPosition); | - |
816 | } | 0 |
817 | | - |
818 | /*! Set the snap positions for the horizontal axis to a list of \a positions. | - |
819 | This overwrites all previously set snap positions and also a previously | - |
820 | set snapping interval. | - |
821 | Snapping can be deactivated by setting an empty list of positions. | - |
822 | */ | - |
823 | void QScroller::setSnapPositionsX(const QList<qreal> &positions) | - |
824 | { | - |
825 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
826 | d->snapPositionsX = positions; never executed (the execution status of this line is deduced): d->snapPositionsX = positions; | - |
827 | d->snapIntervalX = 0.0; never executed (the execution status of this line is deduced): d->snapIntervalX = 0.0; | - |
828 | | - |
829 | d->recalcScrollingSegments(); never executed (the execution status of this line is deduced): d->recalcScrollingSegments(); | - |
830 | } | 0 |
831 | | - |
832 | /*! Set the snap positions for the horizontal axis to regular spaced intervals. | - |
833 | The first snap position is at \a first. The next at \a first + \a interval. | - |
834 | This can be used to implement a list header. | - |
835 | This overwrites all previously set snap positions and also a previously | - |
836 | set snapping interval. | - |
837 | Snapping can be deactivated by setting an interval of 0.0 | - |
838 | */ | - |
839 | void QScroller::setSnapPositionsX(qreal first, qreal interval) | - |
840 | { | - |
841 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
842 | d->snapFirstX = first; never executed (the execution status of this line is deduced): d->snapFirstX = first; | - |
843 | d->snapIntervalX = interval; never executed (the execution status of this line is deduced): d->snapIntervalX = interval; | - |
844 | d->snapPositionsX.clear(); never executed (the execution status of this line is deduced): d->snapPositionsX.clear(); | - |
845 | | - |
846 | d->recalcScrollingSegments(); never executed (the execution status of this line is deduced): d->recalcScrollingSegments(); | - |
847 | } | 0 |
848 | | - |
849 | /*! Set the snap positions for the vertical axis to a list of \a positions. | - |
850 | This overwrites all previously set snap positions and also a previously | - |
851 | set snapping interval. | - |
852 | Snapping can be deactivated by setting an empty list of positions. | - |
853 | */ | - |
854 | void QScroller::setSnapPositionsY(const QList<qreal> &positions) | - |
855 | { | - |
856 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
857 | d->snapPositionsY = positions; never executed (the execution status of this line is deduced): d->snapPositionsY = positions; | - |
858 | d->snapIntervalY = 0.0; never executed (the execution status of this line is deduced): d->snapIntervalY = 0.0; | - |
859 | | - |
860 | d->recalcScrollingSegments(); never executed (the execution status of this line is deduced): d->recalcScrollingSegments(); | - |
861 | } | 0 |
862 | | - |
863 | /*! Set the snap positions for the vertical axis to regular spaced intervals. | - |
864 | The first snap position is at \a first. The next at \a first + \a interval. | - |
865 | This overwrites all previously set snap positions and also a previously | - |
866 | set snapping interval. | - |
867 | Snapping can be deactivated by setting an interval of 0.0 | - |
868 | */ | - |
869 | void QScroller::setSnapPositionsY(qreal first, qreal interval) | - |
870 | { | - |
871 | Q_D(QScroller); never executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
872 | d->snapFirstY = first; never executed (the execution status of this line is deduced): d->snapFirstY = first; | - |
873 | d->snapIntervalY = interval; never executed (the execution status of this line is deduced): d->snapIntervalY = interval; | - |
874 | d->snapPositionsY.clear(); never executed (the execution status of this line is deduced): d->snapPositionsY.clear(); | - |
875 | | - |
876 | d->recalcScrollingSegments(); never executed (the execution status of this line is deduced): d->recalcScrollingSegments(); | - |
877 | } | 0 |
878 | | - |
879 | | - |
880 | | - |
881 | // -------------- private ------------ | - |
882 | | - |
883 | QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target) | - |
884 | : target(_target) | - |
885 | #ifndef QT_NO_GESTURES | - |
886 | , recognizer(0) | - |
887 | , recognizerType(Qt::CustomGesture) | - |
888 | #endif | - |
889 | , state(QScroller::Inactive) | - |
890 | , firstScroll(true) | - |
891 | , pressTimestamp(0) | - |
892 | , lastTimestamp(0) | - |
893 | , snapFirstX(-1.0) | - |
894 | , snapIntervalX(0.0) | - |
895 | , snapFirstY(-1.0) | - |
896 | , snapIntervalY(0.0) | - |
897 | #ifndef QT_NO_ANIMATION | - |
898 | , scrollTimer(new QScrollTimer(this)) | - |
899 | #endif | - |
900 | , q_ptr(q) | - |
901 | { | - |
902 | connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed())); executed (the execution status of this line is deduced): connect(target, "2""destroyed(QObject*)", this, "1""targetDestroyed()"); | - |
903 | } executed: } Execution Count:8 | 8 |
904 | | - |
905 | void QScrollerPrivate::init() | - |
906 | { | - |
907 | setDpiFromWidget(0); executed (the execution status of this line is deduced): setDpiFromWidget(0); | - |
908 | monotonicTimer.start(); executed (the execution status of this line is deduced): monotonicTimer.start(); | - |
909 | } executed: } Execution Count:8 | 8 |
910 | | - |
911 | void QScrollerPrivate::sendEvent(QObject *o, QEvent *e) | - |
912 | { | - |
913 | qt_sendSpontaneousEvent(o, e); executed (the execution status of this line is deduced): qt_sendSpontaneousEvent(o, e); | - |
914 | } executed: } Execution Count:151 | 151 |
915 | | - |
916 | const char *QScrollerPrivate::stateName(QScroller::State state) | - |
917 | { | - |
918 | switch (state) { | - |
919 | case QScroller::Inactive: return "inactive"; never executed: return "inactive"; | 0 |
920 | case QScroller::Pressed: return "pressed"; never executed: return "pressed"; | 0 |
921 | case QScroller::Dragging: return "dragging"; never executed: return "dragging"; | 0 |
922 | case QScroller::Scrolling: return "scrolling"; never executed: return "scrolling"; | 0 |
923 | default: return "(invalid)"; never executed: return "(invalid)"; | 0 |
924 | } | - |
925 | } | 0 |
926 | | - |
927 | const char *QScrollerPrivate::inputName(QScroller::Input input) | - |
928 | { | - |
929 | switch (input) { | - |
930 | case QScroller::InputPress: return "press"; never executed: return "press"; | 0 |
931 | case QScroller::InputMove: return "move"; never executed: return "move"; | 0 |
932 | case QScroller::InputRelease: return "release"; never executed: return "release"; | 0 |
933 | default: return "(invalid)"; never executed: return "(invalid)"; | 0 |
934 | } | - |
935 | } | 0 |
936 | | - |
937 | void QScrollerPrivate::targetDestroyed() | - |
938 | { | - |
939 | #ifndef QT_NO_ANIMATION | - |
940 | scrollTimer->stop(); executed (the execution status of this line is deduced): scrollTimer->stop(); | - |
941 | #endif | - |
942 | delete q_ptr; executed (the execution status of this line is deduced): delete q_ptr; | - |
943 | } executed: } Execution Count:8 | 8 |
944 | | - |
945 | void QScrollerPrivate::timerTick() | - |
946 | { | - |
947 | struct timerevent { executed (the execution status of this line is deduced): struct timerevent { | - |
948 | QScroller::State state; executed (the execution status of this line is deduced): QScroller::State state; | - |
949 | typedef void (QScrollerPrivate::*timerhandler_t)(); executed (the execution status of this line is deduced): typedef void (QScrollerPrivate::*timerhandler_t)(); | - |
950 | timerhandler_t handler; executed (the execution status of this line is deduced): timerhandler_t handler; | - |
951 | }; executed (the execution status of this line is deduced): }; | - |
952 | | - |
953 | timerevent timerevents[] = { executed (the execution status of this line is deduced): timerevent timerevents[] = { | - |
954 | { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging }, executed (the execution status of this line is deduced): { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging }, | - |
955 | { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling }, executed (the execution status of this line is deduced): { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling }, | - |
956 | }; executed (the execution status of this line is deduced): }; | - |
957 | | - |
958 | for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) { partially evaluated: i < int(sizeof(timerevents) / sizeof(*timerevents)) yes Evaluation Count:269 | no Evaluation Count:0 |
| 0-269 |
959 | timerevent *te = timerevents + i; executed (the execution status of this line is deduced): timerevent *te = timerevents + i; | - |
960 | | - |
961 | if (state == te->state) { evaluated: state == te->state yes Evaluation Count:137 | yes Evaluation Count:132 |
| 132-137 |
962 | (this->*te->handler)(); executed (the execution status of this line is deduced): (this->*te->handler)(); | - |
963 | return; executed: return; Execution Count:137 | 137 |
964 | } | - |
965 | } executed: } Execution Count:132 | 132 |
966 | | - |
967 | #ifndef QT_NO_ANIMATION | - |
968 | scrollTimer->stop(); never executed (the execution status of this line is deduced): scrollTimer->stop(); | - |
969 | #endif | - |
970 | } | 0 |
971 | | - |
972 | /*! | - |
973 | This function is used by gesture recognizers to inform the scroller about a new input event. | - |
974 | The scroller changes its internal state() according to the input event and its attached | - |
975 | scroller properties. The scroller doesn't distinguish between the kind of input device the | - |
976 | event came from. Therefore the event needs to be split into the \a input type, a \a position and a | - |
977 | milli-second \a timestamp. The \a position needs to be in the target's coordinate system. | - |
978 | | - |
979 | The return value is \c true if the event should be consumed by the calling filter or \c false | - |
980 | if the event should be forwarded to the control. | - |
981 | | - |
982 | \note Using grabGesture() should be sufficient for most use cases. | - |
983 | */ | - |
984 | bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp) | - |
985 | { | - |
986 | Q_D(QScroller); executed (the execution status of this line is deduced): QScrollerPrivate * const d = d_func(); | - |
987 | | - |
988 | qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")"; never executed: QMessageLogger("util/qscroller.cpp", 988, __PRETTY_FUNCTION__).debug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
989 | struct statechange { executed (the execution status of this line is deduced): struct statechange { | - |
990 | State state; executed (the execution status of this line is deduced): State state; | - |
991 | Input input; executed (the execution status of this line is deduced): Input input; | - |
992 | typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp); executed (the execution status of this line is deduced): typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp); | - |
993 | inputhandler_t handler; executed (the execution status of this line is deduced): inputhandler_t handler; | - |
994 | }; executed (the execution status of this line is deduced): }; | - |
995 | | - |
996 | statechange statechanges[] = { executed (the execution status of this line is deduced): statechange statechanges[] = { | - |
997 | { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive }, executed (the execution status of this line is deduced): { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive }, | - |
998 | { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed }, executed (the execution status of this line is deduced): { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed }, | - |
999 | { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed }, executed (the execution status of this line is deduced): { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed }, | - |
1000 | { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging }, executed (the execution status of this line is deduced): { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging }, | - |
1001 | { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging }, executed (the execution status of this line is deduced): { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging }, | - |
1002 | { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling } executed (the execution status of this line is deduced): { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling } | - |
1003 | }; executed (the execution status of this line is deduced): }; | - |
1004 | | - |
1005 | for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) { evaluated: i < int(sizeof(statechanges) / sizeof(*statechanges)) yes Evaluation Count:58 | yes Evaluation Count:2 |
| 2-58 |
1006 | statechange *sc = statechanges + i; executed (the execution status of this line is deduced): statechange *sc = statechanges + i; | - |
1007 | | - |
1008 | if (d->state == sc->state && input == sc->input) evaluated: d->state == sc->state yes Evaluation Count:26 | yes Evaluation Count:32 |
evaluated: input == sc->input yes Evaluation Count:19 | yes Evaluation Count:7 |
| 7-32 |
1009 | return (d->*sc->handler)(position - d->overshootPosition, timestamp); executed: return (d->*sc->handler)(position - d->overshootPosition, timestamp); Execution Count:19 | 19 |
1010 | } executed: } Execution Count:39 | 39 |
1011 | return false; executed: return false; Execution Count:2 | 2 |
1012 | } | - |
1013 | | - |
1014 | #if !defined(Q_WS_MAC) | - |
1015 | // the Mac version is implemented in qscroller_mac.mm | - |
1016 | | - |
1017 | QPointF QScrollerPrivate::realDpi(int screen) | - |
1018 | { | - |
1019 | # if defined(Q_WS_X11) && !defined(QT_NO_XRANDR) | - |
1020 | if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) { | - |
1021 | int nsizes = 0; | - |
1022 | // QDesktopWidget is based on Xinerama screens, which do not always | - |
1023 | // correspond to RandR screens: NVidia's TwinView e.g. will show up | - |
1024 | // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen. | - |
1025 | // (although with the combined size of the Xinerama screens). | - |
1026 | // Additionally, libXrandr will simply crash when calling XRRSizes | - |
1027 | // for (the non-existent) screen 1 in this scenario. | - |
1028 | Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen); | - |
1029 | int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1; | - |
1030 | | - |
1031 | XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes); | - |
1032 | if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) { | - |
1033 | qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), | - |
1034 | qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); | - |
1035 | return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), | - |
1036 | qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); | - |
1037 | } | - |
1038 | } | - |
1039 | # endif | - |
1040 | | - |
1041 | QWidget *w = QApplication::desktop()->screen(screen); executed (the execution status of this line is deduced): QWidget *w = QApplication::desktop()->screen(screen); | - |
1042 | return QPointF(w->physicalDpiX(), w->physicalDpiY()); executed: return QPointF(w->physicalDpiX(), w->physicalDpiY()); Execution Count:16 | 16 |
1043 | } | - |
1044 | | - |
1045 | #endif // !Q_WS_MAC | - |
1046 | | - |
1047 | | - |
1048 | /*! \internal | - |
1049 | Returns the resolution of the used screen. | - |
1050 | */ | - |
1051 | QPointF QScrollerPrivate::dpi() const | - |
1052 | { | - |
1053 | return pixelPerMeter * qreal(0.0254); never executed: return pixelPerMeter * qreal(0.0254); | 0 |
1054 | } | - |
1055 | | - |
1056 | /*! \internal | - |
1057 | Sets the resolution used for scrolling. | - |
1058 | This resolution is only used by the kinetic scroller. If you change this | - |
1059 | then the scroller will behave quite different as a lot of the values are | - |
1060 | given in physical distances (millimeter). | - |
1061 | */ | - |
1062 | void QScrollerPrivate::setDpi(const QPointF &dpi) | - |
1063 | { | - |
1064 | pixelPerMeter = dpi / qreal(0.0254); executed (the execution status of this line is deduced): pixelPerMeter = dpi / qreal(0.0254); | - |
1065 | } executed: } Execution Count:16 | 16 |
1066 | | - |
1067 | /*! \internal | - |
1068 | Sets the dpi used for scrolling to the value of the widget. | - |
1069 | */ | - |
1070 | void QScrollerPrivate::setDpiFromWidget(QWidget *widget) | - |
1071 | { | - |
1072 | QDesktopWidget *dw = QApplication::desktop(); executed (the execution status of this line is deduced): QDesktopWidget *dw = QApplication::desktop(); | - |
1073 | setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen())); executed (the execution status of this line is deduced): setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen())); | - |
1074 | } executed: } Execution Count:16 | 16 |
1075 | | - |
1076 | /*! \internal | - |
1077 | Updates the velocity during dragging. | - |
1078 | Sets releaseVelocity. | - |
1079 | */ | - |
1080 | void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime) | - |
1081 | { | - |
1082 | if (deltaTime <= 0) partially evaluated: deltaTime <= 0 no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1083 | return; | 0 |
1084 | | - |
1085 | Q_Q(QScroller); executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1086 | QPointF ppm = q->pixelPerMeter(); executed (the execution status of this line is deduced): QPointF ppm = q->pixelPerMeter(); | - |
1087 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1088 | QPointF deltaPixel = deltaPixelRaw; executed (the execution status of this line is deduced): QPointF deltaPixel = deltaPixelRaw; | - |
1089 | | - |
1090 | qScrollerDebug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])"; never executed: QMessageLogger("util/qscroller.cpp", 1090, __PRETTY_FUNCTION__).debug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1091 | | - |
1092 | // faster than 2.5mm/ms seems bogus (that would be a screen height in ~20 ms) | - |
1093 | if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5)) partially evaluated: ((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1094 | 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 |
1095 | | - |
1096 | QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm; executed (the execution status of this line is deduced): QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm; | - |
1097 | // around 95% of all updates are in the [1..50] ms range, so make sure | - |
1098 | // to scale the smoothing factor over that range: this way a 50ms update | - |
1099 | // will have full impact, while 5ms update will only have a 10% impact. | - |
1100 | qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50); executed (the execution status of this line is deduced): qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50); | - |
1101 | | - |
1102 | // only smooth if we already have a release velocity and only if the | - |
1103 | // user hasn't stopped to move his finger for more than 100ms | - |
1104 | if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) { evaluated: (releaseVelocity != QPointF(0, 0)) yes Evaluation Count:5 | yes Evaluation Count:5 |
partially evaluated: (deltaTime < 100) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1105 | qScrollerDebug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing); never executed: QMessageLogger("util/qscroller.cpp", 1105, __PRETTY_FUNCTION__).debug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1106 | // smooth x or y only if the new velocity is either 0 or at least in | - |
1107 | // the same direction of the release velocity | - |
1108 | if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x()))) partially evaluated: !newv.x() no Evaluation Count:0 | yes Evaluation Count:5 |
partially evaluated: (qSign(releaseVelocity.x()) == qSign(newv.x())) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1109 | newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing)); executed: newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing)); Execution Count:5 | 5 |
1110 | if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y()))) evaluated: !newv.y() yes Evaluation Count:4 | yes Evaluation Count:1 |
partially evaluated: (qSign(releaseVelocity.y()) == qSign(newv.y())) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-4 |
1111 | newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing)); executed: newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing)); Execution Count:5 | 5 |
1112 | } else executed: } Execution Count:5 | 5 |
1113 | qScrollerDebug() << "NO SMOOTHING to " << newv; never executed: QMessageLogger("util/qscroller.cpp", 1113, __PRETTY_FUNCTION__).debug() << "NO SMOOTHING to " << newv; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1114 | | - |
1115 | releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity)); executed (the execution status of this line is deduced): releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity)); | - |
1116 | releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity)); executed (the execution status of this line is deduced): releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity)); | - |
1117 | | - |
1118 | qScrollerDebug() << " --> new velocity:" << releaseVelocity; never executed: QMessageLogger("util/qscroller.cpp", 1118, __PRETTY_FUNCTION__).debug() << " --> new velocity:" << releaseVelocity; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1119 | } executed: } Execution Count:10 | 10 |
1120 | | - |
1121 | void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation) | - |
1122 | { | - |
1123 | if (startPos == stopPos || deltaPos == 0) partially evaluated: startPos == stopPos no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: deltaPos == 0 no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1124 | return; | 0 |
1125 | | - |
1126 | ScrollSegment s; executed (the execution status of this line is deduced): ScrollSegment s; | - |
1127 | if (orientation == Qt::Horizontal && !xSegments.isEmpty()) evaluated: orientation == Qt::Horizontal yes Evaluation Count:9 | yes Evaluation Count:4 |
evaluated: !xSegments.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:6 |
| 3-9 |
1128 | s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress; executed: s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress; Execution Count:3 | 3 |
1129 | else if (orientation == Qt::Vertical && !ySegments.isEmpty()) evaluated: orientation == Qt::Vertical yes Evaluation Count:4 | yes Evaluation Count:6 |
evaluated: !ySegments.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2-6 |
1130 | s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress; executed: s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress; Execution Count:2 | 2 |
1131 | else | - |
1132 | s.startTime = monotonicTimer.elapsed(); executed: s.startTime = monotonicTimer.elapsed(); Execution Count:8 | 8 |
1133 | | - |
1134 | s.startPos = startPos; executed (the execution status of this line is deduced): s.startPos = startPos; | - |
1135 | s.deltaPos = deltaPos; executed (the execution status of this line is deduced): s.deltaPos = deltaPos; | - |
1136 | s.stopPos = stopPos; executed (the execution status of this line is deduced): s.stopPos = stopPos; | - |
1137 | s.deltaTime = deltaTime * 1000; executed (the execution status of this line is deduced): s.deltaTime = deltaTime * 1000; | - |
1138 | s.stopProgress = stopProgress; executed (the execution status of this line is deduced): s.stopProgress = stopProgress; | - |
1139 | s.curve.setType(curve); executed (the execution status of this line is deduced): s.curve.setType(curve); | - |
1140 | s.type = type; executed (the execution status of this line is deduced): s.type = type; | - |
1141 | | - |
1142 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-9 |
1143 | xSegments.enqueue(s); executed: xSegments.enqueue(s); Execution Count:9 | 9 |
1144 | else | - |
1145 | ySegments.enqueue(s); executed: ySegments.enqueue(s); Execution Count:4 | 4 |
1146 | | - |
1147 | qScrollerDebug() << "+++ Added a new ScrollSegment: " << s; never executed: QMessageLogger("util/qscroller.cpp", 1147, __PRETTY_FUNCTION__).debug() << "+++ Added a new ScrollSegment: " << s; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1148 | } executed: } Execution Count:13 | 13 |
1149 | | - |
1150 | | - |
1151 | /*! \internal | - |
1152 | Clears the old segments and recalculates them if the current segments are not longer valid | - |
1153 | */ | - |
1154 | void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc) | - |
1155 | { | - |
1156 | Q_Q(QScroller); executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1157 | QPointF ppm = q->pixelPerMeter(); executed (the execution status of this line is deduced): QPointF ppm = q->pixelPerMeter(); | - |
1158 | | - |
1159 | releaseVelocity = q->velocity(); executed (the execution status of this line is deduced): releaseVelocity = q->velocity(); | - |
1160 | | - |
1161 | if (forceRecalc || partially evaluated: forceRecalc yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1162 | !scrollingSegmentsValid(Qt::Horizontal) || never evaluated: !scrollingSegmentsValid(Qt::Horizontal) | 0 |
1163 | !scrollingSegmentsValid(Qt::Vertical)) never evaluated: !scrollingSegmentsValid(Qt::Vertical) | 0 |
1164 | createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); executed: createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); Execution Count:4 | 4 |
1165 | } executed: } Execution Count:4 | 4 |
1166 | | - |
1167 | /*! \internal | - |
1168 | Returns the end position after the current scroll has finished. | - |
1169 | */ | - |
1170 | qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const | - |
1171 | { | - |
1172 | if (orientation == Qt::Horizontal) { never evaluated: orientation == Qt::Horizontal | 0 |
1173 | if (xSegments.isEmpty()) never evaluated: xSegments.isEmpty() | 0 |
1174 | return contentPosition.x() + overshootPosition.x(); never executed: return contentPosition.x() + overshootPosition.x(); | 0 |
1175 | else | - |
1176 | return xSegments.last().stopPos; never executed: return xSegments.last().stopPos; | 0 |
1177 | } else { | - |
1178 | if (ySegments.isEmpty()) never evaluated: ySegments.isEmpty() | 0 |
1179 | return contentPosition.y() + overshootPosition.y(); never executed: return contentPosition.y() + overshootPosition.y(); | 0 |
1180 | else | - |
1181 | return ySegments.last().stopPos; never executed: return ySegments.last().stopPos; | 0 |
1182 | } | - |
1183 | } | - |
1184 | | - |
1185 | /*! \internal | - |
1186 | Checks if the scroller segment end in a valid position. | - |
1187 | */ | - |
1188 | bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation) | - |
1189 | { | - |
1190 | QQueue<ScrollSegment> *segments; never executed (the execution status of this line is deduced): QQueue<ScrollSegment> *segments; | - |
1191 | qreal minPos; never executed (the execution status of this line is deduced): qreal minPos; | - |
1192 | qreal maxPos; never executed (the execution status of this line is deduced): qreal maxPos; | - |
1193 | | - |
1194 | if (orientation == Qt::Horizontal) { never evaluated: orientation == Qt::Horizontal | 0 |
1195 | segments = &xSegments; never executed (the execution status of this line is deduced): segments = &xSegments; | - |
1196 | minPos = contentPosRange.left(); never executed (the execution status of this line is deduced): minPos = contentPosRange.left(); | - |
1197 | maxPos = contentPosRange.right(); never executed (the execution status of this line is deduced): maxPos = contentPosRange.right(); | - |
1198 | } else { | 0 |
1199 | segments = &ySegments; never executed (the execution status of this line is deduced): segments = &ySegments; | - |
1200 | minPos = contentPosRange.top(); never executed (the execution status of this line is deduced): minPos = contentPosRange.top(); | - |
1201 | maxPos = contentPosRange.bottom(); never executed (the execution status of this line is deduced): maxPos = contentPosRange.bottom(); | - |
1202 | } | 0 |
1203 | | - |
1204 | if (segments->isEmpty()) never evaluated: segments->isEmpty() | 0 |
1205 | return true; never executed: return true; | 0 |
1206 | | - |
1207 | const ScrollSegment &last = segments->last(); never executed (the execution status of this line is deduced): const ScrollSegment &last = segments->last(); | - |
1208 | qreal stopPos = last.stopPos; never executed (the execution status of this line is deduced): qreal stopPos = last.stopPos; | - |
1209 | | - |
1210 | if (last.type == ScrollTypeScrollTo) never evaluated: last.type == ScrollTypeScrollTo | 0 |
1211 | return true; // scrollTo is always valid never executed: return true; | 0 |
1212 | | - |
1213 | if (last.type == ScrollTypeOvershoot && never evaluated: last.type == ScrollTypeOvershoot | 0 |
1214 | (stopPos != minPos && stopPos != maxPos)) never evaluated: stopPos != minPos never evaluated: stopPos != maxPos | 0 |
1215 | return false; never executed: return false; | 0 |
1216 | | - |
1217 | if (stopPos < minPos || stopPos > maxPos) never evaluated: stopPos < minPos never evaluated: stopPos > maxPos | 0 |
1218 | return false; never executed: return false; | 0 |
1219 | | - |
1220 | if (stopPos == minPos || stopPos == maxPos) // the begin and the end of the list are always ok never evaluated: stopPos == minPos never evaluated: stopPos == maxPos | 0 |
1221 | return true; never executed: return true; | 0 |
1222 | | - |
1223 | qreal nextSnap = nextSnapPos(stopPos, 0, orientation); never executed (the execution status of this line is deduced): qreal nextSnap = nextSnapPos(stopPos, 0, orientation); | - |
1224 | if (!qIsNaN(nextSnap) && stopPos != nextSnap) never evaluated: !qIsNaN(nextSnap) never evaluated: stopPos != nextSnap | 0 |
1225 | return false; never executed: return false; | 0 |
1226 | | - |
1227 | return true; never executed: return true; | 0 |
1228 | } | - |
1229 | | - |
1230 | /*! \internal | - |
1231 | Creates the sections needed to scroll to the specific \a endPos to the segments queue. | - |
1232 | */ | - |
1233 | void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type) | - |
1234 | { | - |
1235 | Q_UNUSED(v); executed (the execution status of this line is deduced): (void)v;; | - |
1236 | | - |
1237 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1238 | xSegments.clear(); executed: xSegments.clear(); Execution Count:1 | 1 |
1239 | else | - |
1240 | ySegments.clear(); executed: ySegments.clear(); Execution Count:1 | 1 |
1241 | | - |
1242 | qScrollerDebug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation); never executed: QMessageLogger("util/qscroller.cpp", 1242, __PRETTY_FUNCTION__).debug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1243 | | - |
1244 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1245 | | - |
1246 | qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x() evaluated: (orientation == Qt::Horizontal) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1247 | : contentPosition.y() + overshootPosition.y(); executed (the execution status of this line is deduced): : contentPosition.y() + overshootPosition.y(); | - |
1248 | qreal deltaPos = (endPos - startPos) / 2; executed (the execution status of this line is deduced): qreal deltaPos = (endPos - startPos) / 2; | - |
1249 | | - |
1250 | pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation); executed (the execution status of this line is deduced): pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation); | - |
1251 | pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); executed (the execution status of this line is deduced): pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); | - |
1252 | } executed: } Execution Count:2 | 2 |
1253 | | - |
1254 | /*! \internal | - |
1255 | */ | - |
1256 | void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, | - |
1257 | qreal deltaTime, qreal deltaPos, | - |
1258 | Qt::Orientation orientation) | - |
1259 | { | - |
1260 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1261 | | - |
1262 | QScrollerProperties::OvershootPolicy policy; executed (the execution status of this line is deduced): QScrollerProperties::OvershootPolicy policy; | - |
1263 | qreal minPos; executed (the execution status of this line is deduced): qreal minPos; | - |
1264 | qreal maxPos; executed (the execution status of this line is deduced): qreal maxPos; | - |
1265 | qreal viewSize; executed (the execution status of this line is deduced): qreal viewSize; | - |
1266 | | - |
1267 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal yes Evaluation Count:9 | yes Evaluation Count:9 |
| 9 |
1268 | xSegments.clear(); executed (the execution status of this line is deduced): xSegments.clear(); | - |
1269 | policy = sp->hOvershootPolicy; executed (the execution status of this line is deduced): policy = sp->hOvershootPolicy; | - |
1270 | minPos = contentPosRange.left(); executed (the execution status of this line is deduced): minPos = contentPosRange.left(); | - |
1271 | maxPos = contentPosRange.right(); executed (the execution status of this line is deduced): maxPos = contentPosRange.right(); | - |
1272 | viewSize = viewportSize.width(); executed (the execution status of this line is deduced): viewSize = viewportSize.width(); | - |
1273 | } else { executed: } Execution Count:9 | 9 |
1274 | ySegments.clear(); executed (the execution status of this line is deduced): ySegments.clear(); | - |
1275 | policy = sp->vOvershootPolicy; executed (the execution status of this line is deduced): policy = sp->vOvershootPolicy; | - |
1276 | minPos = contentPosRange.top(); executed (the execution status of this line is deduced): minPos = contentPosRange.top(); | - |
1277 | maxPos = contentPosRange.bottom(); executed (the execution status of this line is deduced): maxPos = contentPosRange.bottom(); | - |
1278 | viewSize = viewportSize.height(); executed (the execution status of this line is deduced): viewSize = viewportSize.height(); | - |
1279 | } executed: } Execution Count:9 | 9 |
1280 | | - |
1281 | bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn); executed (the execution status of this line is deduced): bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn); | - |
1282 | bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor; evaluated: (policy == QScrollerProperties::OvershootAlwaysOff) yes Evaluation Count:2 | yes Evaluation Count:16 |
evaluated: !sp->overshootScrollDistanceFactor yes Evaluation Count:4 | yes Evaluation Count:12 |
| 2-16 |
1283 | bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos); evaluated: !noOvershoot yes Evaluation Count:12 | yes Evaluation Count:6 |
evaluated: alwaysOvershoot yes Evaluation Count:2 | yes Evaluation Count:10 |
evaluated: maxPos yes Evaluation Count:8 | yes Evaluation Count:2 |
| 2-12 |
1284 | | - |
1285 | qScrollerDebug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation); never executed: QMessageLogger("util/qscroller.cpp", 1285, __PRETTY_FUNCTION__).debug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1286 | | - |
1287 | qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type(); never executed: QMessageLogger("util/qscroller.cpp", 1287, __PRETTY_FUNCTION__).debug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type(); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1288 | | - |
1289 | qreal endPos = startPos + deltaPos; executed (the execution status of this line is deduced): qreal endPos = startPos + deltaPos; | - |
1290 | | - |
1291 | qScrollerDebug() << " Real Delta:" << deltaPos; never executed: QMessageLogger("util/qscroller.cpp", 1291, __PRETTY_FUNCTION__).debug() << " Real Delta:" << deltaPos; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1292 | | - |
1293 | // -- check if are in overshoot and end in overshoot | - |
1294 | if ((startPos < minPos && endPos < minPos) || evaluated: startPos < minPos yes Evaluation Count:1 | yes Evaluation Count:17 |
partially evaluated: endPos < minPos yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-17 |
1295 | (startPos > maxPos && endPos > maxPos)) { partially evaluated: startPos > maxPos no Evaluation Count:0 | yes Evaluation Count:17 |
never evaluated: endPos > maxPos | 0-17 |
1296 | qreal stopPos = endPos < minPos ? minPos : maxPos; partially evaluated: endPos < minPos yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1297 | qreal oDeltaTime = sp->overshootScrollTime; executed (the execution status of this line is deduced): qreal oDeltaTime = sp->overshootScrollTime; | - |
1298 | | - |
1299 | pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); executed (the execution status of this line is deduced): pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); | - |
1300 | return; executed: return; Execution Count:1 | 1 |
1301 | } | - |
1302 | | - |
1303 | // -- determine snap points | - |
1304 | qreal nextSnap = nextSnapPos(endPos, 0, orientation); executed (the execution status of this line is deduced): qreal nextSnap = nextSnapPos(endPos, 0, orientation); | - |
1305 | qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); executed (the execution status of this line is deduced): qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); | - |
1306 | qreal higherSnapPos = nextSnapPos(startPos, 1, orientation); executed (the execution status of this line is deduced): qreal higherSnapPos = nextSnapPos(startPos, 1, orientation); | - |
1307 | | - |
1308 | qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos; never executed: QMessageLogger("util/qscroller.cpp", 1308, __PRETTY_FUNCTION__).debug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
1309 | | - |
1310 | // - check if we can reach another snap point | - |
1311 | if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos)) partially evaluated: nextSnap > higherSnapPos no Evaluation Count:0 | yes Evaluation Count:17 |
partially evaluated: qIsNaN(higherSnapPos) yes Evaluation Count:17 | no Evaluation Count:0 |
| 0-17 |
1312 | higherSnapPos = nextSnap; executed: higherSnapPos = nextSnap; Execution Count:17 | 17 |
1313 | if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos)) partially evaluated: nextSnap < lowerSnapPos no Evaluation Count:0 | yes Evaluation Count:17 |
partially evaluated: qIsNaN(lowerSnapPos) yes Evaluation Count:17 | no Evaluation Count:0 |
| 0-17 |
1314 | lowerSnapPos = nextSnap; executed: lowerSnapPos = nextSnap; Execution Count:17 | 17 |
1315 | | - |
1316 | if (qAbs(v) < sp->minimumVelocity) { evaluated: qAbs(v) < sp->minimumVelocity yes Evaluation Count:12 | yes Evaluation Count:5 |
| 5-12 |
1317 | | - |
1318 | qScrollerDebug() << "### below minimum Vel" << orientation; never executed: QMessageLogger("util/qscroller.cpp", 1318, __PRETTY_FUNCTION__).debug() << "### below minimum Vel" << orientation; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1319 | | - |
1320 | // - no snap points or already at one | - |
1321 | if (qIsNaN(nextSnap) || nextSnap == startPos) partially evaluated: qIsNaN(nextSnap) yes Evaluation Count:12 | no Evaluation Count:0 |
never evaluated: nextSnap == startPos | 0-12 |
1322 | return; // nothing to do, no scrolling needed. executed: return; Execution Count:12 | 12 |
1323 | | - |
1324 | // - decide which point to use | - |
1325 | | - |
1326 | qreal snapDistance = higherSnapPos - lowerSnapPos; never executed (the execution status of this line is deduced): qreal snapDistance = higherSnapPos - lowerSnapPos; | - |
1327 | | - |
1328 | qreal pressDistance = (orientation == Qt::Horizontal) ? never evaluated: (orientation == Qt::Horizontal) | 0 |
1329 | lastPosition.x() - pressPosition.x() : never executed (the execution status of this line is deduced): lastPosition.x() - pressPosition.x() : | - |
1330 | lastPosition.y() - pressPosition.y(); never executed (the execution status of this line is deduced): lastPosition.y() - pressPosition.y(); | - |
1331 | | - |
1332 | // if not dragged far enough, pick the next snap point. | - |
1333 | if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance) never evaluated: sp->snapPositionRatio == 0.0 never evaluated: qAbs(pressDistance / sp->snapPositionRatio) > snapDistance | 0 |
1334 | endPos = nextSnap; never executed: endPos = nextSnap; | 0 |
1335 | else if (pressDistance < 0.0) never evaluated: pressDistance < 0.0 | 0 |
1336 | endPos = lowerSnapPos; never executed: endPos = lowerSnapPos; | 0 |
1337 | else | - |
1338 | endPos = higherSnapPos; never executed: endPos = higherSnapPos; | 0 |
1339 | | - |
1340 | deltaPos = endPos - startPos; never executed (the execution status of this line is deduced): deltaPos = endPos - startPos; | - |
1341 | qreal midPos = startPos + deltaPos * qreal(0.3); never executed (the execution status of this line is deduced): qreal midPos = startPos + deltaPos * qreal(0.3); | - |
1342 | pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation); never executed (the execution status of this line is deduced): pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation); | - |
1343 | pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation); never executed (the execution status of this line is deduced): pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation); | - |
1344 | return; | 0 |
1345 | } | - |
1346 | | - |
1347 | // - go to the next snappoint if there is one | - |
1348 | if (v > 0 && !qIsNaN(higherSnapPos)) { partially evaluated: v > 0 no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: !qIsNaN(higherSnapPos) | 0-5 |
1349 | // change the time in relation to the changed end position | - |
1350 | if (endPos - startPos) never evaluated: endPos - startPos | 0 |
1351 | deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos)); never executed: deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos)); | 0 |
1352 | if (deltaTime > sp->snapTime) never evaluated: deltaTime > sp->snapTime | 0 |
1353 | deltaTime = sp->snapTime; never executed: deltaTime = sp->snapTime; | 0 |
1354 | endPos = higherSnapPos; never executed (the execution status of this line is deduced): endPos = higherSnapPos; | - |
1355 | | - |
1356 | } else if (v < 0 && !qIsNaN(lowerSnapPos)) { never executed: } partially evaluated: v < 0 yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: !qIsNaN(lowerSnapPos) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1357 | // change the time in relation to the changed end position | - |
1358 | if (endPos - startPos) never evaluated: endPos - startPos | 0 |
1359 | deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos)); never executed: deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos)); | 0 |
1360 | if (deltaTime > sp->snapTime) never evaluated: deltaTime > sp->snapTime | 0 |
1361 | deltaTime = sp->snapTime; never executed: deltaTime = sp->snapTime; | 0 |
1362 | endPos = lowerSnapPos; never executed (the execution status of this line is deduced): endPos = lowerSnapPos; | - |
1363 | | - |
1364 | // -- check if we are overshooting | - |
1365 | } else if (endPos < minPos || endPos > maxPos) { never executed: } partially evaluated: endPos < minPos yes Evaluation Count:5 | no Evaluation Count:0 |
never evaluated: endPos > maxPos | 0-5 |
1366 | qreal stopPos = endPos < minPos ? minPos : maxPos; partially evaluated: endPos < minPos yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1367 | | - |
1368 | qScrollerDebug() << "Overshoot: delta:" << (stopPos - startPos); never executed: QMessageLogger("util/qscroller.cpp", 1368, __PRETTY_FUNCTION__).debug() << "Overshoot: delta:" << (stopPos - startPos); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1369 | | - |
1370 | qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos)); executed (the execution status of this line is deduced): qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos)); | - |
1371 | | - |
1372 | if (!canOvershoot) { evaluated: !canOvershoot yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
1373 | qScrollerDebug() << "Overshoot stopp:" << stopProgress; never executed: QMessageLogger("util/qscroller.cpp", 1373, __PRETTY_FUNCTION__).debug() << "Overshoot stopp:" << stopProgress; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1374 | | - |
1375 | pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation); executed (the execution status of this line is deduced): pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation); | - |
1376 | } else { executed: } Execution Count:2 | 2 |
1377 | qreal oDeltaTime = sp->overshootScrollTime; executed (the execution status of this line is deduced): qreal oDeltaTime = sp->overshootScrollTime; | - |
1378 | qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1)); executed (the execution status of this line is deduced): qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1)); | - |
1379 | qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos; executed (the execution status of this line is deduced): qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos; | - |
1380 | qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor); executed (the execution status of this line is deduced): qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor); | - |
1381 | | - |
1382 | qScrollerDebug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; never executed: QMessageLogger("util/qscroller.cpp", 1382, __PRETTY_FUNCTION__).debug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1383 | | - |
1384 | if (qAbs(oDistance) > qAbs(oMaxDistance)) { partially evaluated: qAbs(oDistance) > qAbs(oMaxDistance) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1385 | oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos)); executed (the execution status of this line is deduced): oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos)); | - |
1386 | oDistance = oMaxDistance; executed (the execution status of this line is deduced): oDistance = oMaxDistance; | - |
1387 | qScrollerDebug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; never executed: QMessageLogger("util/qscroller.cpp", 1387, __PRETTY_FUNCTION__).debug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1388 | } executed: } Execution Count:3 | 3 |
1389 | | - |
1390 | pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation); executed (the execution status of this line is deduced): pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation); | - |
1391 | pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation); executed (the execution status of this line is deduced): pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation); | - |
1392 | } executed: } Execution Count:3 | 3 |
1393 | return; executed: return; Execution Count:5 | 5 |
1394 | } | - |
1395 | | - |
1396 | pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); never executed (the execution status of this line is deduced): pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); | - |
1397 | } | 0 |
1398 | | - |
1399 | | - |
1400 | void QScrollerPrivate::createScrollingSegments(const QPointF &v, | - |
1401 | const QPointF &startPos, | - |
1402 | const QPointF &ppm) | - |
1403 | { | - |
1404 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1405 | | - |
1406 | // This is only correct for QEasingCurve::OutQuad (linear velocity, | - |
1407 | // constant deceleration), but the results look and feel ok for OutExpo | - |
1408 | // and OutSine as well | - |
1409 | | - |
1410 | // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) | - |
1411 | // v(0) = vrelease | - |
1412 | // v(deltaTime) = 0 | - |
1413 | // deltaTime = (2 * vrelease) / (a * differntial(0)) | - |
1414 | | - |
1415 | // pos(t) = integrate(v(t)dt) | - |
1416 | // pos(t) = vrelease * t - 0.5 * a * t * t | - |
1417 | // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime | - |
1418 | // deltaPos = pos(deltaTime) | - |
1419 | | - |
1420 | QVector2D vel(v); executed (the execution status of this line is deduced): QVector2D vel(v); | - |
1421 | qreal deltaTime = (qreal(2) * vel.length()) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); executed (the execution status of this line is deduced): qreal deltaTime = (qreal(2) * vel.length()) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); | - |
1422 | QPointF deltaPos = (vel.normalized() * QVector2D(ppm)).toPointF() * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor; executed (the execution status of this line is deduced): QPointF deltaPos = (vel.normalized() * QVector2D(ppm)).toPointF() * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor; | - |
1423 | | - |
1424 | createScrollingSegments(v.x(), startPos.x(), deltaTime, deltaPos.x(), executed (the execution status of this line is deduced): createScrollingSegments(v.x(), startPos.x(), deltaTime, deltaPos.x(), | - |
1425 | Qt::Horizontal); executed (the execution status of this line is deduced): Qt::Horizontal); | - |
1426 | createScrollingSegments(v.y(), startPos.y(), deltaTime, deltaPos.y(), executed (the execution status of this line is deduced): createScrollingSegments(v.y(), startPos.y(), deltaTime, deltaPos.y(), | - |
1427 | Qt::Vertical); executed (the execution status of this line is deduced): Qt::Vertical); | - |
1428 | } executed: } Execution Count:9 | 9 |
1429 | | - |
1430 | /*! \internal | - |
1431 | Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget. | - |
1432 | Returns true if the scrolling was accepted and a target was returned. | - |
1433 | */ | - |
1434 | bool QScrollerPrivate::prepareScrolling(const QPointF &position) | - |
1435 | { | - |
1436 | QScrollPrepareEvent spe(position); executed (the execution status of this line is deduced): QScrollPrepareEvent spe(position); | - |
1437 | spe.ignore(); executed (the execution status of this line is deduced): spe.ignore(); | - |
1438 | sendEvent(target, &spe); executed (the execution status of this line is deduced): sendEvent(target, &spe); | - |
1439 | | - |
1440 | qScrollerDebug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos(); never executed: QMessageLogger("util/qscroller.cpp", 1440, __PRETTY_FUNCTION__).debug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos(); partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1441 | if (spe.isAccepted()) { partially evaluated: spe.isAccepted() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1442 | QPointF oldContentPos = contentPosition + overshootPosition; executed (the execution status of this line is deduced): QPointF oldContentPos = contentPosition + overshootPosition; | - |
1443 | QPointF contentDelta = spe.contentPos() - oldContentPos; executed (the execution status of this line is deduced): QPointF contentDelta = spe.contentPos() - oldContentPos; | - |
1444 | | - |
1445 | viewportSize = spe.viewportSize(); executed (the execution status of this line is deduced): viewportSize = spe.viewportSize(); | - |
1446 | contentPosRange = spe.contentPosRange(); executed (the execution status of this line is deduced): contentPosRange = spe.contentPosRange(); | - |
1447 | if (contentPosRange.width() < 0) partially evaluated: contentPosRange.width() < 0 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1448 | contentPosRange.setWidth(0); never executed: contentPosRange.setWidth(0); | 0 |
1449 | if (contentPosRange.height() < 0) partially evaluated: contentPosRange.height() < 0 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1450 | contentPosRange.setHeight(0); never executed: contentPosRange.setHeight(0); | 0 |
1451 | contentPosition = clampToRect(spe.contentPos(), contentPosRange); executed (the execution status of this line is deduced): contentPosition = clampToRect(spe.contentPos(), contentPosRange); | - |
1452 | overshootPosition = spe.contentPos() - contentPosition; executed (the execution status of this line is deduced): overshootPosition = spe.contentPos() - contentPosition; | - |
1453 | | - |
1454 | // - check if the content position was moved | - |
1455 | if (contentDelta != QPointF(0, 0)) { evaluated: contentDelta != QPointF(0, 0) yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
1456 | // need to correct all segments | - |
1457 | for (int i = 0; i < xSegments.count(); i++) partially evaluated: i < xSegments.count() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1458 | xSegments[i].startPos -= contentDelta.x(); never executed: xSegments[i].startPos -= contentDelta.x(); | 0 |
1459 | | - |
1460 | for (int i = 0; i < ySegments.count(); i++) partially evaluated: i < ySegments.count() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1461 | ySegments[i].startPos -= contentDelta.y(); never executed: ySegments[i].startPos -= contentDelta.y(); | 0 |
1462 | } executed: } Execution Count:6 | 6 |
1463 | | - |
1464 | if (QWidget *w = qobject_cast<QWidget *>(target)) partially evaluated: QWidget *w = qobject_cast<QWidget *>(target) yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1465 | setDpiFromWidget(w); executed: setDpiFromWidget(w); Execution Count:8 | 8 |
1466 | #ifndef QT_NO_GRAPHICSVIEW | - |
1467 | if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) { partially evaluated: QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target) no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1468 | //TODO: the first view isn't really correct - maybe use an additional field in the prepare event? | - |
1469 | if (go->scene() && !go->scene()->views().isEmpty()) never evaluated: go->scene() never evaluated: !go->scene()->views().isEmpty() | 0 |
1470 | setDpiFromWidget(go->scene()->views().first()); never executed: setDpiFromWidget(go->scene()->views().first()); | 0 |
1471 | } | 0 |
1472 | #endif | - |
1473 | | - |
1474 | if (state == QScroller::Scrolling) { partially evaluated: state == QScroller::Scrolling no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1475 | recalcScrollingSegments(); never executed (the execution status of this line is deduced): recalcScrollingSegments(); | - |
1476 | } | 0 |
1477 | return true; executed: return true; Execution Count:8 | 8 |
1478 | } | - |
1479 | | - |
1480 | return false; never executed: return false; | 0 |
1481 | } | - |
1482 | | - |
1483 | void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp) | - |
1484 | { | - |
1485 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1486 | | - |
1487 | QPointF deltaPixel = position - lastPosition; executed (the execution status of this line is deduced): QPointF deltaPixel = position - lastPosition; | - |
1488 | qint64 deltaTime = timestamp - lastTimestamp; executed (the execution status of this line is deduced): qint64 deltaTime = timestamp - lastTimestamp; | - |
1489 | | - |
1490 | if (sp->axisLockThreshold) { partially evaluated: sp->axisLockThreshold no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1491 | int dx = qAbs(deltaPixel.x()); never executed (the execution status of this line is deduced): int dx = qAbs(deltaPixel.x()); | - |
1492 | int dy = qAbs(deltaPixel.y()); never executed (the execution status of this line is deduced): int dy = qAbs(deltaPixel.y()); | - |
1493 | if (dx || dy) { never evaluated: dx never evaluated: dy | 0 |
1494 | bool vertical = (dy > dx); never executed (the execution status of this line is deduced): bool vertical = (dy > dx); | - |
1495 | qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx); never executed (the execution status of this line is deduced): qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx); | - |
1496 | //qScrollerDebug() << "QScroller::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy; | - |
1497 | if (alpha <= sp->axisLockThreshold) { never evaluated: alpha <= sp->axisLockThreshold | 0 |
1498 | if (vertical) never evaluated: vertical | 0 |
1499 | deltaPixel.setX(0); never executed: deltaPixel.setX(0); | 0 |
1500 | else | - |
1501 | deltaPixel.setY(0); never executed: deltaPixel.setY(0); | 0 |
1502 | } | - |
1503 | } | 0 |
1504 | } | 0 |
1505 | | - |
1506 | // calculate velocity (if the user would release the mouse NOW) | - |
1507 | updateVelocity(deltaPixel, deltaTime); executed (the execution status of this line is deduced): updateVelocity(deltaPixel, deltaTime); | - |
1508 | | - |
1509 | // restrict velocity, if content is not scrollable | - |
1510 | QRectF max = contentPosRange; executed (the execution status of this line is deduced): QRectF max = contentPosRange; | - |
1511 | bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); evaluated: (max.width() > 0) yes Evaluation Count:8 | yes Evaluation Count:2 |
partially evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-8 |
1512 | bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); partially evaluated: (max.height() > 0) yes Evaluation Count:10 | no Evaluation Count:0 |
never evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) | 0-10 |
1513 | | - |
1514 | if (!canScrollX) { partially evaluated: !canScrollX no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1515 | deltaPixel.setX(0); never executed (the execution status of this line is deduced): deltaPixel.setX(0); | - |
1516 | releaseVelocity.setX(0); never executed (the execution status of this line is deduced): releaseVelocity.setX(0); | - |
1517 | } | 0 |
1518 | if (!canScrollY) { partially evaluated: !canScrollY no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1519 | deltaPixel.setY(0); never executed (the execution status of this line is deduced): deltaPixel.setY(0); | - |
1520 | releaseVelocity.setY(0); never executed (the execution status of this line is deduced): releaseVelocity.setY(0); | - |
1521 | } | 0 |
1522 | | - |
1523 | // if (firstDrag) { | - |
1524 | // // Do not delay the first drag | - |
1525 | // setContentPositionHelper(q->contentPosition() - overshootDistance - deltaPixel); | - |
1526 | // dragDistance = QPointF(0, 0); | - |
1527 | // } else { | - |
1528 | dragDistance += deltaPixel; executed (the execution status of this line is deduced): dragDistance += deltaPixel; | - |
1529 | // } | - |
1530 | //qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y(); | - |
1531 | | - |
1532 | lastPosition = position; executed (the execution status of this line is deduced): lastPosition = position; | - |
1533 | lastTimestamp = timestamp; executed (the execution status of this line is deduced): lastTimestamp = timestamp; | - |
1534 | } executed: } Execution Count:10 | 10 |
1535 | | - |
1536 | bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp) | - |
1537 | { | - |
1538 | if (prepareScrolling(position)) { partially evaluated: prepareScrolling(position) yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1539 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1540 | | - |
1541 | if (!contentPosRange.isNull() || partially evaluated: !contentPosRange.isNull() yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1542 | (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) || never evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) | 0 |
1543 | (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) { never evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) | 0 |
1544 | | - |
1545 | lastPosition = pressPosition = position; executed (the execution status of this line is deduced): lastPosition = pressPosition = position; | - |
1546 | lastTimestamp = pressTimestamp = timestamp; executed (the execution status of this line is deduced): lastTimestamp = pressTimestamp = timestamp; | - |
1547 | setState(QScroller::Pressed); executed (the execution status of this line is deduced): setState(QScroller::Pressed); | - |
1548 | } executed: } Execution Count:7 | 7 |
1549 | } executed: } Execution Count:7 | 7 |
1550 | return false; executed: return false; Execution Count:7 | 7 |
1551 | } | - |
1552 | | - |
1553 | bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64) | - |
1554 | { | - |
1555 | if (overshootPosition != QPointF(0.0, 0.0)) { never evaluated: overshootPosition != QPointF(0.0, 0.0) | 0 |
1556 | setState(QScroller::Scrolling); never executed (the execution status of this line is deduced): setState(QScroller::Scrolling); | - |
1557 | return true; never executed: return true; | 0 |
1558 | } else { | - |
1559 | setState(QScroller::Inactive); never executed (the execution status of this line is deduced): setState(QScroller::Inactive); | - |
1560 | return false; never executed: return false; | 0 |
1561 | } | - |
1562 | } | - |
1563 | | - |
1564 | bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp) | - |
1565 | { | - |
1566 | Q_Q(QScroller); executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1567 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1568 | QPointF ppm = q->pixelPerMeter(); executed (the execution status of this line is deduced): QPointF ppm = q->pixelPerMeter(); | - |
1569 | | - |
1570 | QPointF deltaPixel = position - pressPosition; executed (the execution status of this line is deduced): QPointF deltaPixel = position - pressPosition; | - |
1571 | | - |
1572 | bool moveAborted = false; executed (the execution status of this line is deduced): bool moveAborted = false; | - |
1573 | bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance); executed (the execution status of this line is deduced): bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance); | - |
1574 | | - |
1575 | // check the direction of the mouse drag and abort if it's too much in the wrong direction. | - |
1576 | if (moveStarted) { partially evaluated: moveStarted yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1577 | QRectF max = contentPosRange; executed (the execution status of this line is deduced): QRectF max = contentPosRange; | - |
1578 | bool canScrollX = (max.width() > 0); executed (the execution status of this line is deduced): bool canScrollX = (max.width() > 0); | - |
1579 | bool canScrollY = (max.height() > 0); executed (the execution status of this line is deduced): bool canScrollY = (max.height() > 0); | - |
1580 | | - |
1581 | if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) evaluated: sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1582 | canScrollX = true; executed: canScrollX = true; Execution Count:2 | 2 |
1583 | if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) partially evaluated: sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1584 | canScrollY = true; never executed: canScrollY = true; | 0 |
1585 | | - |
1586 | if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) { partially evaluated: qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y()) no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1587 | if (!canScrollY) never evaluated: !canScrollY | 0 |
1588 | moveAborted = true; never executed: moveAborted = true; | 0 |
1589 | } else { | 0 |
1590 | if (!canScrollX) evaluated: !canScrollX yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1591 | moveAborted = true; executed: moveAborted = true; Execution Count:2 | 2 |
1592 | } executed: } Execution Count:7 | 7 |
1593 | } | - |
1594 | | - |
1595 | if (moveAborted) { evaluated: moveAborted yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1596 | setState(QScroller::Inactive); executed (the execution status of this line is deduced): setState(QScroller::Inactive); | - |
1597 | moveStarted = false; executed (the execution status of this line is deduced): moveStarted = false; | - |
1598 | | - |
1599 | } else if (moveStarted) { executed: } Execution Count:2 partially evaluated: moveStarted yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1600 | setState(QScroller::Dragging); executed (the execution status of this line is deduced): setState(QScroller::Dragging); | - |
1601 | | - |
1602 | // subtract the dragStartDistance | - |
1603 | deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength()); executed (the execution status of this line is deduced): deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength()); | - |
1604 | | - |
1605 | if (deltaPixel != QPointF(0, 0)) { partially evaluated: deltaPixel != QPointF(0, 0) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1606 | // handleDrag updates lastPosition, lastTimestamp and velocity | - |
1607 | handleDrag(pressPosition + deltaPixel, timestamp); executed (the execution status of this line is deduced): handleDrag(pressPosition + deltaPixel, timestamp); | - |
1608 | } executed: } Execution Count:5 | 5 |
1609 | } executed: } Execution Count:5 | 5 |
1610 | return moveStarted; executed: return moveStarted; Execution Count:7 | 7 |
1611 | } | - |
1612 | | - |
1613 | bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp) | - |
1614 | { | - |
1615 | // handleDrag updates lastPosition, lastTimestamp and velocity | - |
1616 | handleDrag(position, timestamp); never executed (the execution status of this line is deduced): handleDrag(position, timestamp); | - |
1617 | return true; never executed: return true; | 0 |
1618 | } | - |
1619 | | - |
1620 | void QScrollerPrivate::timerEventWhileDragging() | - |
1621 | { | - |
1622 | if (dragDistance != QPointF(0, 0)) { partially evaluated: dragDistance != QPointF(0, 0) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1623 | qScrollerDebug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance; never executed: QMessageLogger("util/qscroller.cpp", 1623, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1624 | | - |
1625 | setContentPositionHelperDragging(-dragDistance); executed (the execution status of this line is deduced): setContentPositionHelperDragging(-dragDistance); | - |
1626 | dragDistance = QPointF(0, 0); executed (the execution status of this line is deduced): dragDistance = QPointF(0, 0); | - |
1627 | } executed: } Execution Count:5 | 5 |
1628 | } executed: } Execution Count:5 | 5 |
1629 | | - |
1630 | bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp) | - |
1631 | { | - |
1632 | Q_Q(QScroller); executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1633 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1634 | | - |
1635 | // handleDrag updates lastPosition, lastTimestamp and velocity | - |
1636 | handleDrag(position, timestamp); executed (the execution status of this line is deduced): handleDrag(position, timestamp); | - |
1637 | | - |
1638 | // check if we moved at all - this can happen if you stop a running | - |
1639 | // scroller with a press and release shortly afterwards | - |
1640 | QPointF deltaPixel = position - pressPosition; executed (the execution status of this line is deduced): QPointF deltaPixel = position - pressPosition; | - |
1641 | if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) { partially evaluated: ((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1642 | | - |
1643 | // handle accelerating flicks | - |
1644 | if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime && partially evaluated: (oldVelocity != QPointF(0, 0)) no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: sp->acceleratingFlickMaximumTime | 0-5 |
1645 | ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) { never evaluated: ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000)) | 0 |
1646 | | - |
1647 | // - determine if the direction was changed | - |
1648 | int signX = 0, signY = 0; never executed (the execution status of this line is deduced): int signX = 0, signY = 0; | - |
1649 | if (releaseVelocity.x()) never evaluated: releaseVelocity.x() | 0 |
1650 | signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1; never executed: signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1; never evaluated: (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) | 0 |
1651 | if (releaseVelocity.y()) never evaluated: releaseVelocity.y() | 0 |
1652 | signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1; never executed: signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1; never evaluated: (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) | 0 |
1653 | | - |
1654 | if (signX > 0) never evaluated: signX > 0 | 0 |
1655 | releaseVelocity.setX(qBound(-sp->maximumVelocity, never executed: releaseVelocity.setX(qBound(-sp->maximumVelocity, oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1656 | oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, never executed: releaseVelocity.setX(qBound(-sp->maximumVelocity, oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1657 | sp->maximumVelocity)); never executed: releaseVelocity.setX(qBound(-sp->maximumVelocity, oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1658 | if (signY > 0) never evaluated: signY > 0 | 0 |
1659 | releaseVelocity.setY(qBound(-sp->maximumVelocity, never executed: releaseVelocity.setY(qBound(-sp->maximumVelocity, oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1660 | oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, never executed: releaseVelocity.setY(qBound(-sp->maximumVelocity, oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1661 | sp->maximumVelocity)); never executed: releaseVelocity.setY(qBound(-sp->maximumVelocity, oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, sp->maximumVelocity)); | 0 |
1662 | } | 0 |
1663 | } executed: } Execution Count:5 | 5 |
1664 | | - |
1665 | QPointF ppm = q->pixelPerMeter(); executed (the execution status of this line is deduced): QPointF ppm = q->pixelPerMeter(); | - |
1666 | createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); executed (the execution status of this line is deduced): createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); | - |
1667 | | - |
1668 | qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition; never executed: QMessageLogger("util/qscroller.cpp", 1668, __PRETTY_FUNCTION__).debug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1669 | | - |
1670 | if (xSegments.isEmpty() && ySegments.isEmpty()) partially evaluated: xSegments.isEmpty() no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: ySegments.isEmpty() | 0-5 |
1671 | setState(QScroller::Inactive); never executed: setState(QScroller::Inactive); | 0 |
1672 | else | - |
1673 | setState(QScroller::Scrolling); executed: setState(QScroller::Scrolling); Execution Count:5 | 5 |
1674 | | - |
1675 | return true; executed: return true; Execution Count:5 | 5 |
1676 | } | - |
1677 | | - |
1678 | void QScrollerPrivate::timerEventWhileScrolling() | - |
1679 | { | - |
1680 | qScrollerDebug() << "QScroller::timerEventWhileScrolling()"; never executed: QMessageLogger("util/qscroller.cpp", 1680, __PRETTY_FUNCTION__).debug() << "QScroller::timerEventWhileScrolling()"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
1681 | | - |
1682 | setContentPositionHelperScrolling(); executed (the execution status of this line is deduced): setContentPositionHelperScrolling(); | - |
1683 | if (xSegments.isEmpty() && ySegments.isEmpty()) evaluated: xSegments.isEmpty() yes Evaluation Count:6 | yes Evaluation Count:126 |
partially evaluated: ySegments.isEmpty() yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-126 |
1684 | setState(QScroller::Inactive); executed: setState(QScroller::Inactive); Execution Count:6 | 6 |
1685 | } executed: } Execution Count:132 | 132 |
1686 | | - |
1687 | bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp) | - |
1688 | { | - |
1689 | Q_Q(QScroller); never executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1690 | | - |
1691 | if ((q->velocity() <= properties.d->maximumClickThroughVelocity) && never evaluated: (q->velocity() <= properties.d->maximumClickThroughVelocity) | 0 |
1692 | (overshootPosition == QPointF(0.0, 0.0))) { never evaluated: (overshootPosition == QPointF(0.0, 0.0)) | 0 |
1693 | setState(QScroller::Inactive); never executed (the execution status of this line is deduced): setState(QScroller::Inactive); | - |
1694 | return false; never executed: return false; | 0 |
1695 | } else { | - |
1696 | lastPosition = pressPosition = position; never executed (the execution status of this line is deduced): lastPosition = pressPosition = position; | - |
1697 | lastTimestamp = pressTimestamp = timestamp; never executed (the execution status of this line is deduced): lastTimestamp = pressTimestamp = timestamp; | - |
1698 | setState(QScroller::Pressed); never executed (the execution status of this line is deduced): setState(QScroller::Pressed); | - |
1699 | setState(QScroller::Dragging); never executed (the execution status of this line is deduced): setState(QScroller::Dragging); | - |
1700 | return true; never executed: return true; | 0 |
1701 | } | - |
1702 | } | - |
1703 | | - |
1704 | /*! \internal | - |
1705 | This function handles all state changes of the scroller. | - |
1706 | */ | - |
1707 | void QScrollerPrivate::setState(QScroller::State newstate) | - |
1708 | { | - |
1709 | Q_Q(QScroller); executed (the execution status of this line is deduced): QScroller * const q = q_func(); | - |
1710 | bool sendLastScroll = false; executed (the execution status of this line is deduced): bool sendLastScroll = false; | - |
1711 | | - |
1712 | if (state == newstate) partially evaluated: state == newstate no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1713 | return; | 0 |
1714 | | - |
1715 | qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")"; never executed: QMessageLogger("util/qscroller.cpp", 1715, __PRETTY_FUNCTION__).debug() << q << "QScroller::setState(" << stateName(newstate) << ")"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1716 | | - |
1717 | switch (newstate) { | - |
1718 | case QScroller::Inactive: | - |
1719 | #ifndef QT_NO_ANIMATION | - |
1720 | scrollTimer->stop(); executed (the execution status of this line is deduced): scrollTimer->stop(); | - |
1721 | #endif | - |
1722 | | - |
1723 | // send the last scroll event (but only after the current state change was finished) | - |
1724 | if (!firstScroll) evaluated: !firstScroll yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
1725 | sendLastScroll = true; executed: sendLastScroll = true; Execution Count:6 | 6 |
1726 | | - |
1727 | releaseVelocity = QPointF(0, 0); executed (the execution status of this line is deduced): releaseVelocity = QPointF(0, 0); | - |
1728 | break; executed: break; Execution Count:8 | 8 |
1729 | | - |
1730 | case QScroller::Pressed: | - |
1731 | #ifndef QT_NO_ANIMATION | - |
1732 | scrollTimer->stop(); executed (the execution status of this line is deduced): scrollTimer->stop(); | - |
1733 | #endif | - |
1734 | | - |
1735 | oldVelocity = releaseVelocity; executed (the execution status of this line is deduced): oldVelocity = releaseVelocity; | - |
1736 | releaseVelocity = QPointF(0, 0); executed (the execution status of this line is deduced): releaseVelocity = QPointF(0, 0); | - |
1737 | break; executed: break; Execution Count:7 | 7 |
1738 | | - |
1739 | case QScroller::Dragging: | - |
1740 | dragDistance = QPointF(0, 0); executed (the execution status of this line is deduced): dragDistance = QPointF(0, 0); | - |
1741 | #ifndef QT_NO_ANIMATION | - |
1742 | if (state == QScroller::Pressed) partially evaluated: state == QScroller::Pressed yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1743 | scrollTimer->start(); executed: scrollTimer->start(); Execution Count:5 | 5 |
1744 | #endif | - |
1745 | break; executed: break; Execution Count:5 | 5 |
1746 | | - |
1747 | case QScroller::Scrolling: | - |
1748 | #ifndef QT_NO_ANIMATION | - |
1749 | scrollTimer->start(); executed (the execution status of this line is deduced): scrollTimer->start(); | - |
1750 | #endif | - |
1751 | break; executed: break; Execution Count:6 | 6 |
1752 | } | - |
1753 | | - |
1754 | qSwap(state, newstate); executed (the execution status of this line is deduced): qSwap(state, newstate); | - |
1755 | | - |
1756 | if (sendLastScroll) { evaluated: sendLastScroll yes Evaluation Count:6 | yes Evaluation Count:20 |
| 6-20 |
1757 | QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished); executed (the execution status of this line is deduced): QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished); | - |
1758 | sendEvent(target, &se); executed (the execution status of this line is deduced): sendEvent(target, &se); | - |
1759 | firstScroll = true; executed (the execution status of this line is deduced): firstScroll = true; | - |
1760 | } executed: } Execution Count:6 | 6 |
1761 | if (state == QScroller::Dragging || state == QScroller::Scrolling) evaluated: state == QScroller::Dragging yes Evaluation Count:5 | yes Evaluation Count:21 |
evaluated: state == QScroller::Scrolling yes Evaluation Count:6 | yes Evaluation Count:15 |
| 5-21 |
1762 | qt_activeScrollers()->insert(q); executed: qt_activeScrollers()->insert(q); Execution Count:11 | 11 |
1763 | else | - |
1764 | qt_activeScrollers()->remove(q); executed: qt_activeScrollers()->remove(q); Execution Count:15 | 15 |
1765 | emit q->stateChanged(state); executed (the execution status of this line is deduced): q->stateChanged(state); | - |
1766 | } executed: } Execution Count:26 | 26 |
1767 | | - |
1768 | | - |
1769 | /*! \internal | - |
1770 | Helps when setting the content position. | - |
1771 | It will try to move the content by the requested delta but stop in case | - |
1772 | when we are coming back from an overshoot or a scrollTo. | - |
1773 | It will also indicate a new overshooting condition by the overshootX and oversthootY flags. | - |
1774 | | - |
1775 | In this cases it will reset the velocity variables and other flags. | - |
1776 | | - |
1777 | Also keeps track of the current over-shooting value in overshootPosition. | - |
1778 | | - |
1779 | \a deltaPos is the amount of pixels the current content position should be moved | - |
1780 | */ | - |
1781 | void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos) | - |
1782 | { | - |
1783 | const QScrollerPropertiesPrivate *sp = properties.d.data(); executed (the execution status of this line is deduced): const QScrollerPropertiesPrivate *sp = properties.d.data(); | - |
1784 | | - |
1785 | if (sp->overshootDragResistanceFactor) partially evaluated: sp->overshootDragResistanceFactor yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1786 | overshootPosition /= sp->overshootDragResistanceFactor; executed: overshootPosition /= sp->overshootDragResistanceFactor; Execution Count:5 | 5 |
1787 | | - |
1788 | QPointF oldPos = contentPosition + overshootPosition; executed (the execution status of this line is deduced): QPointF oldPos = contentPosition + overshootPosition; | - |
1789 | QPointF newPos = oldPos + deltaPos; executed (the execution status of this line is deduced): QPointF newPos = oldPos + deltaPos; | - |
1790 | | - |
1791 | qScrollerDebug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])"; never executed: QMessageLogger("util/qscroller.cpp", 1791, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1792 | qScrollerDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos; never executed: QMessageLogger("util/qscroller.cpp", 1792, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1793 | | - |
1794 | QPointF oldClampedPos = clampToRect(oldPos, contentPosRange); executed (the execution status of this line is deduced): QPointF oldClampedPos = clampToRect(oldPos, contentPosRange); | - |
1795 | QPointF newClampedPos = clampToRect(newPos, contentPosRange); executed (the execution status of this line is deduced): QPointF newClampedPos = clampToRect(newPos, contentPosRange); | - |
1796 | | - |
1797 | // --- handle overshooting and stop if the coordinate is going back inside the normal area | - |
1798 | bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); executed (the execution status of this line is deduced): bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); | - |
1799 | bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); executed (the execution status of this line is deduced): bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); | - |
1800 | bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) || evaluated: (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
1801 | ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) || partially evaluated: (state == QScroller::Dragging) yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: !sp->overshootDragResistanceFactor no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1802 | !sp->overshootDragDistanceFactor; evaluated: !sp->overshootDragDistanceFactor yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
1803 | bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) || partially evaluated: (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1804 | ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) || partially evaluated: (state == QScroller::Dragging) yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: !sp->overshootDragResistanceFactor no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1805 | !sp->overshootDragDistanceFactor; evaluated: !sp->overshootDragDistanceFactor yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
1806 | bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width()); evaluated: !noOvershootX yes Evaluation Count:3 | yes Evaluation Count:2 |
evaluated: alwaysOvershootX yes Evaluation Count:1 | yes Evaluation Count:2 |
partially evaluated: contentPosRange.width() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-3 |
1807 | bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height()); evaluated: !noOvershootY yes Evaluation Count:4 | yes Evaluation Count:1 |
partially evaluated: alwaysOvershootY no Evaluation Count:0 | yes Evaluation Count:4 |
partially evaluated: contentPosRange.height() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1808 | | - |
1809 | qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0; evaluated: (canOvershootX) yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
1810 | qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0; evaluated: (canOvershootY) yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1811 | | - |
1812 | qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0; evaluated: (canOvershootX) yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
1813 | qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0; evaluated: (canOvershootY) yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1814 | | - |
1815 | qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor; executed (the execution status of this line is deduced): qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor; | - |
1816 | qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor; executed (the execution status of this line is deduced): qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor; | - |
1817 | | - |
1818 | qScrollerDebug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy; never executed: QMessageLogger("util/qscroller.cpp", 1818, __PRETTY_FUNCTION__).debug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1819 | qScrollerDebug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX; never executed: QMessageLogger("util/qscroller.cpp", 1819, __PRETTY_FUNCTION__).debug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1820 | | - |
1821 | if (sp->overshootDragResistanceFactor) { partially evaluated: sp->overshootDragResistanceFactor yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1822 | oldOvershootX *= sp->overshootDragResistanceFactor; executed (the execution status of this line is deduced): oldOvershootX *= sp->overshootDragResistanceFactor; | - |
1823 | oldOvershootY *= sp->overshootDragResistanceFactor; executed (the execution status of this line is deduced): oldOvershootY *= sp->overshootDragResistanceFactor; | - |
1824 | newOvershootX *= sp->overshootDragResistanceFactor; executed (the execution status of this line is deduced): newOvershootX *= sp->overshootDragResistanceFactor; | - |
1825 | newOvershootY *= sp->overshootDragResistanceFactor; executed (the execution status of this line is deduced): newOvershootY *= sp->overshootDragResistanceFactor; | - |
1826 | } executed: } Execution Count:5 | 5 |
1827 | | - |
1828 | // -- stop at the maximum overshoot distance | - |
1829 | | - |
1830 | newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX); executed (the execution status of this line is deduced): newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX); | - |
1831 | newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY); executed (the execution status of this line is deduced): newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY); | - |
1832 | | - |
1833 | overshootPosition.setX(newOvershootX); executed (the execution status of this line is deduced): overshootPosition.setX(newOvershootX); | - |
1834 | overshootPosition.setY(newOvershootY); executed (the execution status of this line is deduced): overshootPosition.setY(newOvershootY); | - |
1835 | contentPosition = newClampedPos; executed (the execution status of this line is deduced): contentPosition = newClampedPos; | - |
1836 | | - |
1837 | QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); executed (the execution status of this line is deduced): QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); | - |
1838 | sendEvent(target, &se); executed (the execution status of this line is deduced): sendEvent(target, &se); | - |
1839 | firstScroll = false; executed (the execution status of this line is deduced): firstScroll = false; | - |
1840 | | - |
1841 | qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition << never executed: QMessageLogger("util/qscroller.cpp", 1841, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition << "- overshoot x/y?:" << overshootPosition; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1842 | "- overshoot x/y?:" << overshootPosition; never executed: QMessageLogger("util/qscroller.cpp", 1841, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition << "- overshoot x/y?:" << overshootPosition; | 0 |
1843 | } executed: } Execution Count:5 | 5 |
1844 | | - |
1845 | | - |
1846 | qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos) | - |
1847 | { | - |
1848 | qreal pos = oldPos; executed (the execution status of this line is deduced): qreal pos = oldPos; | - |
1849 | | - |
1850 | // check the X segments for new positions | - |
1851 | while (!segments.isEmpty()) { evaluated: !segments.isEmpty() yes Evaluation Count:191 | yes Evaluation Count:86 |
| 86-191 |
1852 | const ScrollSegment s = segments.head(); executed (the execution status of this line is deduced): const ScrollSegment s = segments.head(); | - |
1853 | | - |
1854 | if ((s.startTime + s.deltaTime * s.stopProgress) <= now) { evaluated: (s.startTime + s.deltaTime * s.stopProgress) <= now yes Evaluation Count:13 | yes Evaluation Count:178 |
| 13-178 |
1855 | segments.dequeue(); executed (the execution status of this line is deduced): segments.dequeue(); | - |
1856 | pos = s.stopPos; executed (the execution status of this line is deduced): pos = s.stopPos; | - |
1857 | } else if (s.startTime <= now) { executed: } Execution Count:13 partially evaluated: s.startTime <= now yes Evaluation Count:178 | no Evaluation Count:0 |
| 0-178 |
1858 | qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); executed (the execution status of this line is deduced): qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); | - |
1859 | pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress); executed (the execution status of this line is deduced): pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress); | - |
1860 | if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) { evaluated: s.deltaPos > 0 yes Evaluation Count:121 | yes Evaluation Count:57 |
| 57-121 |
1861 | segments.dequeue(); never executed (the execution status of this line is deduced): segments.dequeue(); | - |
1862 | pos = s.stopPos; never executed (the execution status of this line is deduced): pos = s.stopPos; | - |
1863 | } else { | 0 |
1864 | break; executed: break; Execution Count:178 | 178 |
1865 | } | - |
1866 | } else { | - |
1867 | break; | 0 |
1868 | } | - |
1869 | } | - |
1870 | return pos; executed: return pos; Execution Count:264 | 264 |
1871 | } | - |
1872 | | - |
1873 | void QScrollerPrivate::setContentPositionHelperScrolling() | - |
1874 | { | - |
1875 | qint64 now = monotonicTimer.elapsed(); executed (the execution status of this line is deduced): qint64 now = monotonicTimer.elapsed(); | - |
1876 | QPointF newPos = contentPosition + overshootPosition; executed (the execution status of this line is deduced): QPointF newPos = contentPosition + overshootPosition; | - |
1877 | | - |
1878 | newPos.setX(nextSegmentPosition(xSegments, now, newPos.x())); executed (the execution status of this line is deduced): newPos.setX(nextSegmentPosition(xSegments, now, newPos.x())); | - |
1879 | newPos.setY(nextSegmentPosition(ySegments, now, newPos.y())); executed (the execution status of this line is deduced): newPos.setY(nextSegmentPosition(ySegments, now, newPos.y())); | - |
1880 | | - |
1881 | // -- set the position and handle overshoot | - |
1882 | qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()"; never executed: QMessageLogger("util/qscroller.cpp", 1882, __PRETTY_FUNCTION__).debug() << "QScroller::setContentPositionHelperScrolling()"; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
1883 | qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos; never executed: QMessageLogger("util/qscroller.cpp", 1883, __PRETTY_FUNCTION__).debug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
1884 | | - |
1885 | QPointF newClampedPos = clampToRect(newPos, contentPosRange); executed (the execution status of this line is deduced): QPointF newClampedPos = clampToRect(newPos, contentPosRange); | - |
1886 | | - |
1887 | overshootPosition = newPos - newClampedPos; executed (the execution status of this line is deduced): overshootPosition = newPos - newClampedPos; | - |
1888 | contentPosition = newClampedPos; executed (the execution status of this line is deduced): contentPosition = newClampedPos; | - |
1889 | | - |
1890 | QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); executed (the execution status of this line is deduced): QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); | - |
1891 | sendEvent(target, &se); executed (the execution status of this line is deduced): sendEvent(target, &se); | - |
1892 | firstScroll = false; executed (the execution status of this line is deduced): firstScroll = false; | - |
1893 | | - |
1894 | qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition; never executed: QMessageLogger("util/qscroller.cpp", 1894, __PRETTY_FUNCTION__).debug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition; partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
1895 | } executed: } Execution Count:132 | 132 |
1896 | | - |
1897 | /*! \internal | - |
1898 | Returns the next snap point in direction. | - |
1899 | If \a direction >0 it will return the next snap point that is larger than the current position. | - |
1900 | If \a direction <0 it will return the next snap point that is smaller than the current position. | - |
1901 | If \a direction ==0 it will return the nearest snap point (or the current position if we are already | - |
1902 | on a snap point. | - |
1903 | Returns the nearest snap position or NaN if no such point could be found. | - |
1904 | */ | - |
1905 | qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation) | - |
1906 | { | - |
1907 | qreal bestSnapPos = Q_QNAN; executed (the execution status of this line is deduced): qreal bestSnapPos = (::qQNaN()); | - |
1908 | qreal bestSnapPosDist = Q_INFINITY; executed (the execution status of this line is deduced): qreal bestSnapPosDist = (::qInf()); | - |
1909 | | - |
1910 | qreal minPos; executed (the execution status of this line is deduced): qreal minPos; | - |
1911 | qreal maxPos; executed (the execution status of this line is deduced): qreal maxPos; | - |
1912 | | - |
1913 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal yes Evaluation Count:25 | yes Evaluation Count:28 |
| 25-28 |
1914 | minPos = contentPosRange.left(); executed (the execution status of this line is deduced): minPos = contentPosRange.left(); | - |
1915 | maxPos = contentPosRange.right(); executed (the execution status of this line is deduced): maxPos = contentPosRange.right(); | - |
1916 | } else { executed: } Execution Count:25 | 25 |
1917 | minPos = contentPosRange.top(); executed (the execution status of this line is deduced): minPos = contentPosRange.top(); | - |
1918 | maxPos = contentPosRange.bottom(); executed (the execution status of this line is deduced): maxPos = contentPosRange.bottom(); | - |
1919 | } executed: } Execution Count:28 | 28 |
1920 | | - |
1921 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal yes Evaluation Count:25 | yes Evaluation Count:28 |
| 25-28 |
1922 | // the snap points in the list | - |
1923 | foreach (qreal snapPos, snapPositionsX) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(snapPositionsX)> _container_(snapPositionsX); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (qreal snapPos = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1924 | qreal snapPosDist = snapPos - p; never executed (the execution status of this line is deduced): qreal snapPosDist = snapPos - p; | - |
1925 | if ((dir > 0 && snapPosDist < 0) || never evaluated: dir > 0 never evaluated: snapPosDist < 0 | 0 |
1926 | (dir < 0 && snapPosDist > 0)) never evaluated: dir < 0 never evaluated: snapPosDist > 0 | 0 |
1927 | continue; // wrong direction never executed: continue; | 0 |
1928 | if (snapPos < minPos || snapPos > maxPos ) never evaluated: snapPos < minPos never evaluated: snapPos > maxPos | 0 |
1929 | continue; // invalid never executed: continue; | 0 |
1930 | | - |
1931 | if (qIsNaN(bestSnapPos) || never evaluated: qIsNaN(bestSnapPos) | 0 |
1932 | qAbs(snapPosDist) < bestSnapPosDist ) { never evaluated: qAbs(snapPosDist) < bestSnapPosDist | 0 |
1933 | bestSnapPos = snapPos; never executed (the execution status of this line is deduced): bestSnapPos = snapPos; | - |
1934 | bestSnapPosDist = qAbs(snapPosDist); never executed (the execution status of this line is deduced): bestSnapPosDist = qAbs(snapPosDist); | - |
1935 | } | 0 |
1936 | } | 0 |
1937 | | - |
1938 | // the snap point interval | - |
1939 | if (snapIntervalX > 0.0) { partially evaluated: snapIntervalX > 0.0 no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
1940 | qreal first = minPos + snapFirstX; never executed (the execution status of this line is deduced): qreal first = minPos + snapFirstX; | - |
1941 | qreal snapPos; never executed (the execution status of this line is deduced): qreal snapPos; | - |
1942 | if (dir > 0) | 0 |
1943 | snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first; never executed: snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first; | 0 |
1944 | else if (dir < 0) | 0 |
1945 | snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first; never executed: snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first; | 0 |
1946 | else if (p <= first) never evaluated: p <= first | 0 |
1947 | snapPos = first; never executed: snapPos = first; | 0 |
1948 | else | - |
1949 | { | - |
1950 | qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first; never executed (the execution status of this line is deduced): qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first; | - |
1951 | if (p >= last) never evaluated: p >= last | 0 |
1952 | snapPos = last; never executed: snapPos = last; | 0 |
1953 | else | - |
1954 | snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first; never executed: snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first; | 0 |
1955 | } | - |
1956 | | - |
1957 | if (snapPos >= first && snapPos <= maxPos ) { never evaluated: snapPos >= first never evaluated: snapPos <= maxPos | 0 |
1958 | qreal snapPosDist = snapPos - p; never executed (the execution status of this line is deduced): qreal snapPosDist = snapPos - p; | - |
1959 | | - |
1960 | if (qIsNaN(bestSnapPos) || never evaluated: qIsNaN(bestSnapPos) | 0 |
1961 | qAbs(snapPosDist) < bestSnapPosDist ) { never evaluated: qAbs(snapPosDist) < bestSnapPosDist | 0 |
1962 | bestSnapPos = snapPos; never executed (the execution status of this line is deduced): bestSnapPos = snapPos; | - |
1963 | bestSnapPosDist = qAbs(snapPosDist); never executed (the execution status of this line is deduced): bestSnapPosDist = qAbs(snapPosDist); | - |
1964 | } | 0 |
1965 | } | 0 |
1966 | } | 0 |
1967 | | - |
1968 | } else { // (orientation == Qt::Vertical) executed: } Execution Count:25 | 25 |
1969 | // the snap points in the list | - |
1970 | foreach (qreal snapPos, snapPositionsY) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(snapPositionsY)> _container_(snapPositionsY); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (qreal snapPos = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1971 | qreal snapPosDist = snapPos - p; never executed (the execution status of this line is deduced): qreal snapPosDist = snapPos - p; | - |
1972 | if ((dir > 0 && snapPosDist < 0) || never evaluated: dir > 0 never evaluated: snapPosDist < 0 | 0 |
1973 | (dir < 0 && snapPosDist > 0)) never evaluated: dir < 0 never evaluated: snapPosDist > 0 | 0 |
1974 | continue; // wrong direction never executed: continue; | 0 |
1975 | if (snapPos < minPos || snapPos > maxPos ) never evaluated: snapPos < minPos never evaluated: snapPos > maxPos | 0 |
1976 | continue; // invalid never executed: continue; | 0 |
1977 | | - |
1978 | if (qIsNaN(bestSnapPos) || never evaluated: qIsNaN(bestSnapPos) | 0 |
1979 | qAbs(snapPosDist) < bestSnapPosDist) { never evaluated: qAbs(snapPosDist) < bestSnapPosDist | 0 |
1980 | bestSnapPos = snapPos; never executed (the execution status of this line is deduced): bestSnapPos = snapPos; | - |
1981 | bestSnapPosDist = qAbs(snapPosDist); never executed (the execution status of this line is deduced): bestSnapPosDist = qAbs(snapPosDist); | - |
1982 | } | 0 |
1983 | } | 0 |
1984 | | - |
1985 | // the snap point interval | - |
1986 | if (snapIntervalY > 0.0) { partially evaluated: snapIntervalY > 0.0 no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
1987 | qreal first = minPos + snapFirstY; never executed (the execution status of this line is deduced): qreal first = minPos + snapFirstY; | - |
1988 | qreal snapPos; never executed (the execution status of this line is deduced): qreal snapPos; | - |
1989 | if (dir > 0) | 0 |
1990 | snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first; never executed: snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first; | 0 |
1991 | else if (dir < 0) | 0 |
1992 | snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first; never executed: snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first; | 0 |
1993 | else if (p <= first) never evaluated: p <= first | 0 |
1994 | snapPos = first; never executed: snapPos = first; | 0 |
1995 | else | - |
1996 | { | - |
1997 | qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first; never executed (the execution status of this line is deduced): qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first; | - |
1998 | if (p >= last) never evaluated: p >= last | 0 |
1999 | snapPos = last; never executed: snapPos = last; | 0 |
2000 | else | - |
2001 | snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first; never executed: snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first; | 0 |
2002 | } | - |
2003 | | - |
2004 | if (snapPos >= first && snapPos <= maxPos ) { never evaluated: snapPos >= first never evaluated: snapPos <= maxPos | 0 |
2005 | qreal snapPosDist = snapPos - p; never executed (the execution status of this line is deduced): qreal snapPosDist = snapPos - p; | - |
2006 | | - |
2007 | if (qIsNaN(bestSnapPos) || never evaluated: qIsNaN(bestSnapPos) | 0 |
2008 | qAbs(snapPosDist) < bestSnapPosDist) { never evaluated: qAbs(snapPosDist) < bestSnapPosDist | 0 |
2009 | bestSnapPos = snapPos; never executed (the execution status of this line is deduced): bestSnapPos = snapPos; | - |
2010 | bestSnapPosDist = qAbs(snapPosDist); never executed (the execution status of this line is deduced): bestSnapPosDist = qAbs(snapPosDist); | - |
2011 | } | 0 |
2012 | } | 0 |
2013 | } | 0 |
2014 | } executed: } Execution Count:28 | 28 |
2015 | | - |
2016 | return bestSnapPos; executed: return bestSnapPos; Execution Count:53 | 53 |
2017 | } | - |
2018 | | - |
2019 | /*! | - |
2020 | \enum QScroller::State | - |
2021 | | - |
2022 | This enum contains the different QScroller states. | - |
2023 | | - |
2024 | \value Inactive The scroller is not scrolling and nothing is pressed. | - |
2025 | \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged. | - |
2026 | \value Dragging The scroll area is currently following the touch point or mouse. | - |
2027 | \value Scrolling The scroll area is moving on it's own. | - |
2028 | */ | - |
2029 | | - |
2030 | /*! | - |
2031 | \enum QScroller::ScrollerGestureType | - |
2032 | | - |
2033 | This enum contains the different gesture types that are supported by the QScroller gesture recognizer. | - |
2034 | | - |
2035 | \value TouchGesture The gesture recognizer will only trigger on touch | - |
2036 | events. Specifically it will react on single touch points when using a | - |
2037 | touch screen and dual touch points when using a touchpad. | - |
2038 | \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events. | - |
2039 | \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events. | - |
2040 | \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events. | - |
2041 | */ | - |
2042 | | - |
2043 | /*! | - |
2044 | \enum QScroller::Input | - |
2045 | | - |
2046 | This enum contains an input device agnostic view of input events that are relevant for QScroller. | - |
2047 | | - |
2048 | \value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress, | - |
2049 | QEvent::GraphicsSceneMousePress, QEvent::TouchBegin) | - |
2050 | | - |
2051 | \value InputMove The user moved the input device (e.g. QEvent::MouseMove, | - |
2052 | QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate) | - |
2053 | | - |
2054 | \value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease, | - |
2055 | QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd) | - |
2056 | | - |
2057 | */ | - |
2058 | | - |
2059 | QT_END_NAMESPACE | - |
2060 | | - |
| | |