Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickflickable.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||||||||
6 | ** This file is part of the QtQuick 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 The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||||||||
40 | #include "qquickflickable_p.h" | - | ||||||||||||||||||||||||||||||
41 | #include "qquickflickable_p_p.h" | - | ||||||||||||||||||||||||||||||
42 | #include "qquickflickablebehavior_p.h" | - | ||||||||||||||||||||||||||||||
43 | #include "qquickwindow.h" | - | ||||||||||||||||||||||||||||||
44 | #include "qquickwindow_p.h" | - | ||||||||||||||||||||||||||||||
45 | #include "qquickevents_p_p.h" | - | ||||||||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||||||||
47 | #include <QtQuick/private/qquickpointerhandler_p.h> | - | ||||||||||||||||||||||||||||||
48 | #include <QtQuick/private/qquicktransition_p.h> | - | ||||||||||||||||||||||||||||||
49 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||||||||
51 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||||||||
52 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||||||||
53 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||||||||||||||
54 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||||||||
55 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||||||||||||||
56 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||||||||
57 | #include "qplatformdefs.h" | - | ||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||
59 | #include <math.h> | - | ||||||||||||||||||||||||||||||
60 | #include <cmath> | - | ||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||
62 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||||||||
64 | // FlickThreshold determines how far the "mouse" must have moved | - | ||||||||||||||||||||||||||||||
65 | // before we perform a flick. | - | ||||||||||||||||||||||||||||||
66 | static const int FlickThreshold = 15; | - | ||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||
68 | // RetainGrabVelocity is the maxmimum instantaneous velocity that | - | ||||||||||||||||||||||||||||||
69 | // will ensure the Flickable retains the grab on consecutive flicks. | - | ||||||||||||||||||||||||||||||
70 | static const int RetainGrabVelocity = 100; | - | ||||||||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||||||||
72 | #ifdef Q_OS_OSX | - | ||||||||||||||||||||||||||||||
73 | static const int MovementEndingTimerInterval = 100; | - | ||||||||||||||||||||||||||||||
74 | #endif | - | ||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||
76 | // Currently std::round can't be used on Android when using ndk g++, so | - | ||||||||||||||||||||||||||||||
77 | // use C version instead. We could just define two versions of Round, one | - | ||||||||||||||||||||||||||||||
78 | // for float and one for double, but then only one of them would be used | - | ||||||||||||||||||||||||||||||
79 | // and compiler would trigger a warning about unused function. | - | ||||||||||||||||||||||||||||||
80 | // | - | ||||||||||||||||||||||||||||||
81 | // See https://code.google.com/p/android/issues/detail?id=54418 | - | ||||||||||||||||||||||||||||||
82 | template<typename T> | - | ||||||||||||||||||||||||||||||
83 | static T Round(T t) { | - | ||||||||||||||||||||||||||||||
84 | return round(t); executed 3734 times by 9 tests: return round(t); Executed by:
| 3734 | ||||||||||||||||||||||||||||||
85 | } | - | ||||||||||||||||||||||||||||||
86 | template<> | - | ||||||||||||||||||||||||||||||
87 | Q_DECL_UNUSED float Round<float>(float f) { | - | ||||||||||||||||||||||||||||||
88 | return roundf(f); never executed: return roundf(f); | 0 | ||||||||||||||||||||||||||||||
89 | } | - | ||||||||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||||||||
91 | static qreal EaseOvershoot(qreal t) { | - | ||||||||||||||||||||||||||||||
92 | return qAtan(t); never executed: return qAtan(t); | 0 | ||||||||||||||||||||||||||||||
93 | } | - | ||||||||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||||||||
95 | QQuickFlickableVisibleArea::QQuickFlickableVisibleArea(QQuickFlickable *parent) | - | ||||||||||||||||||||||||||||||
96 | : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) | - | ||||||||||||||||||||||||||||||
97 | , m_yPosition(0.), m_heightRatio(0.) | - | ||||||||||||||||||||||||||||||
98 | { | - | ||||||||||||||||||||||||||||||
99 | } executed 566 times by 3 tests: end of block Executed by:
| 566 | ||||||||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||||||||
101 | qreal QQuickFlickableVisibleArea::widthRatio() const | - | ||||||||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||||||||
103 | return m_widthRatio; executed 18 times by 2 tests: return m_widthRatio; Executed by:
| 18 | ||||||||||||||||||||||||||||||
104 | } | - | ||||||||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||||||||
106 | qreal QQuickFlickableVisibleArea::xPosition() const | - | ||||||||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||||||||
108 | return m_xPosition; executed 8 times by 1 test: return m_xPosition; Executed by:
| 8 | ||||||||||||||||||||||||||||||
109 | } | - | ||||||||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||||||||
111 | qreal QQuickFlickableVisibleArea::heightRatio() const | - | ||||||||||||||||||||||||||||||
112 | { | - | ||||||||||||||||||||||||||||||
113 | return m_heightRatio; executed 2324 times by 3 tests: return m_heightRatio; Executed by:
| 2324 | ||||||||||||||||||||||||||||||
114 | } | - | ||||||||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||||||||
116 | qreal QQuickFlickableVisibleArea::yPosition() const | - | ||||||||||||||||||||||||||||||
117 | { | - | ||||||||||||||||||||||||||||||
118 | return m_yPosition; executed 18 times by 1 test: return m_yPosition; Executed by:
| 18 | ||||||||||||||||||||||||||||||
119 | } | - | ||||||||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||||||||
121 | void QQuickFlickableVisibleArea::updateVisible() | - | ||||||||||||||||||||||||||||||
122 | { | - | ||||||||||||||||||||||||||||||
123 | QQuickFlickablePrivate *p = QQuickFlickablePrivate::get(flickable); | - | ||||||||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||||||||
125 | bool changeX = false; | - | ||||||||||||||||||||||||||||||
126 | bool changeY = false; | - | ||||||||||||||||||||||||||||||
127 | bool changeWidth = false; | - | ||||||||||||||||||||||||||||||
128 | bool changeHeight = false; | - | ||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||
130 | // Vertical | - | ||||||||||||||||||||||||||||||
131 | const qreal viewheight = flickable->height(); | - | ||||||||||||||||||||||||||||||
132 | const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent(); | - | ||||||||||||||||||||||||||||||
133 | qreal pagePos = (-p->vData.move.value() + flickable->minYExtent()) / (maxyextent + viewheight); | - | ||||||||||||||||||||||||||||||
134 | qreal pageSize = viewheight / (maxyextent + viewheight); | - | ||||||||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||||||||
136 | if (pageSize != m_heightRatio) {
| 2318-2483 | ||||||||||||||||||||||||||||||
137 | m_heightRatio = pageSize; | - | ||||||||||||||||||||||||||||||
138 | changeHeight = true; | - | ||||||||||||||||||||||||||||||
139 | } executed 2318 times by 3 tests: end of block Executed by:
| 2318 | ||||||||||||||||||||||||||||||
140 | if (pagePos != m_yPosition) {
| 946-3855 | ||||||||||||||||||||||||||||||
141 | m_yPosition = pagePos; | - | ||||||||||||||||||||||||||||||
142 | changeY = true; | - | ||||||||||||||||||||||||||||||
143 | } executed 946 times by 3 tests: end of block Executed by:
| 946 | ||||||||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||||||||
145 | // Horizontal | - | ||||||||||||||||||||||||||||||
146 | const qreal viewwidth = flickable->width(); | - | ||||||||||||||||||||||||||||||
147 | const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent(); | - | ||||||||||||||||||||||||||||||
148 | pagePos = (-p->hData.move.value() + flickable->minXExtent()) / (maxxextent + viewwidth); | - | ||||||||||||||||||||||||||||||
149 | pageSize = viewwidth / (maxxextent + viewwidth); | - | ||||||||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||||||||
151 | if (pageSize != m_widthRatio) {
| 584-4217 | ||||||||||||||||||||||||||||||
152 | m_widthRatio = pageSize; | - | ||||||||||||||||||||||||||||||
153 | changeWidth = true; | - | ||||||||||||||||||||||||||||||
154 | } executed 584 times by 3 tests: end of block Executed by:
| 584 | ||||||||||||||||||||||||||||||
155 | if (pagePos != m_xPosition) {
| 14-4787 | ||||||||||||||||||||||||||||||
156 | m_xPosition = pagePos; | - | ||||||||||||||||||||||||||||||
157 | changeX = true; | - | ||||||||||||||||||||||||||||||
158 | } executed 4787 times by 3 tests: end of block Executed by:
| 4787 | ||||||||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||||||||
160 | if (changeX)
| 14-4787 | ||||||||||||||||||||||||||||||
161 | emit xPositionChanged(m_xPosition); executed 4787 times by 3 tests: xPositionChanged(m_xPosition); Executed by:
| 4787 | ||||||||||||||||||||||||||||||
162 | if (changeY)
| 946-3855 | ||||||||||||||||||||||||||||||
163 | emit yPositionChanged(m_yPosition); executed 946 times by 3 tests: yPositionChanged(m_yPosition); Executed by:
| 946 | ||||||||||||||||||||||||||||||
164 | if (changeWidth)
| 584-4217 | ||||||||||||||||||||||||||||||
165 | emit widthRatioChanged(m_widthRatio); executed 584 times by 3 tests: widthRatioChanged(m_widthRatio); Executed by:
| 584 | ||||||||||||||||||||||||||||||
166 | if (changeHeight)
| 2318-2483 | ||||||||||||||||||||||||||||||
167 | emit heightRatioChanged(m_heightRatio); executed 2318 times by 3 tests: heightRatioChanged(m_heightRatio); Executed by:
| 2318 | ||||||||||||||||||||||||||||||
168 | } executed 4801 times by 3 tests: end of block Executed by:
| 4801 | ||||||||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||||||||
171 | class QQuickFlickableReboundTransition : public QQuickTransitionManager | - | ||||||||||||||||||||||||||||||
172 | { | - | ||||||||||||||||||||||||||||||
173 | public: | - | ||||||||||||||||||||||||||||||
174 | QQuickFlickableReboundTransition(QQuickFlickable *f, const QString &name) | - | ||||||||||||||||||||||||||||||
175 | : flickable(f), axisData(nullptr), propName(name), active(false) | - | ||||||||||||||||||||||||||||||
176 | { | - | ||||||||||||||||||||||||||||||
177 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||||||||
179 | ~QQuickFlickableReboundTransition() | - | ||||||||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||||||||
181 | flickable = nullptr; | - | ||||||||||||||||||||||||||||||
182 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||||||||
184 | bool startTransition(QQuickFlickablePrivate::AxisData *data, qreal toPos) { | - | ||||||||||||||||||||||||||||||
185 | QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); | - | ||||||||||||||||||||||||||||||
186 | if (!fp->rebound || !fp->rebound->enabled())
| 0 | ||||||||||||||||||||||||||||||
187 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
188 | active = true; | - | ||||||||||||||||||||||||||||||
189 | axisData = data; | - | ||||||||||||||||||||||||||||||
190 | axisData->transitionTo = toPos; | - | ||||||||||||||||||||||||||||||
191 | axisData->transitionToSet = true; | - | ||||||||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||||||||
193 | actions.clear(); | - | ||||||||||||||||||||||||||||||
194 | actions << QQuickStateAction(fp->contentItem, propName, toPos); | - | ||||||||||||||||||||||||||||||
195 | QQuickTransitionManager::transition(actions, fp->rebound, fp->contentItem); | - | ||||||||||||||||||||||||||||||
196 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
197 | } | - | ||||||||||||||||||||||||||||||
198 | - | |||||||||||||||||||||||||||||||
199 | bool isActive() const { | - | ||||||||||||||||||||||||||||||
200 | return active; never executed: return active; | 0 | ||||||||||||||||||||||||||||||
201 | } | - | ||||||||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||||||||
203 | void stopTransition() { | - | ||||||||||||||||||||||||||||||
204 | if (!flickable || !isRunning())
| 0-4 | ||||||||||||||||||||||||||||||
205 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||||||||
206 | QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); | - | ||||||||||||||||||||||||||||||
207 | if (axisData == &fp->hData)
| 0 | ||||||||||||||||||||||||||||||
208 | axisData->move.setValue(-flickable->contentX()); never executed: axisData->move.setValue(-flickable->contentX()); | 0 | ||||||||||||||||||||||||||||||
209 | else | - | ||||||||||||||||||||||||||||||
210 | axisData->move.setValue(-flickable->contentY()); never executed: axisData->move.setValue(-flickable->contentY()); | 0 | ||||||||||||||||||||||||||||||
211 | cancel(); | - | ||||||||||||||||||||||||||||||
212 | active = false; | - | ||||||||||||||||||||||||||||||
213 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||||||||
215 | protected: | - | ||||||||||||||||||||||||||||||
216 | void finished() override { | - | ||||||||||||||||||||||||||||||
217 | if (!flickable)
| 0 | ||||||||||||||||||||||||||||||
218 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
219 | axisData->move.setValue(axisData->transitionTo); | - | ||||||||||||||||||||||||||||||
220 | QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); | - | ||||||||||||||||||||||||||||||
221 | active = false; | - | ||||||||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||||||||
223 | if (!fp->hData.transitionToBounds->isActive()
| 0 | ||||||||||||||||||||||||||||||
224 | && !fp->vData.transitionToBounds->isActive()) {
| 0 | ||||||||||||||||||||||||||||||
225 | flickable->movementEnding(); | - | ||||||||||||||||||||||||||||||
226 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||
229 | private: | - | ||||||||||||||||||||||||||||||
230 | QQuickStateOperation::ActionList actions; | - | ||||||||||||||||||||||||||||||
231 | QQuickFlickable *flickable; | - | ||||||||||||||||||||||||||||||
232 | QQuickFlickablePrivate::AxisData *axisData; | - | ||||||||||||||||||||||||||||||
233 | QString propName; | - | ||||||||||||||||||||||||||||||
234 | bool active; | - | ||||||||||||||||||||||||||||||
235 | }; | - | ||||||||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||||||||
237 | QQuickFlickablePrivate::AxisData::~AxisData() | - | ||||||||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||||||||
239 | delete transitionToBounds; | - | ||||||||||||||||||||||||||||||
240 | } executed 8184 times by 16 tests: end of block Executed by:
| 8184 | ||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||||||||
243 | QQuickFlickablePrivate::QQuickFlickablePrivate() | - | ||||||||||||||||||||||||||||||
244 | : contentItem(new QQuickItem) | - | ||||||||||||||||||||||||||||||
245 | , hData(this, &QQuickFlickablePrivate::setViewportX) | - | ||||||||||||||||||||||||||||||
246 | , vData(this, &QQuickFlickablePrivate::setViewportY) | - | ||||||||||||||||||||||||||||||
247 | , hMoved(false), vMoved(false) | - | ||||||||||||||||||||||||||||||
248 | , stealMouse(false), pressed(false) | - | ||||||||||||||||||||||||||||||
249 | , scrollingPhase(false), interactive(true), calcVelocity(false) | - | ||||||||||||||||||||||||||||||
250 | , pixelAligned(false) | - | ||||||||||||||||||||||||||||||
251 | , lastPosTime(-1) | - | ||||||||||||||||||||||||||||||
252 | , lastPressTime(0) | - | ||||||||||||||||||||||||||||||
253 | , deceleration(QML_FLICK_DEFAULTDECELERATION) | - | ||||||||||||||||||||||||||||||
254 | , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) | - | ||||||||||||||||||||||||||||||
255 | , delayedPressEvent(nullptr), pressDelay(0), fixupDuration(400) | - | ||||||||||||||||||||||||||||||
256 | , flickBoost(1.0), fixupMode(Normal), vTime(0), visibleArea(nullptr) | - | ||||||||||||||||||||||||||||||
257 | , flickableDirection(QQuickFlickable::AutoFlickDirection) | - | ||||||||||||||||||||||||||||||
258 | , boundsBehavior(QQuickFlickable::DragAndOvershootBounds) | - | ||||||||||||||||||||||||||||||
259 | , boundsMovement(QQuickFlickable::FollowBoundsBehavior) | - | ||||||||||||||||||||||||||||||
260 | , rebound(nullptr) | - | ||||||||||||||||||||||||||||||
261 | { | - | ||||||||||||||||||||||||||||||
262 | } executed 4100 times by 18 tests: end of block Executed by:
| 4100 | ||||||||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||||||||
264 | void QQuickFlickablePrivate::init() | - | ||||||||||||||||||||||||||||||
265 | { | - | ||||||||||||||||||||||||||||||
266 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
267 | QQml_setParent_noEvent(contentItem, q); | - | ||||||||||||||||||||||||||||||
268 | contentItem->setParentItem(q); | - | ||||||||||||||||||||||||||||||
269 | qmlobject_connect(&timeline, QQuickTimeLine, SIGNAL(completed()), executed 36 times by 18 tests: end of block Executed by:
executed 36 times by 18 tests: methodIdx = QQuickFlickable::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickFlickable::staticMetaObject.indexOfSignal(method+1);
| 0-4064 | ||||||||||||||||||||||||||||||
270 | q, QQuickFlickable, SLOT(timelineCompleted())) | - | ||||||||||||||||||||||||||||||
271 | qmlobject_connect(&velocityTimeline, QQuickTimeLine, SIGNAL(completed()), executed 36 times by 18 tests: end of block Executed by:
executed 36 times by 18 tests: methodIdx = QQuickFlickable::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickFlickable::staticMetaObject.indexOfSignal(method+1);
| 0-4064 | ||||||||||||||||||||||||||||||
272 | q, QQuickFlickable, SLOT(velocityTimelineCompleted())) | - | ||||||||||||||||||||||||||||||
273 | q->setAcceptedMouseButtons(Qt::LeftButton); | - | ||||||||||||||||||||||||||||||
274 | q->setAcceptTouchEvents(false); // rely on mouse events synthesized from touch | - | ||||||||||||||||||||||||||||||
275 | q->setFiltersChildMouseEvents(true); | - | ||||||||||||||||||||||||||||||
276 | QQuickItemPrivate *viewportPrivate = QQuickItemPrivate::get(contentItem); | - | ||||||||||||||||||||||||||||||
277 | viewportPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||||||||||||||
278 | } executed 4100 times by 18 tests: end of block Executed by:
| 4100 | ||||||||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||||||||
280 | /* | - | ||||||||||||||||||||||||||||||
281 | Returns the amount to overshoot by given a velocity. | - | ||||||||||||||||||||||||||||||
282 | Will be roughly in range 0 - size/4 | - | ||||||||||||||||||||||||||||||
283 | */ | - | ||||||||||||||||||||||||||||||
284 | qreal QQuickFlickablePrivate::overShootDistance(qreal size) const | - | ||||||||||||||||||||||||||||||
285 | { | - | ||||||||||||||||||||||||||||||
286 | if (maxVelocity <= 0)
| 0-346 | ||||||||||||||||||||||||||||||
287 | return 0.0; never executed: return 0.0; | 0 | ||||||||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||||||||
289 | return qMin(qreal(QML_FLICK_OVERSHOOT), size/3); executed 346 times by 7 tests: return qMin(qreal(150), size/3); Executed by:
| 346 | ||||||||||||||||||||||||||||||
290 | } | - | ||||||||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||||||||
292 | void QQuickFlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity) | - | ||||||||||||||||||||||||||||||
293 | { | - | ||||||||||||||||||||||||||||||
294 | if (v > maxVelocity)
| 501-4869 | ||||||||||||||||||||||||||||||
295 | v = maxVelocity; executed 501 times by 6 tests: v = maxVelocity; Executed by:
| 501 | ||||||||||||||||||||||||||||||
296 | else if (v < -maxVelocity)
| 518-4351 | ||||||||||||||||||||||||||||||
297 | v = -maxVelocity; executed 518 times by 3 tests: v = -maxVelocity; Executed by:
| 518 | ||||||||||||||||||||||||||||||
298 | velocityBuffer.append(v); | - | ||||||||||||||||||||||||||||||
299 | if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER)
| 2504-2866 | ||||||||||||||||||||||||||||||
300 | velocityBuffer.remove(0); executed 2866 times by 7 tests: velocityBuffer.remove(0); Executed by:
| 2866 | ||||||||||||||||||||||||||||||
301 | } executed 5370 times by 7 tests: end of block Executed by:
| 5370 | ||||||||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||||||||
303 | void QQuickFlickablePrivate::AxisData::updateVelocity() | - | ||||||||||||||||||||||||||||||
304 | { | - | ||||||||||||||||||||||||||||||
305 | velocity = 0; | - | ||||||||||||||||||||||||||||||
306 | if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) {
| 700-840 | ||||||||||||||||||||||||||||||
307 | int count = velocityBuffer.count()-QML_FLICK_DISCARDSAMPLES; | - | ||||||||||||||||||||||||||||||
308 | for (int i = 0; i < count; ++i) {
| 840-2326 | ||||||||||||||||||||||||||||||
309 | qreal v = velocityBuffer.at(i); | - | ||||||||||||||||||||||||||||||
310 | velocity += v; | - | ||||||||||||||||||||||||||||||
311 | } executed 2326 times by 7 tests: end of block Executed by:
| 2326 | ||||||||||||||||||||||||||||||
312 | velocity /= count; | - | ||||||||||||||||||||||||||||||
313 | } executed 840 times by 7 tests: end of block Executed by:
| 840 | ||||||||||||||||||||||||||||||
314 | } executed 1540 times by 7 tests: end of block Executed by:
| 1540 | ||||||||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||||||||
316 | void QQuickFlickablePrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) | - | ||||||||||||||||||||||||||||||
317 | { | - | ||||||||||||||||||||||||||||||
318 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
319 | if (item == contentItem) {
| 39814-155234 | ||||||||||||||||||||||||||||||
320 | Qt::Orientations orient = nullptr; | - | ||||||||||||||||||||||||||||||
321 | if (change.xChange())
| 10388-29426 | ||||||||||||||||||||||||||||||
322 | orient |= Qt::Horizontal; executed 10388 times by 7 tests: orient |= Qt::Horizontal; Executed by:
| 10388 | ||||||||||||||||||||||||||||||
323 | if (change.yChange())
| 12988-26826 | ||||||||||||||||||||||||||||||
324 | orient |= Qt::Vertical; executed 12988 times by 7 tests: orient |= Qt::Vertical; Executed by:
| 12988 | ||||||||||||||||||||||||||||||
325 | if (orient)
| 16438-23376 | ||||||||||||||||||||||||||||||
326 | q->viewportMoved(orient); executed 23376 times by 9 tests: q->viewportMoved(orient); Executed by:
| 23376 | ||||||||||||||||||||||||||||||
327 | if (orient & Qt::Horizontal)
| 10388-29426 | ||||||||||||||||||||||||||||||
328 | emit q->contentXChanged(); executed 10388 times by 7 tests: q->contentXChanged(); Executed by:
| 10388 | ||||||||||||||||||||||||||||||
329 | if (orient & Qt::Vertical)
| 12988-26826 | ||||||||||||||||||||||||||||||
330 | emit q->contentYChanged(); executed 12988 times by 7 tests: q->contentYChanged(); Executed by:
| 12988 | ||||||||||||||||||||||||||||||
331 | } executed 39814 times by 17 tests: end of block Executed by:
| 39814 | ||||||||||||||||||||||||||||||
332 | } executed 195048 times by 17 tests: end of block Executed by:
| 195048 | ||||||||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||||||||
334 | bool QQuickFlickablePrivate::flickX(qreal velocity) | - | ||||||||||||||||||||||||||||||
335 | { | - | ||||||||||||||||||||||||||||||
336 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
337 | return flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity); executed 1271 times by 6 tests: return flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity); Executed by:
| 1271 | ||||||||||||||||||||||||||||||
338 | } | - | ||||||||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||||||||
340 | bool QQuickFlickablePrivate::flickY(qreal velocity) | - | ||||||||||||||||||||||||||||||
341 | { | - | ||||||||||||||||||||||||||||||
342 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
343 | return flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); executed 1278 times by 5 tests: return flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); Executed by:
| 1278 | ||||||||||||||||||||||||||||||
344 | } | - | ||||||||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||||||||
346 | bool QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, | - | ||||||||||||||||||||||||||||||
347 | QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) | - | ||||||||||||||||||||||||||||||
348 | { | - | ||||||||||||||||||||||||||||||
349 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
350 | qreal maxDistance = -1; | - | ||||||||||||||||||||||||||||||
351 | data.fixingUp = false; | - | ||||||||||||||||||||||||||||||
352 | // -ve velocity means list is moving up | - | ||||||||||||||||||||||||||||||
353 | if (velocity > 0) {
| 164-169 | ||||||||||||||||||||||||||||||
354 | maxDistance = qAbs(minExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
355 | data.flickTarget = minExtent; | - | ||||||||||||||||||||||||||||||
356 | } else { executed 164 times by 7 tests: end of block Executed by:
| 164 | ||||||||||||||||||||||||||||||
357 | maxDistance = qAbs(maxExtent - data.move.value()); | - | ||||||||||||||||||||||||||||||
358 | data.flickTarget = maxExtent; | - | ||||||||||||||||||||||||||||||
359 | } executed 169 times by 4 tests: end of block Executed by:
| 169 | ||||||||||||||||||||||||||||||
360 | if (maxDistance > 0 || boundsBehavior & QQuickFlickable::OvershootBounds) {
| 48-285 | ||||||||||||||||||||||||||||||
361 | qreal v = velocity; | - | ||||||||||||||||||||||||||||||
362 | if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
| 0-317 | ||||||||||||||||||||||||||||||
363 | if (v < 0)
| 0 | ||||||||||||||||||||||||||||||
364 | v = -maxVelocity; never executed: v = -maxVelocity; | 0 | ||||||||||||||||||||||||||||||
365 | else | - | ||||||||||||||||||||||||||||||
366 | v = maxVelocity; never executed: v = maxVelocity; | 0 | ||||||||||||||||||||||||||||||
367 | } | - | ||||||||||||||||||||||||||||||
368 | - | |||||||||||||||||||||||||||||||
369 | // adjust accel so that we hit a full pixel | - | ||||||||||||||||||||||||||||||
370 | qreal accel = deceleration; | - | ||||||||||||||||||||||||||||||
371 | qreal v2 = v * v; | - | ||||||||||||||||||||||||||||||
372 | qreal dist = v2 / (accel * 2.0); | - | ||||||||||||||||||||||||||||||
373 | if (v > 0)
| 156-161 | ||||||||||||||||||||||||||||||
374 | dist = -dist; executed 156 times by 7 tests: dist = -dist; Executed by:
| 156 | ||||||||||||||||||||||||||||||
375 | qreal target = -Round(-(data.move.value() - dist)); | - | ||||||||||||||||||||||||||||||
376 | dist = -target + data.move.value(); | - | ||||||||||||||||||||||||||||||
377 | accel = v2 / (2.0f * qAbs(dist)); | - | ||||||||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||||||||
379 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
380 | if (!data.inOvershoot) {
| 0-317 | ||||||||||||||||||||||||||||||
381 | if (boundsBehavior & QQuickFlickable::OvershootBounds)
| 84-233 | ||||||||||||||||||||||||||||||
382 | timeline.accel(data.move, v, accel); executed 233 times by 7 tests: timeline.accel(data.move, v, accel); Executed by:
| 233 | ||||||||||||||||||||||||||||||
383 | else | - | ||||||||||||||||||||||||||||||
384 | timeline.accel(data.move, v, accel, maxDistance); executed 84 times by 1 test: timeline.accel(data.move, v, accel, maxDistance); Executed by:
| 84 | ||||||||||||||||||||||||||||||
385 | } | - | ||||||||||||||||||||||||||||||
386 | timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); | - | ||||||||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||||||||
388 | if (&data == &hData)
| 140-177 | ||||||||||||||||||||||||||||||
389 | return !hData.flicking && q->xflick(); executed 140 times by 5 tests: return !hData.flicking && q->xflick(); Executed by:
| 140 | ||||||||||||||||||||||||||||||
390 | else if (&data == &vData)
| 0-177 | ||||||||||||||||||||||||||||||
391 | return !vData.flicking && q->yflick(); executed 177 times by 5 tests: return !vData.flicking && q->yflick(); Executed by:
| 177 | ||||||||||||||||||||||||||||||
392 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
393 | } else { | - | ||||||||||||||||||||||||||||||
394 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
395 | fixup(data, minExtent, maxExtent); | - | ||||||||||||||||||||||||||||||
396 | return false; executed 16 times by 1 test: return false; Executed by:
| 16 | ||||||||||||||||||||||||||||||
397 | } | - | ||||||||||||||||||||||||||||||
398 | } | - | ||||||||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||||||||
400 | void QQuickFlickablePrivate::fixupY_callback(void *data) | - | ||||||||||||||||||||||||||||||
401 | { | - | ||||||||||||||||||||||||||||||
402 | ((QQuickFlickablePrivate *)data)->fixupY(); | - | ||||||||||||||||||||||||||||||
403 | } executed 289 times by 5 tests: end of block Executed by:
| 289 | ||||||||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||||||||
405 | void QQuickFlickablePrivate::fixupX_callback(void *data) | - | ||||||||||||||||||||||||||||||
406 | { | - | ||||||||||||||||||||||||||||||
407 | ((QQuickFlickablePrivate *)data)->fixupX(); | - | ||||||||||||||||||||||||||||||
408 | } executed 320 times by 5 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||||||||
410 | void QQuickFlickablePrivate::fixupX() | - | ||||||||||||||||||||||||||||||
411 | { | - | ||||||||||||||||||||||||||||||
412 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
413 | if (!q->isComponentComplete())
| 4010-5728 | ||||||||||||||||||||||||||||||
414 | return; //Do not fixup from initialization values executed 4010 times by 14 tests: return; Executed by:
| 4010 | ||||||||||||||||||||||||||||||
415 | fixup(hData, q->minXExtent(), q->maxXExtent()); | - | ||||||||||||||||||||||||||||||
416 | } executed 5728 times by 12 tests: end of block Executed by:
| 5728 | ||||||||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||||||||
418 | void QQuickFlickablePrivate::fixupY() | - | ||||||||||||||||||||||||||||||
419 | { | - | ||||||||||||||||||||||||||||||
420 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
421 | if (!q->isComponentComplete())
| 6382-17873 | ||||||||||||||||||||||||||||||
422 | return; //Do not fixup from initialization values executed 6382 times by 14 tests: return; Executed by:
| 6382 | ||||||||||||||||||||||||||||||
423 | fixup(vData, q->minYExtent(), q->maxYExtent()); | - | ||||||||||||||||||||||||||||||
424 | } executed 17873 times by 17 tests: end of block Executed by:
| 17873 | ||||||||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||||||||
426 | void QQuickFlickablePrivate::adjustContentPos(AxisData &data, qreal toPos) | - | ||||||||||||||||||||||||||||||
427 | { | - | ||||||||||||||||||||||||||||||
428 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
429 | switch (fixupMode) { | - | ||||||||||||||||||||||||||||||
430 | case Immediate: executed 3528 times by 5 tests: case Immediate: Executed by:
| 3528 | ||||||||||||||||||||||||||||||
431 | timeline.set(data.move, toPos); | - | ||||||||||||||||||||||||||||||
432 | break; executed 3528 times by 5 tests: break; Executed by:
| 3528 | ||||||||||||||||||||||||||||||
433 | case ExtentChanged: executed 51 times by 1 test: case ExtentChanged: Executed by:
| 51 | ||||||||||||||||||||||||||||||
434 | // The target has changed. Don't start from the beginning; just complete the | - | ||||||||||||||||||||||||||||||
435 | // second half of the animation using the new extent. | - | ||||||||||||||||||||||||||||||
436 | timeline.move(data.move, toPos, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); | - | ||||||||||||||||||||||||||||||
437 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
438 | break; executed 51 times by 1 test: break; Executed by:
| 51 | ||||||||||||||||||||||||||||||
439 | default: { executed 325 times by 7 tests: default: Executed by:
| 325 | ||||||||||||||||||||||||||||||
440 | if (data.transitionToBounds && data.transitionToBounds->startTransition(&data, toPos)) {
| 0-325 | ||||||||||||||||||||||||||||||
441 | q->movementStarting(); | - | ||||||||||||||||||||||||||||||
442 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
443 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
444 | qreal dist = toPos - data.move; | - | ||||||||||||||||||||||||||||||
445 | timeline.move(data.move, toPos - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); | - | ||||||||||||||||||||||||||||||
446 | timeline.move(data.move, toPos, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); | - | ||||||||||||||||||||||||||||||
447 | data.fixingUp = true; | - | ||||||||||||||||||||||||||||||
448 | } executed 325 times by 7 tests: end of block Executed by:
| 325 | ||||||||||||||||||||||||||||||
449 | } | - | ||||||||||||||||||||||||||||||
450 | } | - | ||||||||||||||||||||||||||||||
451 | } | - | ||||||||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||||||||
453 | void QQuickFlickablePrivate::resetTimeline(AxisData &data) | - | ||||||||||||||||||||||||||||||
454 | { | - | ||||||||||||||||||||||||||||||
455 | timeline.reset(data.move); | - | ||||||||||||||||||||||||||||||
456 | if (data.transitionToBounds)
| 4-44190 | ||||||||||||||||||||||||||||||
457 | data.transitionToBounds->stopTransition(); executed 4 times by 1 test: data.transitionToBounds->stopTransition(); Executed by:
| 4 | ||||||||||||||||||||||||||||||
458 | } executed 44194 times by 17 tests: end of block Executed by:
| 44194 | ||||||||||||||||||||||||||||||
459 | - | |||||||||||||||||||||||||||||||
460 | void QQuickFlickablePrivate::clearTimeline() | - | ||||||||||||||||||||||||||||||
461 | { | - | ||||||||||||||||||||||||||||||
462 | timeline.clear(); | - | ||||||||||||||||||||||||||||||
463 | if (hData.transitionToBounds)
| 0-2832 | ||||||||||||||||||||||||||||||
464 | hData.transitionToBounds->stopTransition(); never executed: hData.transitionToBounds->stopTransition(); | 0 | ||||||||||||||||||||||||||||||
465 | if (vData.transitionToBounds)
| 0-2832 | ||||||||||||||||||||||||||||||
466 | vData.transitionToBounds->stopTransition(); never executed: vData.transitionToBounds->stopTransition(); | 0 | ||||||||||||||||||||||||||||||
467 | } executed 2832 times by 7 tests: end of block Executed by:
| 2832 | ||||||||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||||||||
469 | void QQuickFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) | - | ||||||||||||||||||||||||||||||
470 | { | - | ||||||||||||||||||||||||||||||
471 | if (data.move.value() >= minExtent || maxExtent > minExtent) {
| 0-15399 | ||||||||||||||||||||||||||||||
472 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
473 | if (data.move.value() != minExtent) {
| 320-15079 | ||||||||||||||||||||||||||||||
474 | adjustContentPos(data, minExtent); | - | ||||||||||||||||||||||||||||||
475 | } executed 320 times by 7 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||||||||
476 | } else if (data.move.value() <= maxExtent) { executed 15399 times by 17 tests: end of block Executed by:
| 2904-15399 | ||||||||||||||||||||||||||||||
477 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
478 | adjustContentPos(data, maxExtent); | - | ||||||||||||||||||||||||||||||
479 | } else if (-Round(-data.move.value()) != data.move.value()) { executed 3584 times by 6 tests: end of block Executed by:
| 70-3584 | ||||||||||||||||||||||||||||||
480 | // We could animate, but since it is less than 0.5 pixel it's probably not worthwhile. | - | ||||||||||||||||||||||||||||||
481 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
482 | qreal val = data.move.value(); | - | ||||||||||||||||||||||||||||||
483 | if (std::abs(-Round(-val) - val) < 0.25) // round small differences
| 11-59 | ||||||||||||||||||||||||||||||
484 | val = -Round(-val); executed 59 times by 3 tests: val = -Round(-val); Executed by:
| 59 | ||||||||||||||||||||||||||||||
485 | else if (data.smoothVelocity.value() > 0) // continue direction of motion for larger
| 5-6 | ||||||||||||||||||||||||||||||
486 | val = -std::floor(-val); executed 5 times by 1 test: val = -std::floor(-val); Executed by:
| 5 | ||||||||||||||||||||||||||||||
487 | else if (data.smoothVelocity.value() < 0)
| 0-6 | ||||||||||||||||||||||||||||||
488 | val = -std::ceil(-val); never executed: val = -std::ceil(-val); | 0 | ||||||||||||||||||||||||||||||
489 | else // otherwise round | - | ||||||||||||||||||||||||||||||
490 | val = -Round(-val); executed 6 times by 2 tests: val = -Round(-val); Executed by:
| 6 | ||||||||||||||||||||||||||||||
491 | timeline.set(data.move, val); | - | ||||||||||||||||||||||||||||||
492 | } executed 70 times by 3 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||||||||
493 | data.inOvershoot = false; | - | ||||||||||||||||||||||||||||||
494 | fixupMode = Normal; | - | ||||||||||||||||||||||||||||||
495 | data.vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
496 | } executed 21887 times by 17 tests: end of block Executed by:
| 21887 | ||||||||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||||||||
498 | static bool fuzzyLessThanOrEqualTo(qreal a, qreal b) | - | ||||||||||||||||||||||||||||||
499 | { | - | ||||||||||||||||||||||||||||||
500 | if (a == 0.0 || b == 0.0) {
| 66305-143646 | ||||||||||||||||||||||||||||||
501 | // qFuzzyCompare is broken | - | ||||||||||||||||||||||||||||||
502 | a += 1.0; | - | ||||||||||||||||||||||||||||||
503 | b += 1.0; | - | ||||||||||||||||||||||||||||||
504 | } executed 175763 times by 18 tests: end of block Executed by:
| 175763 | ||||||||||||||||||||||||||||||
505 | return a <= b || qFuzzyCompare(a, b); executed 242068 times by 18 tests: return a <= b || qFuzzyCompare(a, b); Executed by:
| 242068 | ||||||||||||||||||||||||||||||
506 | } | - | ||||||||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||||||||
508 | void QQuickFlickablePrivate::updateBeginningEnd() | - | ||||||||||||||||||||||||||||||
509 | { | - | ||||||||||||||||||||||||||||||
510 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
511 | bool atBoundaryChange = false; | - | ||||||||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||||||||
513 | // Vertical | - | ||||||||||||||||||||||||||||||
514 | const qreal maxyextent = -q->maxYExtent(); | - | ||||||||||||||||||||||||||||||
515 | const qreal minyextent = -q->minYExtent(); | - | ||||||||||||||||||||||||||||||
516 | const qreal ypos = -vData.move.value(); | - | ||||||||||||||||||||||||||||||
517 | bool atBeginning = fuzzyLessThanOrEqualTo(ypos, minyextent); | - | ||||||||||||||||||||||||||||||
518 | bool atEnd = fuzzyLessThanOrEqualTo(maxyextent, ypos); | - | ||||||||||||||||||||||||||||||
519 | - | |||||||||||||||||||||||||||||||
520 | if (atBeginning != vData.atBeginning) {
| 2230-57676 | ||||||||||||||||||||||||||||||
521 | vData.atBeginning = atBeginning; | - | ||||||||||||||||||||||||||||||
522 | atBoundaryChange = true; | - | ||||||||||||||||||||||||||||||
523 | } executed 2230 times by 6 tests: end of block Executed by:
| 2230 | ||||||||||||||||||||||||||||||
524 | if (atEnd != vData.atEnd) {
| 8187-51719 | ||||||||||||||||||||||||||||||
525 | vData.atEnd = atEnd; | - | ||||||||||||||||||||||||||||||
526 | atBoundaryChange = true; | - | ||||||||||||||||||||||||||||||
527 | } executed 8187 times by 17 tests: end of block Executed by:
| 8187 | ||||||||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||||||||
529 | // Horizontal | - | ||||||||||||||||||||||||||||||
530 | const qreal maxxextent = -q->maxXExtent(); | - | ||||||||||||||||||||||||||||||
531 | const qreal minxextent = -q->minXExtent(); | - | ||||||||||||||||||||||||||||||
532 | const qreal xpos = -hData.move.value(); | - | ||||||||||||||||||||||||||||||
533 | atBeginning = fuzzyLessThanOrEqualTo(xpos, minxextent); | - | ||||||||||||||||||||||||||||||
534 | atEnd = fuzzyLessThanOrEqualTo(maxxextent, xpos); | - | ||||||||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||||||||
536 | if (atBeginning != hData.atBeginning) {
| 1294-58612 | ||||||||||||||||||||||||||||||
537 | hData.atBeginning = atBeginning; | - | ||||||||||||||||||||||||||||||
538 | atBoundaryChange = true; | - | ||||||||||||||||||||||||||||||
539 | } executed 1294 times by 6 tests: end of block Executed by:
| 1294 | ||||||||||||||||||||||||||||||
540 | if (atEnd != hData.atEnd) {
| 5502-54404 | ||||||||||||||||||||||||||||||
541 | hData.atEnd = atEnd; | - | ||||||||||||||||||||||||||||||
542 | atBoundaryChange = true; | - | ||||||||||||||||||||||||||||||
543 | } executed 5502 times by 17 tests: end of block Executed by:
| 5502 | ||||||||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||||||||
545 | if (vData.extentsChanged) {
| 27283-32623 | ||||||||||||||||||||||||||||||
546 | vData.extentsChanged = false; | - | ||||||||||||||||||||||||||||||
547 | qreal originY = q->originY(); | - | ||||||||||||||||||||||||||||||
548 | if (vData.origin != originY) {
| 1533-25750 | ||||||||||||||||||||||||||||||
549 | vData.origin = originY; | - | ||||||||||||||||||||||||||||||
550 | emit q->originYChanged(); | - | ||||||||||||||||||||||||||||||
551 | } executed 1533 times by 3 tests: end of block Executed by:
| 1533 | ||||||||||||||||||||||||||||||
552 | } executed 27283 times by 17 tests: end of block Executed by:
| 27283 | ||||||||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||||||||
554 | if (hData.extentsChanged) {
| 6267-53639 | ||||||||||||||||||||||||||||||
555 | hData.extentsChanged = false; | - | ||||||||||||||||||||||||||||||
556 | qreal originX = q->originX(); | - | ||||||||||||||||||||||||||||||
557 | if (hData.origin != originX) {
| 1076-5191 | ||||||||||||||||||||||||||||||
558 | hData.origin = originX; | - | ||||||||||||||||||||||||||||||
559 | emit q->originXChanged(); | - | ||||||||||||||||||||||||||||||
560 | } executed 1076 times by 3 tests: end of block Executed by:
| 1076 | ||||||||||||||||||||||||||||||
561 | } executed 6267 times by 9 tests: end of block Executed by:
| 6267 | ||||||||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||||||||
563 | if (atBoundaryChange)
| 12573-47333 | ||||||||||||||||||||||||||||||
564 | emit q->isAtBoundaryChanged(); executed 12573 times by 18 tests: q->isAtBoundaryChanged(); Executed by:
| 12573 | ||||||||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||||||||
566 | if (visibleArea)
| 4235-55671 | ||||||||||||||||||||||||||||||
567 | visibleArea->updateVisible(); executed 4235 times by 3 tests: visibleArea->updateVisible(); Executed by:
| 4235 | ||||||||||||||||||||||||||||||
568 | } executed 59906 times by 18 tests: end of block Executed by:
| 59906 | ||||||||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||||||||
570 | /*! | - | ||||||||||||||||||||||||||||||
571 | \qmlsignal QtQuick::Flickable::dragStarted() | - | ||||||||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||||||||
573 | This signal is emitted when the view starts to be dragged due to user | - | ||||||||||||||||||||||||||||||
574 | interaction. | - | ||||||||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||||||||
576 | The corresponding handler is \c onDragStarted. | - | ||||||||||||||||||||||||||||||
577 | */ | - | ||||||||||||||||||||||||||||||
578 | - | |||||||||||||||||||||||||||||||
579 | /*! | - | ||||||||||||||||||||||||||||||
580 | \qmlsignal QtQuick::Flickable::dragEnded() | - | ||||||||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||||||||
582 | This signal is emitted when the user stops dragging the view. | - | ||||||||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||||||||
584 | If the velocity of the drag is sufficient at the time the | - | ||||||||||||||||||||||||||||||
585 | touch/mouse button is released then a flick will start. | - | ||||||||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||||||||
587 | The corresponding handler is \c onDragEnded. | - | ||||||||||||||||||||||||||||||
588 | */ | - | ||||||||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||||||||
590 | /*! | - | ||||||||||||||||||||||||||||||
591 | \qmltype Flickable | - | ||||||||||||||||||||||||||||||
592 | \instantiates QQuickFlickable | - | ||||||||||||||||||||||||||||||
593 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
594 | \ingroup qtquick-input | - | ||||||||||||||||||||||||||||||
595 | \ingroup qtquick-containers | - | ||||||||||||||||||||||||||||||
596 | - | |||||||||||||||||||||||||||||||
597 | \brief Provides a surface that can be "flicked". | - | ||||||||||||||||||||||||||||||
598 | \inherits Item | - | ||||||||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||||||||
600 | The Flickable item places its children on a surface that can be dragged | - | ||||||||||||||||||||||||||||||
601 | and flicked, causing the view onto the child items to scroll. This | - | ||||||||||||||||||||||||||||||
602 | behavior forms the basis of Items that are designed to show large numbers | - | ||||||||||||||||||||||||||||||
603 | of child items, such as \l ListView and \l GridView. | - | ||||||||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||||||||
605 | In traditional user interfaces, views can be scrolled using standard | - | ||||||||||||||||||||||||||||||
606 | controls, such as scroll bars and arrow buttons. In some situations, it | - | ||||||||||||||||||||||||||||||
607 | is also possible to drag the view directly by pressing and holding a | - | ||||||||||||||||||||||||||||||
608 | mouse button while moving the cursor. In touch-based user interfaces, | - | ||||||||||||||||||||||||||||||
609 | this dragging action is often complemented with a flicking action, where | - | ||||||||||||||||||||||||||||||
610 | scrolling continues after the user has stopped touching the view. | - | ||||||||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||||||||
612 | Flickable does not automatically clip its contents. If it is not used as | - | ||||||||||||||||||||||||||||||
613 | a full-screen item, you should consider setting the \l{Item::}{clip} property | - | ||||||||||||||||||||||||||||||
614 | to true. | - | ||||||||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||||||||
616 | \section1 Example Usage | - | ||||||||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||||||||
618 | \div {class="float-right"} | - | ||||||||||||||||||||||||||||||
619 | \inlineimage flickable.gif | - | ||||||||||||||||||||||||||||||
620 | \enddiv | - | ||||||||||||||||||||||||||||||
621 | - | |||||||||||||||||||||||||||||||
622 | The following example shows a small view onto a large image in which the | - | ||||||||||||||||||||||||||||||
623 | user can drag or flick the image in order to view different parts of it. | - | ||||||||||||||||||||||||||||||
624 | - | |||||||||||||||||||||||||||||||
625 | \snippet qml/flickable.qml document | - | ||||||||||||||||||||||||||||||
626 | - | |||||||||||||||||||||||||||||||
627 | \clearfloat | - | ||||||||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||||||||
629 | Items declared as children of a Flickable are automatically parented to the | - | ||||||||||||||||||||||||||||||
630 | Flickable's \l contentItem. This should be taken into account when | - | ||||||||||||||||||||||||||||||
631 | operating on the children of the Flickable; it is usually the children of | - | ||||||||||||||||||||||||||||||
632 | \c contentItem that are relevant. For example, the bound of Items added | - | ||||||||||||||||||||||||||||||
633 | to the Flickable will be available by \c contentItem.childrenRect | - | ||||||||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||||||||
635 | \section1 Limitations | - | ||||||||||||||||||||||||||||||
636 | - | |||||||||||||||||||||||||||||||
637 | \note Due to an implementation detail, items placed inside a Flickable | - | ||||||||||||||||||||||||||||||
638 | cannot anchor to the Flickable. Instead, use \l {Item::}{parent}, which | - | ||||||||||||||||||||||||||||||
639 | refers to the Flickable's \l contentItem. The size of the content item is | - | ||||||||||||||||||||||||||||||
640 | determined by \l contentWidth and \l contentHeight. | - | ||||||||||||||||||||||||||||||
641 | */ | - | ||||||||||||||||||||||||||||||
642 | - | |||||||||||||||||||||||||||||||
643 | /*! | - | ||||||||||||||||||||||||||||||
644 | \qmlsignal QtQuick::Flickable::movementStarted() | - | ||||||||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||||||||
646 | This signal is emitted when the view begins moving due to user | - | ||||||||||||||||||||||||||||||
647 | interaction or a generated flick(). | - | ||||||||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||||||||
649 | The corresponding handler is \c onMovementStarted. | - | ||||||||||||||||||||||||||||||
650 | */ | - | ||||||||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||||||||
652 | /*! | - | ||||||||||||||||||||||||||||||
653 | \qmlsignal QtQuick::Flickable::movementEnded() | - | ||||||||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||||||||
655 | This signal is emitted when the view stops moving due to user | - | ||||||||||||||||||||||||||||||
656 | interaction or a generated flick(). If a flick was active, this signal will | - | ||||||||||||||||||||||||||||||
657 | be emitted once the flick stops. If a flick was not | - | ||||||||||||||||||||||||||||||
658 | active, this signal will be emitted when the | - | ||||||||||||||||||||||||||||||
659 | user stops dragging - i.e. a mouse or touch release. | - | ||||||||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||||||||
661 | The corresponding handler is \c onMovementEnded. | - | ||||||||||||||||||||||||||||||
662 | */ | - | ||||||||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||||||||
664 | /*! | - | ||||||||||||||||||||||||||||||
665 | \qmlsignal QtQuick::Flickable::flickStarted() | - | ||||||||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||||||||
667 | This signal is emitted when the view is flicked. A flick | - | ||||||||||||||||||||||||||||||
668 | starts from the point that the mouse or touch is released, | - | ||||||||||||||||||||||||||||||
669 | while still in motion. | - | ||||||||||||||||||||||||||||||
670 | - | |||||||||||||||||||||||||||||||
671 | The corresponding handler is \c onFlickStarted. | - | ||||||||||||||||||||||||||||||
672 | */ | - | ||||||||||||||||||||||||||||||
673 | - | |||||||||||||||||||||||||||||||
674 | /*! | - | ||||||||||||||||||||||||||||||
675 | \qmlsignal QtQuick::Flickable::flickEnded() | - | ||||||||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||||||||
677 | This signal is emitted when the view stops moving due to a flick. | - | ||||||||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||||||||
679 | The corresponding handler is \c onFlickEnded. | - | ||||||||||||||||||||||||||||||
680 | */ | - | ||||||||||||||||||||||||||||||
681 | - | |||||||||||||||||||||||||||||||
682 | /*! | - | ||||||||||||||||||||||||||||||
683 | \qmlpropertygroup QtQuick::Flickable::visibleArea | - | ||||||||||||||||||||||||||||||
684 | \qmlproperty real QtQuick::Flickable::visibleArea.xPosition | - | ||||||||||||||||||||||||||||||
685 | \qmlproperty real QtQuick::Flickable::visibleArea.widthRatio | - | ||||||||||||||||||||||||||||||
686 | \qmlproperty real QtQuick::Flickable::visibleArea.yPosition | - | ||||||||||||||||||||||||||||||
687 | \qmlproperty real QtQuick::Flickable::visibleArea.heightRatio | - | ||||||||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||||||||
689 | These properties describe the position and size of the currently viewed area. | - | ||||||||||||||||||||||||||||||
690 | The size is defined as the percentage of the full view currently visible, | - | ||||||||||||||||||||||||||||||
691 | scaled to 0.0 - 1.0. The page position is usually in the range 0.0 (beginning) to | - | ||||||||||||||||||||||||||||||
692 | 1.0 minus size ratio (end), i.e. \c yPosition is in the range 0.0 to 1.0-\c heightRatio. | - | ||||||||||||||||||||||||||||||
693 | However, it is possible for the contents to be dragged outside of the normal | - | ||||||||||||||||||||||||||||||
694 | range, resulting in the page positions also being outside the normal range. | - | ||||||||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||||||||
696 | These properties are typically used to draw a scrollbar. For example: | - | ||||||||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||||||||
698 | \snippet qml/flickableScrollbar.qml 0 | - | ||||||||||||||||||||||||||||||
699 | \dots 8 | - | ||||||||||||||||||||||||||||||
700 | \snippet qml/flickableScrollbar.qml 1 | - | ||||||||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||||||||
702 | \sa {customitems/scrollbar}{UI Components: Scrollbar Example} | - | ||||||||||||||||||||||||||||||
703 | */ | - | ||||||||||||||||||||||||||||||
704 | QQuickFlickable::QQuickFlickable(QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
705 | : QQuickItem(*(new QQuickFlickablePrivate), parent) | - | ||||||||||||||||||||||||||||||
706 | { | - | ||||||||||||||||||||||||||||||
707 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
708 | d->init(); | - | ||||||||||||||||||||||||||||||
709 | } executed 296 times by 7 tests: end of block Executed by:
| 296 | ||||||||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||||||||
711 | QQuickFlickable::QQuickFlickable(QQuickFlickablePrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
712 | : QQuickItem(dd, parent) | - | ||||||||||||||||||||||||||||||
713 | { | - | ||||||||||||||||||||||||||||||
714 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
715 | d->init(); | - | ||||||||||||||||||||||||||||||
716 | } executed 3804 times by 13 tests: end of block Executed by:
| 3804 | ||||||||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||||||||
718 | QQuickFlickable::~QQuickFlickable() | - | ||||||||||||||||||||||||||||||
719 | { | - | ||||||||||||||||||||||||||||||
720 | } | - | ||||||||||||||||||||||||||||||
721 | - | |||||||||||||||||||||||||||||||
722 | /*! | - | ||||||||||||||||||||||||||||||
723 | \qmlproperty real QtQuick::Flickable::contentX | - | ||||||||||||||||||||||||||||||
724 | \qmlproperty real QtQuick::Flickable::contentY | - | ||||||||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||||||||
726 | These properties hold the surface coordinate currently at the top-left | - | ||||||||||||||||||||||||||||||
727 | corner of the Flickable. For example, if you flick an image up 100 pixels, | - | ||||||||||||||||||||||||||||||
728 | \c contentY will increase by 100. | - | ||||||||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||||||||
730 | \note If you flick back to the origin (the top-left corner), after the | - | ||||||||||||||||||||||||||||||
731 | rebound animation, \c contentX will settle to the same value as \c originX, | - | ||||||||||||||||||||||||||||||
732 | and \c contentY to \c originY. These are usually (0,0), however ListView | - | ||||||||||||||||||||||||||||||
733 | and GridView may have an arbitrary origin due to delegate size variation, | - | ||||||||||||||||||||||||||||||
734 | or item insertion/removal outside the visible region. So if you want to | - | ||||||||||||||||||||||||||||||
735 | implement something like a vertical scrollbar, one way is to use | - | ||||||||||||||||||||||||||||||
736 | \c {y: (contentY - originY) * (height / contentHeight)} | - | ||||||||||||||||||||||||||||||
737 | for the position; another way is to use the normalized values in | - | ||||||||||||||||||||||||||||||
738 | \l {QtQuick::Flickable::visibleArea}{visibleArea}. | - | ||||||||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||||||||
740 | \sa originX, originY | - | ||||||||||||||||||||||||||||||
741 | */ | - | ||||||||||||||||||||||||||||||
742 | qreal QQuickFlickable::contentX() const | - | ||||||||||||||||||||||||||||||
743 | { | - | ||||||||||||||||||||||||||||||
744 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
745 | return -d->contentItem->x(); executed 65931 times by 10 tests: return -d->contentItem->x(); Executed by:
| 65931 | ||||||||||||||||||||||||||||||
746 | } | - | ||||||||||||||||||||||||||||||
747 | - | |||||||||||||||||||||||||||||||
748 | void QQuickFlickable::setContentX(qreal pos) | - | ||||||||||||||||||||||||||||||
749 | { | - | ||||||||||||||||||||||||||||||
750 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
751 | d->hData.explicitValue = true; | - | ||||||||||||||||||||||||||||||
752 | d->resetTimeline(d->hData); | - | ||||||||||||||||||||||||||||||
753 | d->hData.vTime = d->timeline.time(); | - | ||||||||||||||||||||||||||||||
754 | if (isMoving() || isFlicking())
| 0-8592 | ||||||||||||||||||||||||||||||
755 | movementEnding(true, false); executed 24 times by 2 tests: movementEnding(true, false); Executed by:
| 24 | ||||||||||||||||||||||||||||||
756 | if (-pos != d->hData.move.value())
| 1647-6969 | ||||||||||||||||||||||||||||||
757 | d->hData.move.setValue(-pos); executed 1647 times by 6 tests: d->hData.move.setValue(-pos); Executed by:
| 1647 | ||||||||||||||||||||||||||||||
758 | } executed 8616 times by 8 tests: end of block Executed by:
| 8616 | ||||||||||||||||||||||||||||||
759 | - | |||||||||||||||||||||||||||||||
760 | qreal QQuickFlickable::contentY() const | - | ||||||||||||||||||||||||||||||
761 | { | - | ||||||||||||||||||||||||||||||
762 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
763 | return -d->contentItem->y(); executed 136739 times by 15 tests: return -d->contentItem->y(); Executed by:
| 136739 | ||||||||||||||||||||||||||||||
764 | } | - | ||||||||||||||||||||||||||||||
765 | - | |||||||||||||||||||||||||||||||
766 | void QQuickFlickable::setContentY(qreal pos) | - | ||||||||||||||||||||||||||||||
767 | { | - | ||||||||||||||||||||||||||||||
768 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
769 | d->vData.explicitValue = true; | - | ||||||||||||||||||||||||||||||
770 | d->resetTimeline(d->vData); | - | ||||||||||||||||||||||||||||||
771 | d->vData.vTime = d->timeline.time(); | - | ||||||||||||||||||||||||||||||
772 | if (isMoving() || isFlicking())
| 0-13909 | ||||||||||||||||||||||||||||||
773 | movementEnding(false, true); executed 24 times by 2 tests: movementEnding(false, true); Executed by:
| 24 | ||||||||||||||||||||||||||||||
774 | if (-pos != d->vData.move.value())
| 3501-10432 | ||||||||||||||||||||||||||||||
775 | d->vData.move.setValue(-pos); executed 3501 times by 6 tests: d->vData.move.setValue(-pos); Executed by:
| 3501 | ||||||||||||||||||||||||||||||
776 | } executed 13933 times by 13 tests: end of block Executed by:
| 13933 | ||||||||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||||||||
778 | /*! | - | ||||||||||||||||||||||||||||||
779 | \qmlproperty bool QtQuick::Flickable::interactive | - | ||||||||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||||||||
781 | This property describes whether the user can interact with the Flickable. | - | ||||||||||||||||||||||||||||||
782 | A user cannot drag or flick a Flickable that is not interactive. | - | ||||||||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||||||||
784 | By default, this property is true. | - | ||||||||||||||||||||||||||||||
785 | - | |||||||||||||||||||||||||||||||
786 | This property is useful for temporarily disabling flicking. This allows | - | ||||||||||||||||||||||||||||||
787 | special interaction with Flickable's children; for example, you might want | - | ||||||||||||||||||||||||||||||
788 | to freeze a flickable map while scrolling through a pop-up dialog that | - | ||||||||||||||||||||||||||||||
789 | is a child of the Flickable. | - | ||||||||||||||||||||||||||||||
790 | */ | - | ||||||||||||||||||||||||||||||
791 | bool QQuickFlickable::isInteractive() const | - | ||||||||||||||||||||||||||||||
792 | { | - | ||||||||||||||||||||||||||||||
793 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
794 | return d->interactive; executed 2189 times by 7 tests: return d->interactive; Executed by:
| 2189 | ||||||||||||||||||||||||||||||
795 | } | - | ||||||||||||||||||||||||||||||
796 | - | |||||||||||||||||||||||||||||||
797 | void QQuickFlickable::setInteractive(bool interactive) | - | ||||||||||||||||||||||||||||||
798 | { | - | ||||||||||||||||||||||||||||||
799 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
800 | if (interactive != d->interactive) {
| 4-24 | ||||||||||||||||||||||||||||||
801 | d->interactive = interactive; | - | ||||||||||||||||||||||||||||||
802 | if (!interactive) {
| 8-16 | ||||||||||||||||||||||||||||||
803 | d->cancelInteraction(); | - | ||||||||||||||||||||||||||||||
804 | } executed 16 times by 4 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
805 | emit interactiveChanged(); | - | ||||||||||||||||||||||||||||||
806 | } executed 24 times by 4 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||||||||
807 | } executed 28 times by 4 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||||||||
809 | /*! | - | ||||||||||||||||||||||||||||||
810 | \qmlproperty real QtQuick::Flickable::horizontalVelocity | - | ||||||||||||||||||||||||||||||
811 | \qmlproperty real QtQuick::Flickable::verticalVelocity | - | ||||||||||||||||||||||||||||||
812 | - | |||||||||||||||||||||||||||||||
813 | The instantaneous velocity of movement along the x and y axes, in pixels/sec. | - | ||||||||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||||||||
815 | The reported velocity is smoothed to avoid erratic output. | - | ||||||||||||||||||||||||||||||
816 | - | |||||||||||||||||||||||||||||||
817 | Note that for views with a large content size (more than 10 times the view size), | - | ||||||||||||||||||||||||||||||
818 | the velocity of the flick may exceed the velocity of the touch in the case | - | ||||||||||||||||||||||||||||||
819 | of multiple quick consecutive flicks. This allows the user to flick faster | - | ||||||||||||||||||||||||||||||
820 | through large content. | - | ||||||||||||||||||||||||||||||
821 | */ | - | ||||||||||||||||||||||||||||||
822 | qreal QQuickFlickable::horizontalVelocity() const | - | ||||||||||||||||||||||||||||||
823 | { | - | ||||||||||||||||||||||||||||||
824 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
825 | return d->hData.smoothVelocity.value(); executed 15 times by 3 tests: return d->hData.smoothVelocity.value(); Executed by:
| 15 | ||||||||||||||||||||||||||||||
826 | } | - | ||||||||||||||||||||||||||||||
827 | - | |||||||||||||||||||||||||||||||
828 | qreal QQuickFlickable::verticalVelocity() const | - | ||||||||||||||||||||||||||||||
829 | { | - | ||||||||||||||||||||||||||||||
830 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
831 | return d->vData.smoothVelocity.value(); executed 62 times by 3 tests: return d->vData.smoothVelocity.value(); Executed by:
| 62 | ||||||||||||||||||||||||||||||
832 | } | - | ||||||||||||||||||||||||||||||
833 | - | |||||||||||||||||||||||||||||||
834 | /*! | - | ||||||||||||||||||||||||||||||
835 | \qmlproperty bool QtQuick::Flickable::atXBeginning | - | ||||||||||||||||||||||||||||||
836 | \qmlproperty bool QtQuick::Flickable::atXEnd | - | ||||||||||||||||||||||||||||||
837 | \qmlproperty bool QtQuick::Flickable::atYBeginning | - | ||||||||||||||||||||||||||||||
838 | \qmlproperty bool QtQuick::Flickable::atYEnd | - | ||||||||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||||||||
840 | These properties are true if the flickable view is positioned at the beginning, | - | ||||||||||||||||||||||||||||||
841 | or end respectively. | - | ||||||||||||||||||||||||||||||
842 | */ | - | ||||||||||||||||||||||||||||||
843 | bool QQuickFlickable::isAtXEnd() const | - | ||||||||||||||||||||||||||||||
844 | { | - | ||||||||||||||||||||||||||||||
845 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
846 | return d->hData.atEnd; executed 168 times by 3 tests: return d->hData.atEnd; Executed by:
| 168 | ||||||||||||||||||||||||||||||
847 | } | - | ||||||||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||||||||
849 | bool QQuickFlickable::isAtXBeginning() const | - | ||||||||||||||||||||||||||||||
850 | { | - | ||||||||||||||||||||||||||||||
851 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
852 | return d->hData.atBeginning; executed 158 times by 3 tests: return d->hData.atBeginning; Executed by:
| 158 | ||||||||||||||||||||||||||||||
853 | } | - | ||||||||||||||||||||||||||||||
854 | - | |||||||||||||||||||||||||||||||
855 | bool QQuickFlickable::isAtYEnd() const | - | ||||||||||||||||||||||||||||||
856 | { | - | ||||||||||||||||||||||||||||||
857 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
858 | return d->vData.atEnd; executed 193 times by 5 tests: return d->vData.atEnd; Executed by:
| 193 | ||||||||||||||||||||||||||||||
859 | } | - | ||||||||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||||||||
861 | bool QQuickFlickable::isAtYBeginning() const | - | ||||||||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||||||||
863 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
864 | return d->vData.atBeginning; executed 190 times by 5 tests: return d->vData.atBeginning; Executed by:
| 190 | ||||||||||||||||||||||||||||||
865 | } | - | ||||||||||||||||||||||||||||||
866 | - | |||||||||||||||||||||||||||||||
867 | /*! | - | ||||||||||||||||||||||||||||||
868 | \qmlproperty Item QtQuick::Flickable::contentItem | - | ||||||||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||||||||
870 | The internal item that contains the Items to be moved in the Flickable. | - | ||||||||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||||||||
872 | Items declared as children of a Flickable are automatically parented to the Flickable's contentItem. | - | ||||||||||||||||||||||||||||||
873 | - | |||||||||||||||||||||||||||||||
874 | Items created dynamically need to be explicitly parented to the \e contentItem: | - | ||||||||||||||||||||||||||||||
875 | \code | - | ||||||||||||||||||||||||||||||
876 | Flickable { | - | ||||||||||||||||||||||||||||||
877 | id: myFlickable | - | ||||||||||||||||||||||||||||||
878 | function addItem(file) { | - | ||||||||||||||||||||||||||||||
879 | var component = Qt.createComponent(file) | - | ||||||||||||||||||||||||||||||
880 | component.createObject(myFlickable.contentItem); | - | ||||||||||||||||||||||||||||||
881 | } | - | ||||||||||||||||||||||||||||||
882 | } | - | ||||||||||||||||||||||||||||||
883 | \endcode | - | ||||||||||||||||||||||||||||||
884 | */ | - | ||||||||||||||||||||||||||||||
885 | QQuickItem *QQuickFlickable::contentItem() const | - | ||||||||||||||||||||||||||||||
886 | { | - | ||||||||||||||||||||||||||||||
887 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
888 | return d->contentItem; executed 172139 times by 12 tests: return d->contentItem; Executed by:
| 172139 | ||||||||||||||||||||||||||||||
889 | } | - | ||||||||||||||||||||||||||||||
890 | - | |||||||||||||||||||||||||||||||
891 | QQuickFlickableVisibleArea *QQuickFlickable::visibleArea() | - | ||||||||||||||||||||||||||||||
892 | { | - | ||||||||||||||||||||||||||||||
893 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
894 | if (!d->visibleArea) {
| 566-1802 | ||||||||||||||||||||||||||||||
895 | d->visibleArea = new QQuickFlickableVisibleArea(this); | - | ||||||||||||||||||||||||||||||
896 | d->visibleArea->updateVisible(); // calculate initial ratios | - | ||||||||||||||||||||||||||||||
897 | } executed 566 times by 3 tests: end of block Executed by:
| 566 | ||||||||||||||||||||||||||||||
898 | return d->visibleArea; executed 2368 times by 3 tests: return d->visibleArea; Executed by:
| 2368 | ||||||||||||||||||||||||||||||
899 | } | - | ||||||||||||||||||||||||||||||
900 | - | |||||||||||||||||||||||||||||||
901 | /*! | - | ||||||||||||||||||||||||||||||
902 | \qmlproperty enumeration QtQuick::Flickable::flickableDirection | - | ||||||||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||||||||
904 | This property determines which directions the view can be flicked. | - | ||||||||||||||||||||||||||||||
905 | - | |||||||||||||||||||||||||||||||
906 | \list | - | ||||||||||||||||||||||||||||||
907 | \li Flickable.AutoFlickDirection (default) - allows flicking vertically if the | - | ||||||||||||||||||||||||||||||
908 | \e contentHeight is not equal to the \e height of the Flickable. | - | ||||||||||||||||||||||||||||||
909 | Allows flicking horizontally if the \e contentWidth is not equal | - | ||||||||||||||||||||||||||||||
910 | to the \e width of the Flickable. | - | ||||||||||||||||||||||||||||||
911 | \li Flickable.AutoFlickIfNeeded - allows flicking vertically if the | - | ||||||||||||||||||||||||||||||
912 | \e contentHeight is greater than the \e height of the Flickable. | - | ||||||||||||||||||||||||||||||
913 | Allows flicking horizontally if the \e contentWidth is greater than | - | ||||||||||||||||||||||||||||||
914 | to the \e width of the Flickable. (since \c{QtQuick 2.7}) | - | ||||||||||||||||||||||||||||||
915 | \li Flickable.HorizontalFlick - allows flicking horizontally. | - | ||||||||||||||||||||||||||||||
916 | \li Flickable.VerticalFlick - allows flicking vertically. | - | ||||||||||||||||||||||||||||||
917 | \li Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. | - | ||||||||||||||||||||||||||||||
918 | \endlist | - | ||||||||||||||||||||||||||||||
919 | */ | - | ||||||||||||||||||||||||||||||
920 | QQuickFlickable::FlickableDirection QQuickFlickable::flickableDirection() const | - | ||||||||||||||||||||||||||||||
921 | { | - | ||||||||||||||||||||||||||||||
922 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
923 | return d->flickableDirection; executed 66 times by 1 test: return d->flickableDirection; Executed by:
| 66 | ||||||||||||||||||||||||||||||
924 | } | - | ||||||||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||||||||
926 | void QQuickFlickable::setFlickableDirection(FlickableDirection direction) | - | ||||||||||||||||||||||||||||||
927 | { | - | ||||||||||||||||||||||||||||||
928 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
929 | if (direction != d->flickableDirection) {
| 56-4658 | ||||||||||||||||||||||||||||||
930 | d->flickableDirection = direction; | - | ||||||||||||||||||||||||||||||
931 | emit flickableDirectionChanged(); | - | ||||||||||||||||||||||||||||||
932 | } executed 4658 times by 15 tests: end of block Executed by:
| 4658 | ||||||||||||||||||||||||||||||
933 | } executed 4714 times by 15 tests: end of block Executed by:
| 4714 | ||||||||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||||||||
935 | /*! | - | ||||||||||||||||||||||||||||||
936 | \qmlproperty bool QtQuick::Flickable::pixelAligned | - | ||||||||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||||||||
938 | This property sets the alignment of \l contentX and \l contentY to | - | ||||||||||||||||||||||||||||||
939 | pixels (\c true) or subpixels (\c false). | - | ||||||||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||||||||
941 | Enable pixelAligned to optimize for still content or moving content with | - | ||||||||||||||||||||||||||||||
942 | high constrast edges, such as one-pixel-wide lines, text or vector graphics. | - | ||||||||||||||||||||||||||||||
943 | Disable pixelAligned when optimizing for animation quality. | - | ||||||||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||||||||
945 | The default is \c false. | - | ||||||||||||||||||||||||||||||
946 | */ | - | ||||||||||||||||||||||||||||||
947 | bool QQuickFlickable::pixelAligned() const | - | ||||||||||||||||||||||||||||||
948 | { | - | ||||||||||||||||||||||||||||||
949 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
950 | return d->pixelAligned; never executed: return d->pixelAligned; | 0 | ||||||||||||||||||||||||||||||
951 | } | - | ||||||||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||||||||
953 | void QQuickFlickable::setPixelAligned(bool align) | - | ||||||||||||||||||||||||||||||
954 | { | - | ||||||||||||||||||||||||||||||
955 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
956 | if (align != d->pixelAligned) {
| 10-42 | ||||||||||||||||||||||||||||||
957 | d->pixelAligned = align; | - | ||||||||||||||||||||||||||||||
958 | emit pixelAlignedChanged(); | - | ||||||||||||||||||||||||||||||
959 | } executed 42 times by 2 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||||||||
960 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||||||||
962 | qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event) const | - | ||||||||||||||||||||||||||||||
963 | { | - | ||||||||||||||||||||||||||||||
964 | if (0 != event->timestamp())
| 0-6406 | ||||||||||||||||||||||||||||||
965 | return event->timestamp(); executed 6406 times by 7 tests: return event->timestamp(); Executed by:
| 6406 | ||||||||||||||||||||||||||||||
966 | if (!timer.isValid())
| 0 | ||||||||||||||||||||||||||||||
967 | return 0LL; never executed: return 0LL; | 0 | ||||||||||||||||||||||||||||||
968 | return timer.elapsed(); never executed: return timer.elapsed(); | 0 | ||||||||||||||||||||||||||||||
969 | } | - | ||||||||||||||||||||||||||||||
970 | - | |||||||||||||||||||||||||||||||
971 | qreal QQuickFlickablePrivate::devicePixelRatio() const | - | ||||||||||||||||||||||||||||||
972 | { | - | ||||||||||||||||||||||||||||||
973 | return (window ? window->effectiveDevicePixelRatio() : qApp->devicePixelRatio()); never executed: return (window ? window->effectiveDevicePixelRatio() : (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio()); | 0 | ||||||||||||||||||||||||||||||
974 | } | - | ||||||||||||||||||||||||||||||
975 | - | |||||||||||||||||||||||||||||||
976 | void QQuickFlickablePrivate::handleMousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
977 | { | - | ||||||||||||||||||||||||||||||
978 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
979 | timer.start(); | - | ||||||||||||||||||||||||||||||
980 | if (interactive && timeline.isActive()
| 0-1012 | ||||||||||||||||||||||||||||||
981 | && ((qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity && !hData.fixingUp && !hData.inOvershoot)
| 0-25 | ||||||||||||||||||||||||||||||
982 | || (qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity && !vData.fixingUp && !vData.inOvershoot))) {
| 0-23 | ||||||||||||||||||||||||||||||
983 | stealMouse = true; // If we've been flicked then steal the click. | - | ||||||||||||||||||||||||||||||
984 | int flickTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
985 | if (flickTime > 600) {
| 0-20 | ||||||||||||||||||||||||||||||
986 | // too long between flicks - cancel boost | - | ||||||||||||||||||||||||||||||
987 | hData.continuousFlickVelocity = 0; | - | ||||||||||||||||||||||||||||||
988 | vData.continuousFlickVelocity = 0; | - | ||||||||||||||||||||||||||||||
989 | flickBoost = 1.0; | - | ||||||||||||||||||||||||||||||
990 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
991 | hData.continuousFlickVelocity = -hData.smoothVelocity.value(); | - | ||||||||||||||||||||||||||||||
992 | vData.continuousFlickVelocity = -vData.smoothVelocity.value(); | - | ||||||||||||||||||||||||||||||
993 | if (flickTime > 300) // slower flicking - reduce boost
| 0-20 | ||||||||||||||||||||||||||||||
994 | flickBoost = qMax(1.0, flickBoost - 0.5); never executed: flickBoost = qMax(1.0, flickBoost - 0.5); | 0 | ||||||||||||||||||||||||||||||
995 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||||||||
996 | } else { | - | ||||||||||||||||||||||||||||||
997 | stealMouse = false; | - | ||||||||||||||||||||||||||||||
998 | hData.continuousFlickVelocity = 0; | - | ||||||||||||||||||||||||||||||
999 | vData.continuousFlickVelocity = 0; | - | ||||||||||||||||||||||||||||||
1000 | flickBoost = 1.0; | - | ||||||||||||||||||||||||||||||
1001 | } executed 992 times by 7 tests: end of block Executed by:
| 992 | ||||||||||||||||||||||||||||||
1002 | q->setKeepMouseGrab(stealMouse); | - | ||||||||||||||||||||||||||||||
1003 | - | |||||||||||||||||||||||||||||||
1004 | maybeBeginDrag(computeCurrentTime(event), event->localPos()); | - | ||||||||||||||||||||||||||||||
1005 | } executed 1012 times by 7 tests: end of block Executed by:
| 1012 | ||||||||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||||||||
1007 | void QQuickFlickablePrivate::maybeBeginDrag(qint64 currentTimestamp, const QPointF &pressPosn) | - | ||||||||||||||||||||||||||||||
1008 | { | - | ||||||||||||||||||||||||||||||
1009 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1010 | clearDelayedPress(); | - | ||||||||||||||||||||||||||||||
1011 | pressed = true; | - | ||||||||||||||||||||||||||||||
1012 | - | |||||||||||||||||||||||||||||||
1013 | if (hData.transitionToBounds)
| 0-1012 | ||||||||||||||||||||||||||||||
1014 | hData.transitionToBounds->stopTransition(); never executed: hData.transitionToBounds->stopTransition(); | 0 | ||||||||||||||||||||||||||||||
1015 | if (vData.transitionToBounds)
| 0-1012 | ||||||||||||||||||||||||||||||
1016 | vData.transitionToBounds->stopTransition(); never executed: vData.transitionToBounds->stopTransition(); | 0 | ||||||||||||||||||||||||||||||
1017 | if (!hData.fixingUp)
| 6-1006 | ||||||||||||||||||||||||||||||
1018 | resetTimeline(hData); executed 1006 times by 7 tests: resetTimeline(hData); Executed by:
| 1006 | ||||||||||||||||||||||||||||||
1019 | if (!vData.fixingUp)
| 19-993 | ||||||||||||||||||||||||||||||
1020 | resetTimeline(vData); executed 993 times by 7 tests: resetTimeline(vData); Executed by:
| 993 | ||||||||||||||||||||||||||||||
1021 | - | |||||||||||||||||||||||||||||||
1022 | hData.reset(); | - | ||||||||||||||||||||||||||||||
1023 | vData.reset(); | - | ||||||||||||||||||||||||||||||
1024 | hData.dragMinBound = q->minXExtent() - hData.startMargin; | - | ||||||||||||||||||||||||||||||
1025 | vData.dragMinBound = q->minYExtent() - vData.startMargin; | - | ||||||||||||||||||||||||||||||
1026 | hData.dragMaxBound = q->maxXExtent() + hData.endMargin; | - | ||||||||||||||||||||||||||||||
1027 | vData.dragMaxBound = q->maxYExtent() + vData.endMargin; | - | ||||||||||||||||||||||||||||||
1028 | fixupMode = Normal; | - | ||||||||||||||||||||||||||||||
1029 | lastPos = QPointF(); | - | ||||||||||||||||||||||||||||||
1030 | pressPos = pressPosn; | - | ||||||||||||||||||||||||||||||
1031 | hData.pressPos = hData.move.value(); | - | ||||||||||||||||||||||||||||||
1032 | vData.pressPos = vData.move.value(); | - | ||||||||||||||||||||||||||||||
1033 | bool wasFlicking = hData.flicking || vData.flicking;
| 8-1004 | ||||||||||||||||||||||||||||||
1034 | if (hData.flicking) {
| 8-1004 | ||||||||||||||||||||||||||||||
1035 | hData.flicking = false; | - | ||||||||||||||||||||||||||||||
1036 | emit q->flickingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
1037 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
1038 | if (vData.flicking) {
| 23-989 | ||||||||||||||||||||||||||||||
1039 | vData.flicking = false; | - | ||||||||||||||||||||||||||||||
1040 | emit q->flickingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
1041 | } executed 23 times by 2 tests: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||
1042 | if (wasFlicking)
| 31-981 | ||||||||||||||||||||||||||||||
1043 | emit q->flickingChanged(); executed 31 times by 2 tests: q->flickingChanged(); Executed by:
| 31 | ||||||||||||||||||||||||||||||
1044 | lastPosTime = lastPressTime = currentTimestamp; | - | ||||||||||||||||||||||||||||||
1045 | vData.velocityTime.start(); | - | ||||||||||||||||||||||||||||||
1046 | hData.velocityTime.start(); | - | ||||||||||||||||||||||||||||||
1047 | } executed 1012 times by 7 tests: end of block Executed by:
| 1012 | ||||||||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||||||||
1049 | void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventType, const QPointF &localPos, | - | ||||||||||||||||||||||||||||||
1050 | const QVector2D &deltas, bool overThreshold, bool momentum, | - | ||||||||||||||||||||||||||||||
1051 | bool velocitySensitiveOverBounds, const QVector2D &velocity) | - | ||||||||||||||||||||||||||||||
1052 | { | - | ||||||||||||||||||||||||||||||
1053 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1054 | bool rejectY = false; | - | ||||||||||||||||||||||||||||||
1055 | bool rejectX = false; | - | ||||||||||||||||||||||||||||||
1056 | - | |||||||||||||||||||||||||||||||
1057 | bool keepY = q->yflick(); | - | ||||||||||||||||||||||||||||||
1058 | bool keepX = q->xflick(); | - | ||||||||||||||||||||||||||||||
1059 | - | |||||||||||||||||||||||||||||||
1060 | bool stealY = false; | - | ||||||||||||||||||||||||||||||
1061 | bool stealX = false; | - | ||||||||||||||||||||||||||||||
1062 | if (eventType == QEvent::MouseMove) {
| 0-4540 | ||||||||||||||||||||||||||||||
1063 | stealX = stealY = stealMouse; | - | ||||||||||||||||||||||||||||||
1064 | } else if (eventType == QEvent::Wheel) { executed 4540 times by 7 tests: end of block Executed by:
| 0-4540 | ||||||||||||||||||||||||||||||
1065 | stealX = stealY = scrollingPhase; | - | ||||||||||||||||||||||||||||||
1066 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||||||||
1068 | bool prevHMoved = hMoved; | - | ||||||||||||||||||||||||||||||
1069 | bool prevVMoved = vMoved; | - | ||||||||||||||||||||||||||||||
1070 | - | |||||||||||||||||||||||||||||||
1071 | qint64 elapsedSincePress = currentTimestamp - lastPressTime; | - | ||||||||||||||||||||||||||||||
1072 | - | |||||||||||||||||||||||||||||||
1073 | if (q->yflick()) {
| 1516-3024 | ||||||||||||||||||||||||||||||
1074 | qreal dy = deltas.y(); | - | ||||||||||||||||||||||||||||||
1075 | if (overThreshold || elapsedSincePress > 200) {
| 8-2662 | ||||||||||||||||||||||||||||||
1076 | if (!vMoved)
| 1174-1496 | ||||||||||||||||||||||||||||||
1077 | vData.dragStartOffset = dy; executed 1174 times by 6 tests: vData.dragStartOffset = dy; Executed by:
| 1174 | ||||||||||||||||||||||||||||||
1078 | qreal newY = dy + vData.pressPos - vData.dragStartOffset; | - | ||||||||||||||||||||||||||||||
1079 | // Recalculate bounds in case margins have changed, but use the content | - | ||||||||||||||||||||||||||||||
1080 | // size estimate taken at the start of the drag in case the drag causes | - | ||||||||||||||||||||||||||||||
1081 | // the estimate to be altered | - | ||||||||||||||||||||||||||||||
1082 | const qreal minY = vData.dragMinBound + vData.startMargin; | - | ||||||||||||||||||||||||||||||
1083 | const qreal maxY = vData.dragMaxBound - vData.endMargin; | - | ||||||||||||||||||||||||||||||
1084 | if (!(boundsBehavior & QQuickFlickable::DragOverBounds)) {
| 600-2070 | ||||||||||||||||||||||||||||||
1085 | if (fuzzyLessThanOrEqualTo(newY, maxY)) {
| 110-490 | ||||||||||||||||||||||||||||||
1086 | newY = maxY; | - | ||||||||||||||||||||||||||||||
1087 | rejectY = vData.pressPos == maxY && vData.move.value() == maxY && dy < 0;
| 4-102 | ||||||||||||||||||||||||||||||
1088 | } executed 110 times by 1 test: end of block Executed by:
| 110 | ||||||||||||||||||||||||||||||
1089 | if (fuzzyLessThanOrEqualTo(minY, newY)) {
| 110-490 | ||||||||||||||||||||||||||||||
1090 | newY = minY; | - | ||||||||||||||||||||||||||||||
1091 | rejectY |= vData.pressPos == minY && vData.move.value() == minY && dy > 0;
| 4-102 | ||||||||||||||||||||||||||||||
1092 | } executed 110 times by 1 test: end of block Executed by:
| 110 | ||||||||||||||||||||||||||||||
1093 | } else { executed 600 times by 1 test: end of block Executed by:
| 600 | ||||||||||||||||||||||||||||||
1094 | qreal vel = velocity.y() / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1095 | if (vel > 0. && vel > vData.velocity)
| 108-1178 | ||||||||||||||||||||||||||||||
1096 | vData.velocity = qMin(velocity.y() / QML_FLICK_OVERSHOOTFRICTION, float(QML_FLICK_DEFAULTMAXVELOCITY)); executed 108 times by 6 tests: vData.velocity = qMin(velocity.y() / 8, float(2500)); Executed by:
| 108 | ||||||||||||||||||||||||||||||
1097 | else if (vel < 0. && vel < vData.velocity)
| 125-1142 | ||||||||||||||||||||||||||||||
1098 | vData.velocity = qMax(velocity.y() / QML_FLICK_OVERSHOOTFRICTION, -float(QML_FLICK_DEFAULTMAXVELOCITY)); executed 125 times by 5 tests: vData.velocity = qMax(velocity.y() / 8, -float(2500)); Executed by:
| 125 | ||||||||||||||||||||||||||||||
1099 | if (newY > minY) {
| 274-1796 | ||||||||||||||||||||||||||||||
1100 | // Overshoot beyond the top. But don't wait for momentum phase to end before returning to bounds. | - | ||||||||||||||||||||||||||||||
1101 | if (momentum && vData.atBeginning) {
| 0-274 | ||||||||||||||||||||||||||||||
1102 | if (!vData.inRebound) {
| 0 | ||||||||||||||||||||||||||||||
1103 | vData.inRebound = true; | - | ||||||||||||||||||||||||||||||
1104 | q->returnToBounds(); | - | ||||||||||||||||||||||||||||||
1105 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1106 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1107 | } | - | ||||||||||||||||||||||||||||||
1108 | if (velocitySensitiveOverBounds) {
| 0-274 | ||||||||||||||||||||||||||||||
1109 | qreal overshoot = (newY - minY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1110 | overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); | - | ||||||||||||||||||||||||||||||
1111 | newY = minY + overshoot; | - | ||||||||||||||||||||||||||||||
1112 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1113 | newY = minY + (newY - minY) / 2; | - | ||||||||||||||||||||||||||||||
1114 | } executed 274 times by 5 tests: end of block Executed by:
| 274 | ||||||||||||||||||||||||||||||
1115 | } else if (newY < maxY && maxY - minY <= 0) {
| 0-1707 | ||||||||||||||||||||||||||||||
1116 | // Overshoot beyond the bottom. But don't wait for momentum phase to end before returning to bounds. | - | ||||||||||||||||||||||||||||||
1117 | if (momentum && vData.atEnd) {
| 0-89 | ||||||||||||||||||||||||||||||
1118 | if (!vData.inRebound) {
| 0 | ||||||||||||||||||||||||||||||
1119 | vData.inRebound = true; | - | ||||||||||||||||||||||||||||||
1120 | q->returnToBounds(); | - | ||||||||||||||||||||||||||||||
1121 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1122 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1123 | } | - | ||||||||||||||||||||||||||||||
1124 | if (velocitySensitiveOverBounds) {
| 0-89 | ||||||||||||||||||||||||||||||
1125 | qreal overshoot = (newY - maxY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1126 | overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); | - | ||||||||||||||||||||||||||||||
1127 | newY = maxY - overshoot; | - | ||||||||||||||||||||||||||||||
1128 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1129 | newY = maxY + (newY - maxY) / 2; | - | ||||||||||||||||||||||||||||||
1130 | } executed 89 times by 4 tests: end of block Executed by:
| 89 | ||||||||||||||||||||||||||||||
1131 | } | - | ||||||||||||||||||||||||||||||
1132 | } executed 2070 times by 6 tests: end of block Executed by:
| 2070 | ||||||||||||||||||||||||||||||
1133 | if (!rejectY && stealMouse && dy != 0.0 && dy != vData.previousDragDelta) {
| 140-2530 | ||||||||||||||||||||||||||||||
1134 | clearTimeline(); | - | ||||||||||||||||||||||||||||||
1135 | vData.move.setValue(newY); | - | ||||||||||||||||||||||||||||||
1136 | vMoved = true; | - | ||||||||||||||||||||||||||||||
1137 | } executed 1554 times by 5 tests: end of block Executed by:
| 1554 | ||||||||||||||||||||||||||||||
1138 | if (!rejectY && overThreshold)
| 8-2530 | ||||||||||||||||||||||||||||||
1139 | stealY = true; executed 2522 times by 6 tests: stealY = true; Executed by:
| 2522 | ||||||||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||||||||
1141 | if ((newY >= minY && vData.pressPos == minY && vData.move.value() == minY && dy > 0)
| 66-1992 | ||||||||||||||||||||||||||||||
1142 | || (newY <= maxY && vData.pressPos == maxY && vData.move.value() == maxY && dy < 0)) {
| 40-2187 | ||||||||||||||||||||||||||||||
1143 | keepY = false; | - | ||||||||||||||||||||||||||||||
1144 | } executed 298 times by 5 tests: end of block Executed by:
| 298 | ||||||||||||||||||||||||||||||
1145 | } executed 2670 times by 6 tests: end of block Executed by:
| 2670 | ||||||||||||||||||||||||||||||
1146 | vData.previousDragDelta = dy; | - | ||||||||||||||||||||||||||||||
1147 | } executed 3024 times by 6 tests: end of block Executed by:
| 3024 | ||||||||||||||||||||||||||||||
1148 | - | |||||||||||||||||||||||||||||||
1149 | if (q->xflick()) {
| 1900-2640 | ||||||||||||||||||||||||||||||
1150 | qreal dx = deltas.x(); | - | ||||||||||||||||||||||||||||||
1151 | if (overThreshold || elapsedSincePress > 200) {
| 0-2292 | ||||||||||||||||||||||||||||||
1152 | if (!hMoved)
| 1116-1176 | ||||||||||||||||||||||||||||||
1153 | hData.dragStartOffset = dx; executed 1116 times by 6 tests: hData.dragStartOffset = dx; Executed by:
| 1116 | ||||||||||||||||||||||||||||||
1154 | qreal newX = dx + hData.pressPos - hData.dragStartOffset; | - | ||||||||||||||||||||||||||||||
1155 | const qreal minX = hData.dragMinBound + hData.startMargin; | - | ||||||||||||||||||||||||||||||
1156 | const qreal maxX = hData.dragMaxBound - hData.endMargin; | - | ||||||||||||||||||||||||||||||
1157 | if (!(boundsBehavior & QQuickFlickable::DragOverBounds)) {
| 622-1670 | ||||||||||||||||||||||||||||||
1158 | if (fuzzyLessThanOrEqualTo(newX, maxX)) {
| 132-490 | ||||||||||||||||||||||||||||||
1159 | newX = maxX; | - | ||||||||||||||||||||||||||||||
1160 | rejectX = hData.pressPos == maxX && hData.move.value() == maxX && dx < 0;
| 4-124 | ||||||||||||||||||||||||||||||
1161 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||||||||||||||||||||||||||
1162 | if (fuzzyLessThanOrEqualTo(minX, newX)) {
| 118-504 | ||||||||||||||||||||||||||||||
1163 | newX = minX; | - | ||||||||||||||||||||||||||||||
1164 | rejectX |= hData.pressPos == minX && hData.move.value() == minX && dx > 0;
| 4-110 | ||||||||||||||||||||||||||||||
1165 | } executed 118 times by 1 test: end of block Executed by:
| 118 | ||||||||||||||||||||||||||||||
1166 | } else { executed 622 times by 1 test: end of block Executed by:
| 622 | ||||||||||||||||||||||||||||||
1167 | qreal vel = velocity.x() / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1168 | if (vel > 0. && vel > hData.velocity)
| 110-912 | ||||||||||||||||||||||||||||||
1169 | hData.velocity = qMin(velocity.x() / QML_FLICK_OVERSHOOTFRICTION, float(QML_FLICK_DEFAULTMAXVELOCITY)); executed 110 times by 5 tests: hData.velocity = qMin(velocity.x() / 8, float(2500)); Executed by:
| 110 | ||||||||||||||||||||||||||||||
1170 | else if (vel < 0. && vel < hData.velocity)
| 77-882 | ||||||||||||||||||||||||||||||
1171 | hData.velocity = qMax(velocity.x() / QML_FLICK_OVERSHOOTFRICTION, -float(QML_FLICK_DEFAULTMAXVELOCITY)); executed 77 times by 4 tests: hData.velocity = qMax(velocity.x() / 8, -float(2500)); Executed by:
| 77 | ||||||||||||||||||||||||||||||
1172 | if (newX > minX) {
| 86-1584 | ||||||||||||||||||||||||||||||
1173 | // Overshoot beyond the left. But don't wait for momentum phase to end before returning to bounds. | - | ||||||||||||||||||||||||||||||
1174 | if (momentum && hData.atBeginning) {
| 0-86 | ||||||||||||||||||||||||||||||
1175 | if (!hData.inRebound) {
| 0 | ||||||||||||||||||||||||||||||
1176 | hData.inRebound = true; | - | ||||||||||||||||||||||||||||||
1177 | q->returnToBounds(); | - | ||||||||||||||||||||||||||||||
1178 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1179 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1180 | } | - | ||||||||||||||||||||||||||||||
1181 | if (velocitySensitiveOverBounds) {
| 0-86 | ||||||||||||||||||||||||||||||
1182 | qreal overshoot = (newX - minX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1183 | overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); | - | ||||||||||||||||||||||||||||||
1184 | newX = minX + overshoot; | - | ||||||||||||||||||||||||||||||
1185 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1186 | newX = minX + (newX - minX) / 2; | - | ||||||||||||||||||||||||||||||
1187 | } executed 86 times by 4 tests: end of block Executed by:
| 86 | ||||||||||||||||||||||||||||||
1188 | } else if (newX < maxX && maxX - minX <= 0) {
| 0-1528 | ||||||||||||||||||||||||||||||
1189 | // Overshoot beyond the right. But don't wait for momentum phase to end before returning to bounds. | - | ||||||||||||||||||||||||||||||
1190 | if (momentum && hData.atEnd) {
| 0-56 | ||||||||||||||||||||||||||||||
1191 | if (!hData.inRebound) {
| 0 | ||||||||||||||||||||||||||||||
1192 | hData.inRebound = true; | - | ||||||||||||||||||||||||||||||
1193 | q->returnToBounds(); | - | ||||||||||||||||||||||||||||||
1194 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1195 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1196 | } | - | ||||||||||||||||||||||||||||||
1197 | if (velocitySensitiveOverBounds) {
| 0-56 | ||||||||||||||||||||||||||||||
1198 | qreal overshoot = (newX - maxX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; | - | ||||||||||||||||||||||||||||||
1199 | overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); | - | ||||||||||||||||||||||||||||||
1200 | newX = maxX - overshoot; | - | ||||||||||||||||||||||||||||||
1201 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1202 | newX = maxX + (newX - maxX) / 2; | - | ||||||||||||||||||||||||||||||
1203 | } executed 56 times by 3 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||||||||
1204 | } | - | ||||||||||||||||||||||||||||||
1205 | } executed 1670 times by 6 tests: end of block Executed by:
| 1670 | ||||||||||||||||||||||||||||||
1206 | - | |||||||||||||||||||||||||||||||
1207 | if (!rejectX && stealMouse && dx != 0.0 && dx != hData.previousDragDelta) {
| 154-2138 | ||||||||||||||||||||||||||||||
1208 | clearTimeline(); | - | ||||||||||||||||||||||||||||||
1209 | hData.move.setValue(newX); | - | ||||||||||||||||||||||||||||||
1210 | hMoved = true; | - | ||||||||||||||||||||||||||||||
1211 | } executed 1278 times by 6 tests: end of block Executed by:
| 1278 | ||||||||||||||||||||||||||||||
1212 | - | |||||||||||||||||||||||||||||||
1213 | if (!rejectX && overThreshold)
| 0-2138 | ||||||||||||||||||||||||||||||
1214 | stealX = true; executed 2138 times by 6 tests: stealX = true; Executed by:
| 2138 | ||||||||||||||||||||||||||||||
1215 | - | |||||||||||||||||||||||||||||||
1216 | if ((newX >= minX && vData.pressPos == minX && vData.move.value() == minX && dx > 0)
| 8-1908 | ||||||||||||||||||||||||||||||
1217 | || (newX <= maxX && vData.pressPos == maxX && vData.move.value() == maxX && dx < 0)) {
| 8-1844 | ||||||||||||||||||||||||||||||
1218 | keepX = false; | - | ||||||||||||||||||||||||||||||
1219 | } executed 224 times by 4 tests: end of block Executed by:
| 224 | ||||||||||||||||||||||||||||||
1220 | } executed 2292 times by 6 tests: end of block Executed by:
| 2292 | ||||||||||||||||||||||||||||||
1221 | hData.previousDragDelta = dx; | - | ||||||||||||||||||||||||||||||
1222 | } executed 2640 times by 6 tests: end of block Executed by:
| 2640 | ||||||||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||||||||
1224 | stealMouse = stealX || stealY;
| 342-3838 | ||||||||||||||||||||||||||||||
1225 | if (stealMouse) {
| 360-4180 | ||||||||||||||||||||||||||||||
1226 | if ((stealX && keepX) || (stealY && keepY))
| 12-3838 | ||||||||||||||||||||||||||||||
1227 | q->setKeepMouseGrab(true); executed 4008 times by 7 tests: q->setKeepMouseGrab(true); Executed by:
| 4008 | ||||||||||||||||||||||||||||||
1228 | clearDelayedPress(); | - | ||||||||||||||||||||||||||||||
1229 | } executed 4180 times by 7 tests: end of block Executed by:
| 4180 | ||||||||||||||||||||||||||||||
1230 | - | |||||||||||||||||||||||||||||||
1231 | if (rejectY) {
| 140-4400 | ||||||||||||||||||||||||||||||
1232 | vData.velocityBuffer.clear(); | - | ||||||||||||||||||||||||||||||
1233 | vData.velocity = 0; | - | ||||||||||||||||||||||||||||||
1234 | } executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||||||||
1235 | if (rejectX) {
| 154-4386 | ||||||||||||||||||||||||||||||
1236 | hData.velocityBuffer.clear(); | - | ||||||||||||||||||||||||||||||
1237 | hData.velocity = 0; | - | ||||||||||||||||||||||||||||||
1238 | } executed 154 times by 1 test: end of block Executed by:
| 154 | ||||||||||||||||||||||||||||||
1239 | - | |||||||||||||||||||||||||||||||
1240 | if (momentum && !hData.flicking && !vData.flicking)
| 0-4540 | ||||||||||||||||||||||||||||||
1241 | flickingStarted(hData.velocity != 0, vData.velocity != 0); never executed: flickingStarted(hData.velocity != 0, vData.velocity != 0); | 0 | ||||||||||||||||||||||||||||||
1242 | draggingStarting(); | - | ||||||||||||||||||||||||||||||
1243 | - | |||||||||||||||||||||||||||||||
1244 | if ((hMoved && !prevHMoved) || (vMoved && !prevVMoved))
| 305-2980 | ||||||||||||||||||||||||||||||
1245 | q->movementStarting(); executed 681 times by 7 tests: q->movementStarting(); Executed by:
| 681 | ||||||||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||||||||
1247 | lastPosTime = currentTimestamp; | - | ||||||||||||||||||||||||||||||
1248 | if (q->yflick() && !rejectY)
| 140-3024 | ||||||||||||||||||||||||||||||
1249 | vData.addVelocitySample(velocity.y(), maxVelocity); executed 2884 times by 6 tests: vData.addVelocitySample(velocity.y(), maxVelocity); Executed by:
| 2884 | ||||||||||||||||||||||||||||||
1250 | if (q->xflick() && !rejectX)
| 154-2640 | ||||||||||||||||||||||||||||||
1251 | hData.addVelocitySample(velocity.x(), maxVelocity); executed 2486 times by 6 tests: hData.addVelocitySample(velocity.x(), maxVelocity); Executed by:
| 2486 | ||||||||||||||||||||||||||||||
1252 | lastPos = localPos; | - | ||||||||||||||||||||||||||||||
1253 | } executed 4540 times by 7 tests: end of block Executed by:
| 4540 | ||||||||||||||||||||||||||||||
1254 | - | |||||||||||||||||||||||||||||||
1255 | void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1256 | { | - | ||||||||||||||||||||||||||||||
1257 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1258 | if (!interactive || lastPosTime == -1)
| 0-4624 | ||||||||||||||||||||||||||||||
1259 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1260 | - | |||||||||||||||||||||||||||||||
1261 | qint64 currentTimestamp = computeCurrentTime(event); | - | ||||||||||||||||||||||||||||||
1262 | QVector2D deltas = QVector2D(event->localPos() - pressPos); | - | ||||||||||||||||||||||||||||||
1263 | bool overThreshold = false; | - | ||||||||||||||||||||||||||||||
1264 | QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event); | - | ||||||||||||||||||||||||||||||
1265 | // TODO guarantee that events always have velocity so that it never needs to be computed here | - | ||||||||||||||||||||||||||||||
1266 | if (!(QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity)) {
| 0-4624 | ||||||||||||||||||||||||||||||
1267 | qint64 lastTimestamp = (lastPos.isNull() ? lastPressTime : lastPosTime);
| 864-3760 | ||||||||||||||||||||||||||||||
1268 | if (currentTimestamp == lastTimestamp)
| 84-4540 | ||||||||||||||||||||||||||||||
1269 | return; // events are too close together: velocity would be infinite executed 84 times by 1 test: return; Executed by:
| 84 | ||||||||||||||||||||||||||||||
1270 | qreal elapsed = qreal(currentTimestamp - lastTimestamp) / 1000.; | - | ||||||||||||||||||||||||||||||
1271 | velocity = QVector2D(event->localPos() - (lastPos.isNull() ? pressPos : lastPos)) / elapsed; | - | ||||||||||||||||||||||||||||||
1272 | } executed 4540 times by 7 tests: end of block Executed by:
| 4540 | ||||||||||||||||||||||||||||||
1273 | - | |||||||||||||||||||||||||||||||
1274 | if (q->yflick())
| 1516-3024 | ||||||||||||||||||||||||||||||
1275 | overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, event); executed 3024 times by 6 tests: overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, event); Executed by:
| 3024 | ||||||||||||||||||||||||||||||
1276 | if (q->xflick())
| 1900-2640 | ||||||||||||||||||||||||||||||
1277 | overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.x(), Qt::XAxis, event); executed 2640 times by 6 tests: overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.x(), Qt::XAxis, event); Executed by:
| 2640 | ||||||||||||||||||||||||||||||
1278 | - | |||||||||||||||||||||||||||||||
1279 | drag(currentTimestamp, event->type(), event->localPos(), deltas, overThreshold, false, false, velocity); | - | ||||||||||||||||||||||||||||||
1280 | } executed 4540 times by 7 tests: end of block Executed by:
| 4540 | ||||||||||||||||||||||||||||||
1281 | - | |||||||||||||||||||||||||||||||
1282 | void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1283 | { | - | ||||||||||||||||||||||||||||||
1284 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1285 | stealMouse = false; | - | ||||||||||||||||||||||||||||||
1286 | q->setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
1287 | pressed = false; | - | ||||||||||||||||||||||||||||||
1288 | - | |||||||||||||||||||||||||||||||
1289 | // if we drag then pause before release we should not cause a flick. | - | ||||||||||||||||||||||||||||||
1290 | qint64 elapsed = computeCurrentTime(event) - lastPosTime; | - | ||||||||||||||||||||||||||||||
1291 | - | |||||||||||||||||||||||||||||||
1292 | vData.updateVelocity(); | - | ||||||||||||||||||||||||||||||
1293 | hData.updateVelocity(); | - | ||||||||||||||||||||||||||||||
1294 | - | |||||||||||||||||||||||||||||||
1295 | draggingEnding(); | - | ||||||||||||||||||||||||||||||
1296 | - | |||||||||||||||||||||||||||||||
1297 | if (lastPosTime == -1)
| 10-760 | ||||||||||||||||||||||||||||||
1298 | return; executed 10 times by 3 tests: return; Executed by:
| 10 | ||||||||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||||||||
1300 | hData.vTime = vData.vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||||||||
1302 | bool canBoost = false; | - | ||||||||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||||||||
1304 | qreal vVelocity = 0; | - | ||||||||||||||||||||||||||||||
1305 | if (elapsed < 100 && vData.velocity != 0.) {
| 0-760 | ||||||||||||||||||||||||||||||
1306 | vVelocity = (QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity)
| 0-384 | ||||||||||||||||||||||||||||||
1307 | ? QGuiApplicationPrivate::mouseEventVelocity(event).y() : vData.velocity; | - | ||||||||||||||||||||||||||||||
1308 | } executed 384 times by 5 tests: end of block Executed by:
| 384 | ||||||||||||||||||||||||||||||
1309 | if ((vData.atBeginning && vVelocity > 0.) || (vData.atEnd && vVelocity < 0.)) {
| 48-412 | ||||||||||||||||||||||||||||||
1310 | vVelocity /= 2; | - | ||||||||||||||||||||||||||||||
1311 | } else if (vData.continuousFlickVelocity != 0.0 executed 96 times by 5 tests: end of block Executed by:
| 8-656 | ||||||||||||||||||||||||||||||
1312 | && vData.viewSize/q->height() > QML_FLICK_MULTIFLICK_RATIO
| 0-8 | ||||||||||||||||||||||||||||||
1313 | && ((vVelocity > 0) == (vData.continuousFlickVelocity > 0))
| 0 | ||||||||||||||||||||||||||||||
1314 | && qAbs(vVelocity) > QML_FLICK_MULTIFLICK_THRESHOLD) {
| 0 | ||||||||||||||||||||||||||||||
1315 | // accelerate flick for large view flicked quickly | - | ||||||||||||||||||||||||||||||
1316 | canBoost = true; | - | ||||||||||||||||||||||||||||||
1317 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1318 | - | |||||||||||||||||||||||||||||||
1319 | qreal hVelocity = 0; | - | ||||||||||||||||||||||||||||||
1320 | if (elapsed < 100 && hData.velocity != 0.) {
| 0-760 | ||||||||||||||||||||||||||||||
1321 | hVelocity = (QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity)
| 0-386 | ||||||||||||||||||||||||||||||
1322 | ? QGuiApplicationPrivate::mouseEventVelocity(event).x() : hData.velocity; | - | ||||||||||||||||||||||||||||||
1323 | } executed 386 times by 6 tests: end of block Executed by:
| 386 | ||||||||||||||||||||||||||||||
1324 | if ((hData.atBeginning && hVelocity > 0.) || (hData.atEnd && hVelocity < 0.)) {
| 32-388 | ||||||||||||||||||||||||||||||
1325 | hVelocity /= 2; | - | ||||||||||||||||||||||||||||||
1326 | } else if (hData.continuousFlickVelocity != 0.0 executed 106 times by 4 tests: end of block Executed by:
| 8-646 | ||||||||||||||||||||||||||||||
1327 | && hData.viewSize/q->width() > QML_FLICK_MULTIFLICK_RATIO
| 0-8 | ||||||||||||||||||||||||||||||
1328 | && ((hVelocity > 0) == (hData.continuousFlickVelocity > 0))
| 0 | ||||||||||||||||||||||||||||||
1329 | && qAbs(hVelocity) > QML_FLICK_MULTIFLICK_THRESHOLD) {
| 0 | ||||||||||||||||||||||||||||||
1330 | // accelerate flick for large view flicked quickly | - | ||||||||||||||||||||||||||||||
1331 | canBoost = true; | - | ||||||||||||||||||||||||||||||
1332 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1333 | - | |||||||||||||||||||||||||||||||
1334 | flickBoost = canBoost ? qBound(1.0, flickBoost+0.25, QML_FLICK_MULTIFLICK_MAXBOOST) : 1.0;
| 0-760 | ||||||||||||||||||||||||||||||
1335 | - | |||||||||||||||||||||||||||||||
1336 | bool flickedVertically = false; | - | ||||||||||||||||||||||||||||||
1337 | vVelocity *= flickBoost; | - | ||||||||||||||||||||||||||||||
1338 | bool isVerticalFlickAllowed = q->yflick() && qAbs(vVelocity) > MinimumFlickVelocity && qAbs(event->localPos().y() - pressPos.y()) > FlickThreshold;
| 0-472 | ||||||||||||||||||||||||||||||
1339 | if (isVerticalFlickAllowed) {
| 336-424 | ||||||||||||||||||||||||||||||
1340 | velocityTimeline.reset(vData.smoothVelocity); | - | ||||||||||||||||||||||||||||||
1341 | vData.smoothVelocity.setValue(-vVelocity); | - | ||||||||||||||||||||||||||||||
1342 | flickedVertically = flickY(vVelocity); | - | ||||||||||||||||||||||||||||||
1343 | } executed 336 times by 5 tests: end of block Executed by:
| 336 | ||||||||||||||||||||||||||||||
1344 | - | |||||||||||||||||||||||||||||||
1345 | bool flickedHorizontally = false; | - | ||||||||||||||||||||||||||||||
1346 | hVelocity *= flickBoost; | - | ||||||||||||||||||||||||||||||
1347 | bool isHorizontalFlickAllowed = q->xflick() && qAbs(hVelocity) > MinimumFlickVelocity && qAbs(event->localPos().x() - pressPos.x()) > FlickThreshold;
| 32-434 | ||||||||||||||||||||||||||||||
1348 | if (isHorizontalFlickAllowed) {
| 354-406 | ||||||||||||||||||||||||||||||
1349 | velocityTimeline.reset(hData.smoothVelocity); | - | ||||||||||||||||||||||||||||||
1350 | hData.smoothVelocity.setValue(-hVelocity); | - | ||||||||||||||||||||||||||||||
1351 | flickedHorizontally = flickX(hVelocity); | - | ||||||||||||||||||||||||||||||
1352 | } executed 354 times by 6 tests: end of block Executed by:
| 354 | ||||||||||||||||||||||||||||||
1353 | - | |||||||||||||||||||||||||||||||
1354 | if (!isVerticalFlickAllowed)
| 336-424 | ||||||||||||||||||||||||||||||
1355 | fixupY(); executed 424 times by 6 tests: fixupY(); Executed by:
| 424 | ||||||||||||||||||||||||||||||
1356 | - | |||||||||||||||||||||||||||||||
1357 | if (!isHorizontalFlickAllowed)
| 354-406 | ||||||||||||||||||||||||||||||
1358 | fixupX(); executed 406 times by 6 tests: fixupX(); Executed by:
| 406 | ||||||||||||||||||||||||||||||
1359 | - | |||||||||||||||||||||||||||||||
1360 | flickingStarted(flickedHorizontally, flickedVertically); | - | ||||||||||||||||||||||||||||||
1361 | if (!isViewMoving())
| 60-700 | ||||||||||||||||||||||||||||||
1362 | q->movementEnding(); executed 60 times by 3 tests: q->movementEnding(); Executed by:
| 60 | ||||||||||||||||||||||||||||||
1363 | } executed 760 times by 7 tests: end of block Executed by:
| 760 | ||||||||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||||||||
1365 | void QQuickFlickable::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1366 | { | - | ||||||||||||||||||||||||||||||
1367 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1368 | if (d->interactive) {
| 8-667 | ||||||||||||||||||||||||||||||
1369 | if (!d->pressed)
| 310-357 | ||||||||||||||||||||||||||||||
1370 | d->handleMousePressEvent(event); executed 357 times by 4 tests: d->handleMousePressEvent(event); Executed by:
| 357 | ||||||||||||||||||||||||||||||
1371 | event->accept(); | - | ||||||||||||||||||||||||||||||
1372 | } else { executed 667 times by 5 tests: end of block Executed by:
| 667 | ||||||||||||||||||||||||||||||
1373 | QQuickItem::mousePressEvent(event); | - | ||||||||||||||||||||||||||||||
1374 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
1375 | } | - | ||||||||||||||||||||||||||||||
1376 | - | |||||||||||||||||||||||||||||||
1377 | void QQuickFlickable::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1378 | { | - | ||||||||||||||||||||||||||||||
1379 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1380 | if (d->interactive) {
| 0-4070 | ||||||||||||||||||||||||||||||
1381 | d->handleMouseMoveEvent(event); | - | ||||||||||||||||||||||||||||||
1382 | event->accept(); | - | ||||||||||||||||||||||||||||||
1383 | } else { executed 4070 times by 6 tests: end of block Executed by:
| 4070 | ||||||||||||||||||||||||||||||
1384 | QQuickItem::mouseMoveEvent(event); | - | ||||||||||||||||||||||||||||||
1385 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1386 | } | - | ||||||||||||||||||||||||||||||
1387 | - | |||||||||||||||||||||||||||||||
1388 | void QQuickFlickable::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1389 | { | - | ||||||||||||||||||||||||||||||
1390 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1391 | if (d->interactive) {
| 0-724 | ||||||||||||||||||||||||||||||
1392 | if (d->delayedPressEvent) {
| 0-724 | ||||||||||||||||||||||||||||||
1393 | d->replayDelayedPress(); | - | ||||||||||||||||||||||||||||||
1394 | - | |||||||||||||||||||||||||||||||
1395 | // Now send the release | - | ||||||||||||||||||||||||||||||
1396 | if (window() && window()->mouseGrabberItem()) {
| 0 | ||||||||||||||||||||||||||||||
1397 | QPointF localPos = window()->mouseGrabberItem()->mapFromScene(event->windowPos()); | - | ||||||||||||||||||||||||||||||
1398 | QScopedPointer<QMouseEvent> mouseEvent(QQuickWindowPrivate::cloneMouseEvent(event, &localPos)); | - | ||||||||||||||||||||||||||||||
1399 | QCoreApplication::sendEvent(window(), mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
1400 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||||||||
1402 | // And the event has been consumed | - | ||||||||||||||||||||||||||||||
1403 | d->stealMouse = false; | - | ||||||||||||||||||||||||||||||
1404 | d->pressed = false; | - | ||||||||||||||||||||||||||||||
1405 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1406 | } | - | ||||||||||||||||||||||||||||||
1407 | - | |||||||||||||||||||||||||||||||
1408 | d->handleMouseReleaseEvent(event); | - | ||||||||||||||||||||||||||||||
1409 | event->accept(); | - | ||||||||||||||||||||||||||||||
1410 | } else { executed 724 times by 7 tests: end of block Executed by:
| 724 | ||||||||||||||||||||||||||||||
1411 | QQuickItem::mouseReleaseEvent(event); | - | ||||||||||||||||||||||||||||||
1412 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1413 | } | - | ||||||||||||||||||||||||||||||
1414 | - | |||||||||||||||||||||||||||||||
1415 | #if QT_CONFIG(wheelevent) | - | ||||||||||||||||||||||||||||||
1416 | void QQuickFlickable::wheelEvent(QWheelEvent *event) | - | ||||||||||||||||||||||||||||||
1417 | { | - | ||||||||||||||||||||||||||||||
1418 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1419 | if (!d->interactive) {
| 0 | ||||||||||||||||||||||||||||||
1420 | QQuickItem::wheelEvent(event); | - | ||||||||||||||||||||||||||||||
1421 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1422 | } | - | ||||||||||||||||||||||||||||||
1423 | event->setAccepted(false); | - | ||||||||||||||||||||||||||||||
1424 | qint64 currentTimestamp = d->computeCurrentTime(event); | - | ||||||||||||||||||||||||||||||
1425 | switch (event->phase()) { | - | ||||||||||||||||||||||||||||||
1426 | case Qt::ScrollBegin: never executed: case Qt::ScrollBegin: | 0 | ||||||||||||||||||||||||||||||
1427 | d->scrollingPhase = true; | - | ||||||||||||||||||||||||||||||
1428 | d->accumulatedWheelPixelDelta = QVector2D(); | - | ||||||||||||||||||||||||||||||
1429 | d->vData.velocity = 0; | - | ||||||||||||||||||||||||||||||
1430 | d->hData.velocity = 0; | - | ||||||||||||||||||||||||||||||
1431 | d->timer.start(); | - | ||||||||||||||||||||||||||||||
1432 | d->maybeBeginDrag(currentTimestamp, event->posF()); | - | ||||||||||||||||||||||||||||||
1433 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1434 | case Qt::NoScrollPhase: // default phase with an ordinary wheel mouse never executed: case Qt::NoScrollPhase: | 0 | ||||||||||||||||||||||||||||||
1435 | case Qt::ScrollUpdate: never executed: case Qt::ScrollUpdate: | 0 | ||||||||||||||||||||||||||||||
1436 | if (d->scrollingPhase)
| 0 | ||||||||||||||||||||||||||||||
1437 | d->pressed = true; never executed: d->pressed = true; | 0 | ||||||||||||||||||||||||||||||
1438 | #ifdef Q_OS_MACOS | - | ||||||||||||||||||||||||||||||
1439 | // TODO eliminate this timer when ScrollMomentum has been added | - | ||||||||||||||||||||||||||||||
1440 | d->movementEndingTimer.start(MovementEndingTimerInterval, this); | - | ||||||||||||||||||||||||||||||
1441 | #endif | - | ||||||||||||||||||||||||||||||
1442 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1443 | case Qt::ScrollEnd: never executed: case Qt::ScrollEnd: | 0 | ||||||||||||||||||||||||||||||
1444 | // TODO most of this should be done at transition to ScrollMomentum phase, | - | ||||||||||||||||||||||||||||||
1445 | // then do what the movementEndingTimer triggers at transition to ScrollEnd phase | - | ||||||||||||||||||||||||||||||
1446 | d->pressed = false; | - | ||||||||||||||||||||||||||||||
1447 | d->scrollingPhase = false; | - | ||||||||||||||||||||||||||||||
1448 | d->draggingEnding(); | - | ||||||||||||||||||||||||||||||
1449 | event->accept(); | - | ||||||||||||||||||||||||||||||
1450 | returnToBounds(); | - | ||||||||||||||||||||||||||||||
1451 | d->lastPosTime = -1; | - | ||||||||||||||||||||||||||||||
1452 | #ifdef Q_OS_MACOS | - | ||||||||||||||||||||||||||||||
1453 | d->movementEndingTimer.start(MovementEndingTimerInterval, this); | - | ||||||||||||||||||||||||||||||
1454 | #endif | - | ||||||||||||||||||||||||||||||
1455 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1456 | } | - | ||||||||||||||||||||||||||||||
1457 | - | |||||||||||||||||||||||||||||||
1458 | if (event->source() == Qt::MouseEventNotSynthesized || event->pixelDelta().isNull()) {
| 0 | ||||||||||||||||||||||||||||||
1459 | // physical mouse wheel, so use angleDelta | - | ||||||||||||||||||||||||||||||
1460 | int xDelta = event->angleDelta().x(); | - | ||||||||||||||||||||||||||||||
1461 | int yDelta = event->angleDelta().y(); | - | ||||||||||||||||||||||||||||||
1462 | if (yflick() && yDelta != 0) {
| 0 | ||||||||||||||||||||||||||||||
1463 | bool valid = false; | - | ||||||||||||||||||||||||||||||
1464 | if (yDelta > 0 && contentY() > -minYExtent()) {
| 0 | ||||||||||||||||||||||||||||||
1465 | d->vData.velocity = qMax(yDelta*2 - d->vData.smoothVelocity.value(), qreal(d->maxVelocity/4)); | - | ||||||||||||||||||||||||||||||
1466 | valid = true; | - | ||||||||||||||||||||||||||||||
1467 | } else if (yDelta < 0 && contentY() < -maxYExtent()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
1468 | d->vData.velocity = qMin(yDelta*2 - d->vData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); | - | ||||||||||||||||||||||||||||||
1469 | valid = true; | - | ||||||||||||||||||||||||||||||
1470 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1471 | if (valid) {
| 0 | ||||||||||||||||||||||||||||||
1472 | d->flickY(d->vData.velocity); | - | ||||||||||||||||||||||||||||||
1473 | d->flickingStarted(false, true); | - | ||||||||||||||||||||||||||||||
1474 | if (d->vData.flicking) {
| 0 | ||||||||||||||||||||||||||||||
1475 | d->vMoved = true; | - | ||||||||||||||||||||||||||||||
1476 | movementStarting(); | - | ||||||||||||||||||||||||||||||
1477 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1478 | event->accept(); | - | ||||||||||||||||||||||||||||||
1479 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1480 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1481 | if (xflick() && xDelta != 0) {
| 0 | ||||||||||||||||||||||||||||||
1482 | bool valid = false; | - | ||||||||||||||||||||||||||||||
1483 | if (xDelta > 0 && contentX() > -minXExtent()) {
| 0 | ||||||||||||||||||||||||||||||
1484 | d->hData.velocity = qMax(xDelta*2 - d->hData.smoothVelocity.value(), qreal(d->maxVelocity/4)); | - | ||||||||||||||||||||||||||||||
1485 | valid = true; | - | ||||||||||||||||||||||||||||||
1486 | } else if (xDelta < 0 && contentX() < -maxXExtent()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
1487 | d->hData.velocity = qMin(xDelta*2 - d->hData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); | - | ||||||||||||||||||||||||||||||
1488 | valid = true; | - | ||||||||||||||||||||||||||||||
1489 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1490 | if (valid) {
| 0 | ||||||||||||||||||||||||||||||
1491 | d->flickX(d->hData.velocity); | - | ||||||||||||||||||||||||||||||
1492 | d->flickingStarted(true, false); | - | ||||||||||||||||||||||||||||||
1493 | if (d->hData.flicking) {
| 0 | ||||||||||||||||||||||||||||||
1494 | d->hMoved = true; | - | ||||||||||||||||||||||||||||||
1495 | movementStarting(); | - | ||||||||||||||||||||||||||||||
1496 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1497 | event->accept(); | - | ||||||||||||||||||||||||||||||
1498 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1499 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1500 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1501 | // use pixelDelta (probably from a trackpad) | - | ||||||||||||||||||||||||||||||
1502 | int xDelta = event->pixelDelta().x(); | - | ||||||||||||||||||||||||||||||
1503 | int yDelta = event->pixelDelta().y(); | - | ||||||||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||||||||
1505 | qreal elapsed = qreal(currentTimestamp - d->lastPosTime) / 1000.; | - | ||||||||||||||||||||||||||||||
1506 | if (elapsed <= 0) {
| 0 | ||||||||||||||||||||||||||||||
1507 | d->lastPosTime = currentTimestamp; | - | ||||||||||||||||||||||||||||||
1508 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1509 | } | - | ||||||||||||||||||||||||||||||
1510 | QVector2D velocity(xDelta / elapsed, yDelta / elapsed); | - | ||||||||||||||||||||||||||||||
1511 | d->lastPosTime = currentTimestamp; | - | ||||||||||||||||||||||||||||||
1512 | d->accumulatedWheelPixelDelta += QVector2D(event->pixelDelta()); | - | ||||||||||||||||||||||||||||||
1513 | d->drag(currentTimestamp, event->type(), event->posF(), d->accumulatedWheelPixelDelta, true, !d->scrollingPhase, true, velocity); | - | ||||||||||||||||||||||||||||||
1514 | event->accept(); | - | ||||||||||||||||||||||||||||||
1515 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1516 | - | |||||||||||||||||||||||||||||||
1517 | if (!event->isAccepted())
| 0 | ||||||||||||||||||||||||||||||
1518 | QQuickItem::wheelEvent(event); never executed: QQuickItem::wheelEvent(event); | 0 | ||||||||||||||||||||||||||||||
1519 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1520 | #endif | - | ||||||||||||||||||||||||||||||
1521 | - | |||||||||||||||||||||||||||||||
1522 | bool QQuickFlickablePrivate::isInnermostPressDelay(QQuickItem *i) const | - | ||||||||||||||||||||||||||||||
1523 | { | - | ||||||||||||||||||||||||||||||
1524 | Q_Q(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1525 | QQuickItem *item = i; | - | ||||||||||||||||||||||||||||||
1526 | while (item) {
| 0-48 | ||||||||||||||||||||||||||||||
1527 | QQuickFlickable *flick = qobject_cast<QQuickFlickable*>(item); | - | ||||||||||||||||||||||||||||||
1528 | if (flick && flick->pressDelay() > 0 && flick->isInteractive()) {
| 0-32 | ||||||||||||||||||||||||||||||
1529 | // Found the innermost flickable with press delay - is it me? | - | ||||||||||||||||||||||||||||||
1530 | return (flick == q); executed 16 times by 1 test: return (flick == q); Executed by:
| 16 | ||||||||||||||||||||||||||||||
1531 | } | - | ||||||||||||||||||||||||||||||
1532 | item = item->parentItem(); | - | ||||||||||||||||||||||||||||||
1533 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||||||||
1534 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
1535 | } | - | ||||||||||||||||||||||||||||||
1536 | - | |||||||||||||||||||||||||||||||
1537 | void QQuickFlickablePrivate::captureDelayedPress(QQuickItem *item, QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
1538 | { | - | ||||||||||||||||||||||||||||||
1539 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1540 | if (!q->window() || pressDelay <= 0)
| 0-655 | ||||||||||||||||||||||||||||||
1541 | return; executed 639 times by 7 tests: return; Executed by:
| 639 | ||||||||||||||||||||||||||||||
1542 | - | |||||||||||||||||||||||||||||||
1543 | // Only the innermost flickable should handle the delayed press; this allows | - | ||||||||||||||||||||||||||||||
1544 | // flickables up the parent chain to all see the events in their filter functions | - | ||||||||||||||||||||||||||||||
1545 | if (!isInnermostPressDelay(item))
| 0-16 | ||||||||||||||||||||||||||||||
1546 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||||||||
1548 | delayedPressEvent = QQuickWindowPrivate::cloneMouseEvent(event); | - | ||||||||||||||||||||||||||||||
1549 | delayedPressEvent->setAccepted(false); | - | ||||||||||||||||||||||||||||||
1550 | delayedPressTimer.start(pressDelay, q); | - | ||||||||||||||||||||||||||||||
1551 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||||||||
1553 | void QQuickFlickablePrivate::clearDelayedPress() | - | ||||||||||||||||||||||||||||||
1554 | { | - | ||||||||||||||||||||||||||||||
1555 | if (delayedPressEvent) {
| 14-5783 | ||||||||||||||||||||||||||||||
1556 | delayedPressTimer.stop(); | - | ||||||||||||||||||||||||||||||
1557 | delete delayedPressEvent; | - | ||||||||||||||||||||||||||||||
1558 | delayedPressEvent = nullptr; | - | ||||||||||||||||||||||||||||||
1559 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
1560 | } executed 5797 times by 7 tests: end of block Executed by:
| 5797 | ||||||||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||||||||
1562 | void QQuickFlickablePrivate::replayDelayedPress() | - | ||||||||||||||||||||||||||||||
1563 | { | - | ||||||||||||||||||||||||||||||
1564 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1565 | if (delayedPressEvent) {
| 0-2 | ||||||||||||||||||||||||||||||
1566 | // Losing the grab will clear the delayed press event; take control of it here | - | ||||||||||||||||||||||||||||||
1567 | QScopedPointer<QMouseEvent> mouseEvent(delayedPressEvent); | - | ||||||||||||||||||||||||||||||
1568 | delayedPressEvent = nullptr; | - | ||||||||||||||||||||||||||||||
1569 | delayedPressTimer.stop(); | - | ||||||||||||||||||||||||||||||
1570 | - | |||||||||||||||||||||||||||||||
1571 | // If we have the grab, release before delivering the event | - | ||||||||||||||||||||||||||||||
1572 | if (QQuickWindow *w = q->window()) {
| 0-2 | ||||||||||||||||||||||||||||||
1573 | QQuickWindowPrivate *wpriv = QQuickWindowPrivate::get(w); | - | ||||||||||||||||||||||||||||||
1574 | wpriv->allowChildEventFiltering = false; // don't allow re-filtering during replay | - | ||||||||||||||||||||||||||||||
1575 | replayingPressEvent = true; | - | ||||||||||||||||||||||||||||||
1576 | if (w->mouseGrabberItem() == q)
| 0-2 | ||||||||||||||||||||||||||||||
1577 | q->ungrabMouse(); executed 2 times by 1 test: q->ungrabMouse(); Executed by:
| 2 | ||||||||||||||||||||||||||||||
1578 | - | |||||||||||||||||||||||||||||||
1579 | // Use the event handler that will take care of finding the proper item to propagate the event | - | ||||||||||||||||||||||||||||||
1580 | QCoreApplication::sendEvent(w, mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
1581 | replayingPressEvent = false; | - | ||||||||||||||||||||||||||||||
1582 | wpriv->allowChildEventFiltering = true; | - | ||||||||||||||||||||||||||||||
1583 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1584 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1585 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||||||||
1587 | //XXX pixelAligned ignores the global position of the Flickable, i.e. assumes Flickable itself is pixel aligned. | - | ||||||||||||||||||||||||||||||
1588 | void QQuickFlickablePrivate::setViewportX(qreal x) | - | ||||||||||||||||||||||||||||||
1589 | { | - | ||||||||||||||||||||||||||||||
1590 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1591 | qreal effectiveX = pixelAligned ? -Round(-x) : x;
| 194-13186 | ||||||||||||||||||||||||||||||
1592 | - | |||||||||||||||||||||||||||||||
1593 | const qreal maxX = q->maxXExtent(); | - | ||||||||||||||||||||||||||||||
1594 | const qreal minX = q->minXExtent(); | - | ||||||||||||||||||||||||||||||
1595 | - | |||||||||||||||||||||||||||||||
1596 | if (boundsMovement == int(QQuickFlickable::StopAtBounds))
| 347-13033 | ||||||||||||||||||||||||||||||
1597 | effectiveX = qBound(maxX, effectiveX, minX); executed 347 times by 1 test: effectiveX = qBound(maxX, effectiveX, minX); Executed by:
| 347 | ||||||||||||||||||||||||||||||
1598 | - | |||||||||||||||||||||||||||||||
1599 | contentItem->setX(effectiveX); | - | ||||||||||||||||||||||||||||||
1600 | if (contentItem->x() != effectiveX)
| 6-13374 | ||||||||||||||||||||||||||||||
1601 | return; // reentered executed 6 times by 2 tests: return; Executed by:
| 6 | ||||||||||||||||||||||||||||||
1602 | - | |||||||||||||||||||||||||||||||
1603 | qreal overshoot = 0.0; | - | ||||||||||||||||||||||||||||||
1604 | if (x <= maxX)
| 4859-8515 | ||||||||||||||||||||||||||||||
1605 | overshoot = maxX - x; executed 4859 times by 5 tests: overshoot = maxX - x; Executed by:
| 4859 | ||||||||||||||||||||||||||||||
1606 | else if (x >= minX)
| 2501-6014 | ||||||||||||||||||||||||||||||
1607 | overshoot = minX - x; executed 2501 times by 7 tests: overshoot = minX - x; Executed by:
| 2501 | ||||||||||||||||||||||||||||||
1608 | - | |||||||||||||||||||||||||||||||
1609 | if (overshoot != hData.overshoot) {
| 4293-9081 | ||||||||||||||||||||||||||||||
1610 | hData.overshoot = overshoot; | - | ||||||||||||||||||||||||||||||
1611 | emit q->horizontalOvershootChanged(); | - | ||||||||||||||||||||||||||||||
1612 | } executed 4293 times by 6 tests: end of block Executed by:
| 4293 | ||||||||||||||||||||||||||||||
1613 | } executed 13374 times by 7 tests: end of block Executed by:
| 13374 | ||||||||||||||||||||||||||||||
1614 | - | |||||||||||||||||||||||||||||||
1615 | void QQuickFlickablePrivate::setViewportY(qreal y) | - | ||||||||||||||||||||||||||||||
1616 | { | - | ||||||||||||||||||||||||||||||
1617 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1618 | qreal effectiveY = pixelAligned ? -Round(-y) : y;
| 184-16111 | ||||||||||||||||||||||||||||||
1619 | - | |||||||||||||||||||||||||||||||
1620 | const qreal maxY = q->maxYExtent(); | - | ||||||||||||||||||||||||||||||
1621 | const qreal minY = q->minYExtent(); | - | ||||||||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||||||||
1623 | if (boundsMovement == int(QQuickFlickable::StopAtBounds))
| 337-15958 | ||||||||||||||||||||||||||||||
1624 | effectiveY = qBound(maxY, effectiveY, minY); executed 337 times by 1 test: effectiveY = qBound(maxY, effectiveY, minY); Executed by:
| 337 | ||||||||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||||||||
1626 | contentItem->setY(effectiveY); | - | ||||||||||||||||||||||||||||||
1627 | if (contentItem->y() != effectiveY)
| 14-16281 | ||||||||||||||||||||||||||||||
1628 | return; // reentered executed 14 times by 3 tests: return; Executed by:
| 14 | ||||||||||||||||||||||||||||||
1629 | - | |||||||||||||||||||||||||||||||
1630 | qreal overshoot = 0.0; | - | ||||||||||||||||||||||||||||||
1631 | if (y <= maxY)
| 5827-10454 | ||||||||||||||||||||||||||||||
1632 | overshoot = maxY - y; executed 5827 times by 5 tests: overshoot = maxY - y; Executed by:
| 5827 | ||||||||||||||||||||||||||||||
1633 | else if (y >= minY)
| 2848-7606 | ||||||||||||||||||||||||||||||
1634 | overshoot = minY - y; executed 2848 times by 7 tests: overshoot = minY - y; Executed by:
| 2848 | ||||||||||||||||||||||||||||||
1635 | - | |||||||||||||||||||||||||||||||
1636 | if (overshoot != vData.overshoot) {
| 4586-11695 | ||||||||||||||||||||||||||||||
1637 | vData.overshoot = overshoot; | - | ||||||||||||||||||||||||||||||
1638 | emit q->verticalOvershootChanged(); | - | ||||||||||||||||||||||||||||||
1639 | } executed 4586 times by 5 tests: end of block Executed by:
| 4586 | ||||||||||||||||||||||||||||||
1640 | } executed 16281 times by 7 tests: end of block Executed by:
| 16281 | ||||||||||||||||||||||||||||||
1641 | - | |||||||||||||||||||||||||||||||
1642 | void QQuickFlickable::timerEvent(QTimerEvent *event) | - | ||||||||||||||||||||||||||||||
1643 | { | - | ||||||||||||||||||||||||||||||
1644 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1645 | if (event->timerId() == d->delayedPressTimer.timerId()) {
| 0-2 | ||||||||||||||||||||||||||||||
1646 | d->delayedPressTimer.stop(); | - | ||||||||||||||||||||||||||||||
1647 | if (d->delayedPressEvent) {
| 0-2 | ||||||||||||||||||||||||||||||
1648 | d->replayDelayedPress(); | - | ||||||||||||||||||||||||||||||
1649 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1650 | } else if (event->timerId() == d->movementEndingTimer.timerId()) { executed 2 times by 1 test: end of block Executed by:
| 0-2 | ||||||||||||||||||||||||||||||
1651 | d->movementEndingTimer.stop(); | - | ||||||||||||||||||||||||||||||
1652 | if (!d->scrollingPhase) {
| 0 | ||||||||||||||||||||||||||||||
1653 | d->pressed = false; | - | ||||||||||||||||||||||||||||||
1654 | d->stealMouse = false; | - | ||||||||||||||||||||||||||||||
1655 | if (!d->velocityTimeline.isActive() && !d->timeline.isActive())
| 0 | ||||||||||||||||||||||||||||||
1656 | movementEnding(true, true); never executed: movementEnding(true, true); | 0 | ||||||||||||||||||||||||||||||
1657 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1658 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1659 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1660 | - | |||||||||||||||||||||||||||||||
1661 | qreal QQuickFlickable::minYExtent() const | - | ||||||||||||||||||||||||||||||
1662 | { | - | ||||||||||||||||||||||||||||||
1663 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1664 | return d->vData.startMargin; executed 48213 times by 10 tests: return d->vData.startMargin; Executed by:
| 48213 | ||||||||||||||||||||||||||||||
1665 | } | - | ||||||||||||||||||||||||||||||
1666 | - | |||||||||||||||||||||||||||||||
1667 | qreal QQuickFlickable::minXExtent() const | - | ||||||||||||||||||||||||||||||
1668 | { | - | ||||||||||||||||||||||||||||||
1669 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1670 | return d->hData.startMargin; executed 79062 times by 18 tests: return d->hData.startMargin; Executed by:
| 79062 | ||||||||||||||||||||||||||||||
1671 | } | - | ||||||||||||||||||||||||||||||
1672 | - | |||||||||||||||||||||||||||||||
1673 | /* returns -ve */ | - | ||||||||||||||||||||||||||||||
1674 | qreal QQuickFlickable::maxXExtent() const | - | ||||||||||||||||||||||||||||||
1675 | { | - | ||||||||||||||||||||||||||||||
1676 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1677 | return qMin<qreal>(minXExtent(), width() - vWidth() - d->hData.endMargin); executed 15303 times by 9 tests: return qMin<qreal>(minXExtent(), width() - vWidth() - d->hData.endMargin); Executed by:
| 15303 | ||||||||||||||||||||||||||||||
1678 | } | - | ||||||||||||||||||||||||||||||
1679 | /* returns -ve */ | - | ||||||||||||||||||||||||||||||
1680 | qreal QQuickFlickable::maxYExtent() const | - | ||||||||||||||||||||||||||||||
1681 | { | - | ||||||||||||||||||||||||||||||
1682 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1683 | return qMin<qreal>(minYExtent(), height() - vHeight() - d->vData.endMargin); executed 15263 times by 9 tests: return qMin<qreal>(minYExtent(), height() - vHeight() - d->vData.endMargin); Executed by:
| 15263 | ||||||||||||||||||||||||||||||
1684 | } | - | ||||||||||||||||||||||||||||||
1685 | - | |||||||||||||||||||||||||||||||
1686 | void QQuickFlickable::componentComplete() | - | ||||||||||||||||||||||||||||||
1687 | { | - | ||||||||||||||||||||||||||||||
1688 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1689 | QQuickItem::componentComplete(); | - | ||||||||||||||||||||||||||||||
1690 | if (!d->hData.explicitValue && d->hData.startMargin != 0.)
| 12-2146 | ||||||||||||||||||||||||||||||
1691 | setContentX(-minXExtent()); executed 12 times by 2 tests: setContentX(-minXExtent()); Executed by:
| 12 | ||||||||||||||||||||||||||||||
1692 | if (!d->vData.explicitValue && d->vData.startMargin != 0.)
| 4-3766 | ||||||||||||||||||||||||||||||
1693 | setContentY(-minYExtent()); executed 4 times by 1 test: setContentY(-minYExtent()); Executed by:
| 4 | ||||||||||||||||||||||||||||||
1694 | } executed 4098 times by 18 tests: end of block Executed by:
| 4098 | ||||||||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||||||||
1696 | void QQuickFlickable::viewportMoved(Qt::Orientations orient) | - | ||||||||||||||||||||||||||||||
1697 | { | - | ||||||||||||||||||||||||||||||
1698 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1699 | if (orient & Qt::Vertical)
| 10388-12988 | ||||||||||||||||||||||||||||||
1700 | d->viewportAxisMoved(d->vData, minYExtent(), maxYExtent(), height(), d->fixupY_callback); executed 12988 times by 7 tests: d->viewportAxisMoved(d->vData, minYExtent(), maxYExtent(), height(), d->fixupY_callback); Executed by:
| 12988 | ||||||||||||||||||||||||||||||
1701 | if (orient & Qt::Horizontal)
| 10388-12988 | ||||||||||||||||||||||||||||||
1702 | d->viewportAxisMoved(d->hData, minXExtent(), maxXExtent(), width(), d->fixupX_callback); executed 10388 times by 7 tests: d->viewportAxisMoved(d->hData, minXExtent(), maxXExtent(), width(), d->fixupX_callback); Executed by:
| 10388 | ||||||||||||||||||||||||||||||
1703 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
1704 | } executed 23376 times by 9 tests: end of block Executed by:
| 23376 | ||||||||||||||||||||||||||||||
1705 | - | |||||||||||||||||||||||||||||||
1706 | void QQuickFlickablePrivate::viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, | - | ||||||||||||||||||||||||||||||
1707 | QQuickTimeLineCallback::Callback fixupCallback) | - | ||||||||||||||||||||||||||||||
1708 | { | - | ||||||||||||||||||||||||||||||
1709 | if (!scrollingPhase && (pressed || calcVelocity)) {
| 0-23376 | ||||||||||||||||||||||||||||||
1710 | int elapsed = data.velocityTime.restart(); | - | ||||||||||||||||||||||||||||||
1711 | if (elapsed > 0) {
| 643-2907 | ||||||||||||||||||||||||||||||
1712 | qreal velocity = (data.lastPos - data.move.value()) * 1000 / elapsed; | - | ||||||||||||||||||||||||||||||
1713 | if (qAbs(velocity) > 0) {
| 0-2907 | ||||||||||||||||||||||||||||||
1714 | velocityTimeline.reset(data.smoothVelocity); | - | ||||||||||||||||||||||||||||||
1715 | if (calcVelocity)
| 1203-1704 | ||||||||||||||||||||||||||||||
1716 | velocityTimeline.set(data.smoothVelocity, velocity); executed 1203 times by 3 tests: velocityTimeline.set(data.smoothVelocity, velocity); Executed by:
| 1203 | ||||||||||||||||||||||||||||||
1717 | else | - | ||||||||||||||||||||||||||||||
1718 | velocityTimeline.move(data.smoothVelocity, velocity, reportedVelocitySmoothing); executed 1704 times by 6 tests: velocityTimeline.move(data.smoothVelocity, velocity, reportedVelocitySmoothing); Executed by:
| 1704 | ||||||||||||||||||||||||||||||
1719 | velocityTimeline.move(data.smoothVelocity, 0, reportedVelocitySmoothing); | - | ||||||||||||||||||||||||||||||
1720 | } executed 2907 times by 7 tests: end of block Executed by:
| 2907 | ||||||||||||||||||||||||||||||
1721 | } executed 2907 times by 7 tests: end of block Executed by:
| 2907 | ||||||||||||||||||||||||||||||
1722 | } else { executed 3550 times by 8 tests: end of block Executed by:
| 3550 | ||||||||||||||||||||||||||||||
1723 | if (timeline.time() > data.vTime) {
| 5070-14756 | ||||||||||||||||||||||||||||||
1724 | velocityTimeline.reset(data.smoothVelocity); | - | ||||||||||||||||||||||||||||||
1725 | qreal velocity = (data.lastPos - data.move.value()) * 1000 / (timeline.time() - data.vTime); | - | ||||||||||||||||||||||||||||||
1726 | data.smoothVelocity.setValue(velocity); | - | ||||||||||||||||||||||||||||||
1727 | } executed 14756 times by 7 tests: end of block Executed by:
| 14756 | ||||||||||||||||||||||||||||||
1728 | } executed 19826 times by 9 tests: end of block Executed by:
| 19826 | ||||||||||||||||||||||||||||||
1729 | - | |||||||||||||||||||||||||||||||
1730 | if (!data.inOvershoot && !data.fixingUp && data.flicking
| 963-22413 | ||||||||||||||||||||||||||||||
1731 | && (data.move.value() > minExtent || data.move.value() < maxExtent)
| 119-5666 | ||||||||||||||||||||||||||||||
1732 | && qAbs(data.smoothVelocity.value()) > 10) {
| 0-256 | ||||||||||||||||||||||||||||||
1733 | // Increase deceleration if we've passed a bound | - | ||||||||||||||||||||||||||||||
1734 | qreal overBound = data.move.value() > minExtent
| 119-137 | ||||||||||||||||||||||||||||||
1735 | ? data.move.value() - minExtent | - | ||||||||||||||||||||||||||||||
1736 | : maxExtent - data.move.value(); | - | ||||||||||||||||||||||||||||||
1737 | data.inOvershoot = true; | - | ||||||||||||||||||||||||||||||
1738 | qreal maxDistance = overShootDistance(vSize) - overBound; | - | ||||||||||||||||||||||||||||||
1739 | resetTimeline(data); | - | ||||||||||||||||||||||||||||||
1740 | if (maxDistance > 0)
| 20-236 | ||||||||||||||||||||||||||||||
1741 | timeline.accel(data.move, -data.smoothVelocity.value(), deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); executed 236 times by 7 tests: timeline.accel(data.move, -data.smoothVelocity.value(), deceleration*8, maxDistance); Executed by:
| 236 | ||||||||||||||||||||||||||||||
1742 | timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this)); | - | ||||||||||||||||||||||||||||||
1743 | } executed 256 times by 7 tests: end of block Executed by:
| 256 | ||||||||||||||||||||||||||||||
1744 | - | |||||||||||||||||||||||||||||||
1745 | data.lastPos = data.move.value(); | - | ||||||||||||||||||||||||||||||
1746 | data.vTime = timeline.time(); | - | ||||||||||||||||||||||||||||||
1747 | } executed 23376 times by 9 tests: end of block Executed by:
| 23376 | ||||||||||||||||||||||||||||||
1748 | - | |||||||||||||||||||||||||||||||
1749 | void QQuickFlickable::geometryChanged(const QRectF &newGeometry, | - | ||||||||||||||||||||||||||||||
1750 | const QRectF &oldGeometry) | - | ||||||||||||||||||||||||||||||
1751 | { | - | ||||||||||||||||||||||||||||||
1752 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1753 | QQuickItem::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||||||||
1754 | - | |||||||||||||||||||||||||||||||
1755 | bool changed = false; | - | ||||||||||||||||||||||||||||||
1756 | if (newGeometry.width() != oldGeometry.width()) {
| 4116-4430 | ||||||||||||||||||||||||||||||
1757 | changed = true; // we must update visualArea.widthRatio | - | ||||||||||||||||||||||||||||||
1758 | if (d->hData.viewSize < 0)
| 228-3888 | ||||||||||||||||||||||||||||||
1759 | d->contentItem->setWidth(width()); executed 3888 times by 15 tests: d->contentItem->setWidth(width()); Executed by:
| 3888 | ||||||||||||||||||||||||||||||
1760 | // Make sure that we're entirely in view. | - | ||||||||||||||||||||||||||||||
1761 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-4116 | ||||||||||||||||||||||||||||||
1762 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
1763 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
1764 | } executed 4116 times by 16 tests: end of block Executed by:
| 4116 | ||||||||||||||||||||||||||||||
1765 | } executed 4116 times by 16 tests: end of block Executed by:
| 4116 | ||||||||||||||||||||||||||||||
1766 | if (newGeometry.height() != oldGeometry.height()) {
| 4142-4404 | ||||||||||||||||||||||||||||||
1767 | changed = true; // we must update visualArea.heightRatio | - | ||||||||||||||||||||||||||||||
1768 | if (d->vData.viewSize < 0)
| 1938-2204 | ||||||||||||||||||||||||||||||
1769 | d->contentItem->setHeight(height()); executed 2204 times by 14 tests: d->contentItem->setHeight(height()); Executed by:
| 2204 | ||||||||||||||||||||||||||||||
1770 | // Make sure that we're entirely in view. | - | ||||||||||||||||||||||||||||||
1771 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-4142 | ||||||||||||||||||||||||||||||
1772 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
1773 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
1774 | } executed 4142 times by 16 tests: end of block Executed by:
| 4142 | ||||||||||||||||||||||||||||||
1775 | } executed 4142 times by 16 tests: end of block Executed by:
| 4142 | ||||||||||||||||||||||||||||||
1776 | - | |||||||||||||||||||||||||||||||
1777 | if (changed)
| 680-7866 | ||||||||||||||||||||||||||||||
1778 | d->updateBeginningEnd(); executed 7866 times by 16 tests: d->updateBeginningEnd(); Executed by:
| 7866 | ||||||||||||||||||||||||||||||
1779 | } executed 8546 times by 16 tests: end of block Executed by:
| 8546 | ||||||||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||||||||
1781 | /*! | - | ||||||||||||||||||||||||||||||
1782 | \qmlmethod QtQuick::Flickable::flick(qreal xVelocity, qreal yVelocity) | - | ||||||||||||||||||||||||||||||
1783 | - | |||||||||||||||||||||||||||||||
1784 | Flicks the content with \a xVelocity horizontally and \a yVelocity vertically in pixels/sec. | - | ||||||||||||||||||||||||||||||
1785 | - | |||||||||||||||||||||||||||||||
1786 | Calling this method will update the corresponding moving and flicking properties and signals, | - | ||||||||||||||||||||||||||||||
1787 | just like a real flick. | - | ||||||||||||||||||||||||||||||
1788 | */ | - | ||||||||||||||||||||||||||||||
1789 | - | |||||||||||||||||||||||||||||||
1790 | void QQuickFlickable::flick(qreal xVelocity, qreal yVelocity) | - | ||||||||||||||||||||||||||||||
1791 | { | - | ||||||||||||||||||||||||||||||
1792 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1793 | d->hData.reset(); | - | ||||||||||||||||||||||||||||||
1794 | d->vData.reset(); | - | ||||||||||||||||||||||||||||||
1795 | d->hData.velocity = xVelocity; | - | ||||||||||||||||||||||||||||||
1796 | d->vData.velocity = yVelocity; | - | ||||||||||||||||||||||||||||||
1797 | d->hData.vTime = d->vData.vTime = d->timeline.time(); | - | ||||||||||||||||||||||||||||||
1798 | - | |||||||||||||||||||||||||||||||
1799 | bool flickedX = d->flickX(xVelocity); | - | ||||||||||||||||||||||||||||||
1800 | bool flickedY = d->flickY(yVelocity); | - | ||||||||||||||||||||||||||||||
1801 | - | |||||||||||||||||||||||||||||||
1802 | if (flickedX)
| 2-8 | ||||||||||||||||||||||||||||||
1803 | d->hMoved = true; executed 8 times by 1 test: d->hMoved = true; Executed by:
| 8 | ||||||||||||||||||||||||||||||
1804 | if (flickedY)
| 0-10 | ||||||||||||||||||||||||||||||
1805 | d->vMoved = true; executed 10 times by 1 test: d->vMoved = true; Executed by:
| 10 | ||||||||||||||||||||||||||||||
1806 | movementStarting(); | - | ||||||||||||||||||||||||||||||
1807 | d->flickingStarted(flickedX, flickedY); | - | ||||||||||||||||||||||||||||||
1808 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
1809 | - | |||||||||||||||||||||||||||||||
1810 | void QQuickFlickablePrivate::flickingStarted(bool flickingH, bool flickingV) | - | ||||||||||||||||||||||||||||||
1811 | { | - | ||||||||||||||||||||||||||||||
1812 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1813 | if (!flickingH && !flickingV)
| 139-418 | ||||||||||||||||||||||||||||||
1814 | return; executed 139 times by 5 tests: return; Executed by:
| 139 | ||||||||||||||||||||||||||||||
1815 | - | |||||||||||||||||||||||||||||||
1816 | bool wasFlicking = hData.flicking || vData.flicking;
| 0-631 | ||||||||||||||||||||||||||||||
1817 | if (flickingH && !hData.flicking) {
| 0-352 | ||||||||||||||||||||||||||||||
1818 | hData.flicking = true; | - | ||||||||||||||||||||||||||||||
1819 | emit q->flickingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
1820 | } executed 352 times by 6 tests: end of block Executed by:
| 352 | ||||||||||||||||||||||||||||||
1821 | if (flickingV && !vData.flicking) {
| 0-337 | ||||||||||||||||||||||||||||||
1822 | vData.flicking = true; | - | ||||||||||||||||||||||||||||||
1823 | emit q->flickingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
1824 | } executed 337 times by 5 tests: end of block Executed by:
| 337 | ||||||||||||||||||||||||||||||
1825 | if (!wasFlicking && (hData.flicking || vData.flicking)) {
| 0-631 | ||||||||||||||||||||||||||||||
1826 | emit q->flickingChanged(); | - | ||||||||||||||||||||||||||||||
1827 | emit q->flickStarted(); | - | ||||||||||||||||||||||||||||||
1828 | } executed 631 times by 7 tests: end of block Executed by:
| 631 | ||||||||||||||||||||||||||||||
1829 | } executed 631 times by 7 tests: end of block Executed by:
| 631 | ||||||||||||||||||||||||||||||
1830 | - | |||||||||||||||||||||||||||||||
1831 | /*! | - | ||||||||||||||||||||||||||||||
1832 | \qmlmethod QtQuick::Flickable::cancelFlick() | - | ||||||||||||||||||||||||||||||
1833 | - | |||||||||||||||||||||||||||||||
1834 | Cancels the current flick animation. | - | ||||||||||||||||||||||||||||||
1835 | */ | - | ||||||||||||||||||||||||||||||
1836 | - | |||||||||||||||||||||||||||||||
1837 | void QQuickFlickable::cancelFlick() | - | ||||||||||||||||||||||||||||||
1838 | { | - | ||||||||||||||||||||||||||||||
1839 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1840 | d->resetTimeline(d->hData); | - | ||||||||||||||||||||||||||||||
1841 | d->resetTimeline(d->vData); | - | ||||||||||||||||||||||||||||||
1842 | movementEnding(); | - | ||||||||||||||||||||||||||||||
1843 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
1844 | - | |||||||||||||||||||||||||||||||
1845 | void QQuickFlickablePrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o) | - | ||||||||||||||||||||||||||||||
1846 | { | - | ||||||||||||||||||||||||||||||
1847 | if (QQuickItem *i = qmlobject_cast<QQuickItem *>(o)) {
| 6-344 | ||||||||||||||||||||||||||||||
1848 | i->setParentItem(static_cast<QQuickFlickablePrivate*>(prop->data)->contentItem); | - | ||||||||||||||||||||||||||||||
1849 | } else { executed 344 times by 7 tests: end of block Executed by:
| 344 | ||||||||||||||||||||||||||||||
1850 | o->setParent(prop->object); // XXX todo - do we want this? | - | ||||||||||||||||||||||||||||||
1851 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
1852 | } | - | ||||||||||||||||||||||||||||||
1853 | - | |||||||||||||||||||||||||||||||
1854 | int QQuickFlickablePrivate::data_count(QQmlListProperty<QObject> *) | - | ||||||||||||||||||||||||||||||
1855 | { | - | ||||||||||||||||||||||||||||||
1856 | // XXX todo | - | ||||||||||||||||||||||||||||||
1857 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
1858 | } | - | ||||||||||||||||||||||||||||||
1859 | - | |||||||||||||||||||||||||||||||
1860 | QObject *QQuickFlickablePrivate::data_at(QQmlListProperty<QObject> *, int) | - | ||||||||||||||||||||||||||||||
1861 | { | - | ||||||||||||||||||||||||||||||
1862 | // XXX todo | - | ||||||||||||||||||||||||||||||
1863 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
1864 | } | - | ||||||||||||||||||||||||||||||
1865 | - | |||||||||||||||||||||||||||||||
1866 | void QQuickFlickablePrivate::data_clear(QQmlListProperty<QObject> *) | - | ||||||||||||||||||||||||||||||
1867 | { | - | ||||||||||||||||||||||||||||||
1868 | // XXX todo | - | ||||||||||||||||||||||||||||||
1869 | } | - | ||||||||||||||||||||||||||||||
1870 | - | |||||||||||||||||||||||||||||||
1871 | QQmlListProperty<QObject> QQuickFlickable::flickableData() | - | ||||||||||||||||||||||||||||||
1872 | { | - | ||||||||||||||||||||||||||||||
1873 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1874 | return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append, executed 282 times by 7 tests: return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append, QQuickFlickablePrivate::data_count, QQuickFlickablePrivate::data_at, QQuickFlickablePrivate::data_clear); Executed by:
| 282 | ||||||||||||||||||||||||||||||
1875 | QQuickFlickablePrivate::data_count, executed 282 times by 7 tests: return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append, QQuickFlickablePrivate::data_count, QQuickFlickablePrivate::data_at, QQuickFlickablePrivate::data_clear); Executed by:
| 282 | ||||||||||||||||||||||||||||||
1876 | QQuickFlickablePrivate::data_at, executed 282 times by 7 tests: return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append, QQuickFlickablePrivate::data_count, QQuickFlickablePrivate::data_at, QQuickFlickablePrivate::data_clear); Executed by:
| 282 | ||||||||||||||||||||||||||||||
1877 | QQuickFlickablePrivate::data_clear); executed 282 times by 7 tests: return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append, QQuickFlickablePrivate::data_count, QQuickFlickablePrivate::data_at, QQuickFlickablePrivate::data_clear); Executed by:
| 282 | ||||||||||||||||||||||||||||||
1878 | } | - | ||||||||||||||||||||||||||||||
1879 | - | |||||||||||||||||||||||||||||||
1880 | QQmlListProperty<QQuickItem> QQuickFlickable::flickableChildren() | - | ||||||||||||||||||||||||||||||
1881 | { | - | ||||||||||||||||||||||||||||||
1882 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1883 | return QQuickItemPrivate::get(d->contentItem)->children(); never executed: return QQuickItemPrivate::get(d->contentItem)->children(); | 0 | ||||||||||||||||||||||||||||||
1884 | } | - | ||||||||||||||||||||||||||||||
1885 | - | |||||||||||||||||||||||||||||||
1886 | /*! | - | ||||||||||||||||||||||||||||||
1887 | \qmlproperty enumeration QtQuick::Flickable::boundsBehavior | - | ||||||||||||||||||||||||||||||
1888 | This property holds whether the surface may be dragged | - | ||||||||||||||||||||||||||||||
1889 | beyond the Flickable's boundaries, or overshoot the | - | ||||||||||||||||||||||||||||||
1890 | Flickable's boundaries when flicked. | - | ||||||||||||||||||||||||||||||
1891 | - | |||||||||||||||||||||||||||||||
1892 | When the \l boundsMovement is \c Flickable.FollowBoundsBehavior, a value | - | ||||||||||||||||||||||||||||||
1893 | other than \c Flickable.StopAtBounds will give a feeling that the edges of | - | ||||||||||||||||||||||||||||||
1894 | the view are soft, rather than a hard physical boundary. | - | ||||||||||||||||||||||||||||||
1895 | - | |||||||||||||||||||||||||||||||
1896 | The \c boundsBehavior can be one of: | - | ||||||||||||||||||||||||||||||
1897 | - | |||||||||||||||||||||||||||||||
1898 | \list | - | ||||||||||||||||||||||||||||||
1899 | \li Flickable.StopAtBounds - the contents can not be dragged beyond the boundary | - | ||||||||||||||||||||||||||||||
1900 | of the flickable, and flicks will not overshoot. | - | ||||||||||||||||||||||||||||||
1901 | \li Flickable.DragOverBounds - the contents can be dragged beyond the boundary | - | ||||||||||||||||||||||||||||||
1902 | of the Flickable, but flicks will not overshoot. | - | ||||||||||||||||||||||||||||||
1903 | \li Flickable.OvershootBounds - the contents can overshoot the boundary when flicked, | - | ||||||||||||||||||||||||||||||
1904 | but the content cannot be dragged beyond the boundary of the flickable. (since \c{QtQuick 2.5}) | - | ||||||||||||||||||||||||||||||
1905 | \li Flickable.DragAndOvershootBounds (default) - the contents can be dragged | - | ||||||||||||||||||||||||||||||
1906 | beyond the boundary of the Flickable, and can overshoot the | - | ||||||||||||||||||||||||||||||
1907 | boundary when flicked. | - | ||||||||||||||||||||||||||||||
1908 | \endlist | - | ||||||||||||||||||||||||||||||
1909 | - | |||||||||||||||||||||||||||||||
1910 | \sa horizontalOvershoot, verticalOvershoot, boundsMovement | - | ||||||||||||||||||||||||||||||
1911 | */ | - | ||||||||||||||||||||||||||||||
1912 | QQuickFlickable::BoundsBehavior QQuickFlickable::boundsBehavior() const | - | ||||||||||||||||||||||||||||||
1913 | { | - | ||||||||||||||||||||||||||||||
1914 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1915 | return d->boundsBehavior; executed 14 times by 1 test: return d->boundsBehavior; Executed by:
| 14 | ||||||||||||||||||||||||||||||
1916 | } | - | ||||||||||||||||||||||||||||||
1917 | - | |||||||||||||||||||||||||||||||
1918 | void QQuickFlickable::setBoundsBehavior(BoundsBehavior b) | - | ||||||||||||||||||||||||||||||
1919 | { | - | ||||||||||||||||||||||||||||||
1920 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1921 | if (b == d->boundsBehavior)
| 32-76 | ||||||||||||||||||||||||||||||
1922 | return; executed 32 times by 1 test: return; Executed by:
| 32 | ||||||||||||||||||||||||||||||
1923 | d->boundsBehavior = b; | - | ||||||||||||||||||||||||||||||
1924 | emit boundsBehaviorChanged(); | - | ||||||||||||||||||||||||||||||
1925 | } executed 76 times by 2 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||||||||
1926 | - | |||||||||||||||||||||||||||||||
1927 | /*! | - | ||||||||||||||||||||||||||||||
1928 | \qmlproperty Transition QtQuick::Flickable::rebound | - | ||||||||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||||||||
1930 | This holds the transition to be applied to the content view when | - | ||||||||||||||||||||||||||||||
1931 | it snaps back to the bounds of the flickable. The transition is | - | ||||||||||||||||||||||||||||||
1932 | triggered when the view is flicked or dragged past the edge of the | - | ||||||||||||||||||||||||||||||
1933 | content area, or when returnToBounds() is called. | - | ||||||||||||||||||||||||||||||
1934 | - | |||||||||||||||||||||||||||||||
1935 | \qml | - | ||||||||||||||||||||||||||||||
1936 | import QtQuick 2.0 | - | ||||||||||||||||||||||||||||||
1937 | - | |||||||||||||||||||||||||||||||
1938 | Flickable { | - | ||||||||||||||||||||||||||||||
1939 | width: 150; height: 150 | - | ||||||||||||||||||||||||||||||
1940 | contentWidth: 300; contentHeight: 300 | - | ||||||||||||||||||||||||||||||
1941 | - | |||||||||||||||||||||||||||||||
1942 | rebound: Transition { | - | ||||||||||||||||||||||||||||||
1943 | NumberAnimation { | - | ||||||||||||||||||||||||||||||
1944 | properties: "x,y" | - | ||||||||||||||||||||||||||||||
1945 | duration: 1000 | - | ||||||||||||||||||||||||||||||
1946 | easing.type: Easing.OutBounce | - | ||||||||||||||||||||||||||||||
1947 | } | - | ||||||||||||||||||||||||||||||
1948 | } | - | ||||||||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||||||||
1950 | Rectangle { | - | ||||||||||||||||||||||||||||||
1951 | width: 300; height: 300 | - | ||||||||||||||||||||||||||||||
1952 | gradient: Gradient { | - | ||||||||||||||||||||||||||||||
1953 | GradientStop { position: 0.0; color: "lightsteelblue" } | - | ||||||||||||||||||||||||||||||
1954 | GradientStop { position: 1.0; color: "blue" } | - | ||||||||||||||||||||||||||||||
1955 | } | - | ||||||||||||||||||||||||||||||
1956 | } | - | ||||||||||||||||||||||||||||||
1957 | } | - | ||||||||||||||||||||||||||||||
1958 | \endqml | - | ||||||||||||||||||||||||||||||
1959 | - | |||||||||||||||||||||||||||||||
1960 | When the above view is flicked beyond its bounds, it will return to its | - | ||||||||||||||||||||||||||||||
1961 | bounds using the transition specified: | - | ||||||||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||||||||
1963 | \image flickable-rebound.gif | - | ||||||||||||||||||||||||||||||
1964 | - | |||||||||||||||||||||||||||||||
1965 | If this property is not set, a default animation is applied. | - | ||||||||||||||||||||||||||||||
1966 | */ | - | ||||||||||||||||||||||||||||||
1967 | QQuickTransition *QQuickFlickable::rebound() const | - | ||||||||||||||||||||||||||||||
1968 | { | - | ||||||||||||||||||||||||||||||
1969 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1970 | return d->rebound; never executed: return d->rebound; | 0 | ||||||||||||||||||||||||||||||
1971 | } | - | ||||||||||||||||||||||||||||||
1972 | - | |||||||||||||||||||||||||||||||
1973 | void QQuickFlickable::setRebound(QQuickTransition *transition) | - | ||||||||||||||||||||||||||||||
1974 | { | - | ||||||||||||||||||||||||||||||
1975 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
1976 | if (transition) {
| 4 | ||||||||||||||||||||||||||||||
1977 | if (!d->hData.transitionToBounds)
| 0-4 | ||||||||||||||||||||||||||||||
1978 | d->hData.transitionToBounds = new QQuickFlickableReboundTransition(this, QLatin1String("x")); executed 4 times by 1 test: d->hData.transitionToBounds = new QQuickFlickableReboundTransition(this, QLatin1String("x")); Executed by:
| 4 | ||||||||||||||||||||||||||||||
1979 | if (!d->vData.transitionToBounds)
| 0-4 | ||||||||||||||||||||||||||||||
1980 | d->vData.transitionToBounds = new QQuickFlickableReboundTransition(this, QLatin1String("y")); executed 4 times by 1 test: d->vData.transitionToBounds = new QQuickFlickableReboundTransition(this, QLatin1String("y")); Executed by:
| 4 | ||||||||||||||||||||||||||||||
1981 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
1982 | if (d->rebound != transition) {
| 4 | ||||||||||||||||||||||||||||||
1983 | d->rebound = transition; | - | ||||||||||||||||||||||||||||||
1984 | emit reboundChanged(); | - | ||||||||||||||||||||||||||||||
1985 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
1986 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||
1987 | - | |||||||||||||||||||||||||||||||
1988 | /*! | - | ||||||||||||||||||||||||||||||
1989 | \qmlproperty real QtQuick::Flickable::contentWidth | - | ||||||||||||||||||||||||||||||
1990 | \qmlproperty real QtQuick::Flickable::contentHeight | - | ||||||||||||||||||||||||||||||
1991 | - | |||||||||||||||||||||||||||||||
1992 | The dimensions of the content (the surface controlled by Flickable). | - | ||||||||||||||||||||||||||||||
1993 | This should typically be set to the combined size of the items placed in the | - | ||||||||||||||||||||||||||||||
1994 | Flickable. | - | ||||||||||||||||||||||||||||||
1995 | - | |||||||||||||||||||||||||||||||
1996 | The following snippet shows how these properties are used to display | - | ||||||||||||||||||||||||||||||
1997 | an image that is larger than the Flickable item itself: | - | ||||||||||||||||||||||||||||||
1998 | - | |||||||||||||||||||||||||||||||
1999 | \snippet qml/flickable.qml document | - | ||||||||||||||||||||||||||||||
2000 | - | |||||||||||||||||||||||||||||||
2001 | In some cases, the content dimensions can be automatically set | - | ||||||||||||||||||||||||||||||
2002 | based on the \l {Item::childrenRect.width}{childrenRect.width} | - | ||||||||||||||||||||||||||||||
2003 | and \l {Item::childrenRect.height}{childrenRect.height} properties | - | ||||||||||||||||||||||||||||||
2004 | of the \l contentItem. For example, the previous snippet could be rewritten with: | - | ||||||||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||||||||
2006 | \code | - | ||||||||||||||||||||||||||||||
2007 | contentWidth: contentItem.childrenRect.width; contentHeight: contentItem.childrenRect.height | - | ||||||||||||||||||||||||||||||
2008 | \endcode | - | ||||||||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||||||||
2010 | Though this assumes that the origin of the childrenRect is 0,0. | - | ||||||||||||||||||||||||||||||
2011 | */ | - | ||||||||||||||||||||||||||||||
2012 | qreal QQuickFlickable::contentWidth() const | - | ||||||||||||||||||||||||||||||
2013 | { | - | ||||||||||||||||||||||||||||||
2014 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2015 | return d->hData.viewSize; executed 3147 times by 4 tests: return d->hData.viewSize; Executed by:
| 3147 | ||||||||||||||||||||||||||||||
2016 | } | - | ||||||||||||||||||||||||||||||
2017 | - | |||||||||||||||||||||||||||||||
2018 | void QQuickFlickable::setContentWidth(qreal w) | - | ||||||||||||||||||||||||||||||
2019 | { | - | ||||||||||||||||||||||||||||||
2020 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2021 | if (d->hData.viewSize == w)
| 1882-4240 | ||||||||||||||||||||||||||||||
2022 | return; executed 4240 times by 4 tests: return; Executed by:
| 4240 | ||||||||||||||||||||||||||||||
2023 | d->hData.viewSize = w; | - | ||||||||||||||||||||||||||||||
2024 | if (w < 0)
| 40-1842 | ||||||||||||||||||||||||||||||
2025 | d->contentItem->setWidth(width()); executed 40 times by 2 tests: d->contentItem->setWidth(width()); Executed by:
| 40 | ||||||||||||||||||||||||||||||
2026 | else | - | ||||||||||||||||||||||||||||||
2027 | d->contentItem->setWidth(w); executed 1842 times by 9 tests: d->contentItem->setWidth(w); Executed by:
| 1842 | ||||||||||||||||||||||||||||||
2028 | d->hData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2029 | // Make sure that we're entirely in view. | - | ||||||||||||||||||||||||||||||
2030 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-1882 | ||||||||||||||||||||||||||||||
2031 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2032 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
2033 | } else if (!d->pressed && d->hData.fixingUp) { executed 1882 times by 9 tests: end of block Executed by:
| 0-1882 | ||||||||||||||||||||||||||||||
2034 | d->fixupMode = QQuickFlickablePrivate::ExtentChanged; | - | ||||||||||||||||||||||||||||||
2035 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
2036 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
2037 | emit contentWidthChanged(); | - | ||||||||||||||||||||||||||||||
2038 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2039 | } executed 1882 times by 9 tests: end of block Executed by:
| 1882 | ||||||||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||||||||
2041 | qreal QQuickFlickable::contentHeight() const | - | ||||||||||||||||||||||||||||||
2042 | { | - | ||||||||||||||||||||||||||||||
2043 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2044 | return d->vData.viewSize; executed 3147 times by 4 tests: return d->vData.viewSize; Executed by:
| 3147 | ||||||||||||||||||||||||||||||
2045 | } | - | ||||||||||||||||||||||||||||||
2046 | - | |||||||||||||||||||||||||||||||
2047 | void QQuickFlickable::setContentHeight(qreal h) | - | ||||||||||||||||||||||||||||||
2048 | { | - | ||||||||||||||||||||||||||||||
2049 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2050 | if (d->vData.viewSize == h)
| 10238-12802 | ||||||||||||||||||||||||||||||
2051 | return; executed 12802 times by 9 tests: return; Executed by:
| 12802 | ||||||||||||||||||||||||||||||
2052 | d->vData.viewSize = h; | - | ||||||||||||||||||||||||||||||
2053 | if (h < 0)
| 668-9570 | ||||||||||||||||||||||||||||||
2054 | d->contentItem->setHeight(height()); executed 668 times by 2 tests: d->contentItem->setHeight(height()); Executed by:
| 668 | ||||||||||||||||||||||||||||||
2055 | else | - | ||||||||||||||||||||||||||||||
2056 | d->contentItem->setHeight(h); executed 9570 times by 17 tests: d->contentItem->setHeight(h); Executed by:
| 9570 | ||||||||||||||||||||||||||||||
2057 | d->vData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2058 | // Make sure that we're entirely in view. | - | ||||||||||||||||||||||||||||||
2059 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-10230 | ||||||||||||||||||||||||||||||
2060 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2061 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
2062 | } else if (!d->pressed && d->vData.fixingUp) { executed 10179 times by 17 tests: end of block Executed by:
| 0-10179 | ||||||||||||||||||||||||||||||
2063 | d->fixupMode = QQuickFlickablePrivate::ExtentChanged; | - | ||||||||||||||||||||||||||||||
2064 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
2065 | } executed 51 times by 1 test: end of block Executed by:
| 51 | ||||||||||||||||||||||||||||||
2066 | emit contentHeightChanged(); | - | ||||||||||||||||||||||||||||||
2067 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2068 | } executed 10238 times by 17 tests: end of block Executed by:
| 10238 | ||||||||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||||||||
2070 | /*! | - | ||||||||||||||||||||||||||||||
2071 | \qmlproperty real QtQuick::Flickable::topMargin | - | ||||||||||||||||||||||||||||||
2072 | \qmlproperty real QtQuick::Flickable::leftMargin | - | ||||||||||||||||||||||||||||||
2073 | \qmlproperty real QtQuick::Flickable::bottomMargin | - | ||||||||||||||||||||||||||||||
2074 | \qmlproperty real QtQuick::Flickable::rightMargin | - | ||||||||||||||||||||||||||||||
2075 | - | |||||||||||||||||||||||||||||||
2076 | These properties hold the margins around the content. This space is reserved | - | ||||||||||||||||||||||||||||||
2077 | in addition to the contentWidth and contentHeight. | - | ||||||||||||||||||||||||||||||
2078 | */ | - | ||||||||||||||||||||||||||||||
2079 | - | |||||||||||||||||||||||||||||||
2080 | - | |||||||||||||||||||||||||||||||
2081 | qreal QQuickFlickable::topMargin() const | - | ||||||||||||||||||||||||||||||
2082 | { | - | ||||||||||||||||||||||||||||||
2083 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2084 | return d->vData.startMargin; executed 8 times by 1 test: return d->vData.startMargin; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2085 | } | - | ||||||||||||||||||||||||||||||
2086 | - | |||||||||||||||||||||||||||||||
2087 | void QQuickFlickable::setTopMargin(qreal m) | - | ||||||||||||||||||||||||||||||
2088 | { | - | ||||||||||||||||||||||||||||||
2089 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2090 | if (d->vData.startMargin == m)
| 12-22 | ||||||||||||||||||||||||||||||
2091 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||||||||||||||||||||||||||
2092 | d->vData.startMargin = m; | - | ||||||||||||||||||||||||||||||
2093 | d->vData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2094 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-22 | ||||||||||||||||||||||||||||||
2095 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2096 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
2097 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2098 | emit topMarginChanged(); | - | ||||||||||||||||||||||||||||||
2099 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2100 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2101 | - | |||||||||||||||||||||||||||||||
2102 | qreal QQuickFlickable::bottomMargin() const | - | ||||||||||||||||||||||||||||||
2103 | { | - | ||||||||||||||||||||||||||||||
2104 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2105 | return d->vData.endMargin; executed 8 times by 1 test: return d->vData.endMargin; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2106 | } | - | ||||||||||||||||||||||||||||||
2107 | - | |||||||||||||||||||||||||||||||
2108 | void QQuickFlickable::setBottomMargin(qreal m) | - | ||||||||||||||||||||||||||||||
2109 | { | - | ||||||||||||||||||||||||||||||
2110 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2111 | if (d->vData.endMargin == m)
| 8-18 | ||||||||||||||||||||||||||||||
2112 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2113 | d->vData.endMargin = m; | - | ||||||||||||||||||||||||||||||
2114 | d->vData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2115 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-18 | ||||||||||||||||||||||||||||||
2116 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2117 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
2118 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||||||||
2119 | emit bottomMarginChanged(); | - | ||||||||||||||||||||||||||||||
2120 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2121 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||||||||||||||
2122 | - | |||||||||||||||||||||||||||||||
2123 | qreal QQuickFlickable::leftMargin() const | - | ||||||||||||||||||||||||||||||
2124 | { | - | ||||||||||||||||||||||||||||||
2125 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2126 | return d->hData.startMargin; executed 8 times by 1 test: return d->hData.startMargin; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2127 | } | - | ||||||||||||||||||||||||||||||
2128 | - | |||||||||||||||||||||||||||||||
2129 | void QQuickFlickable::setLeftMargin(qreal m) | - | ||||||||||||||||||||||||||||||
2130 | { | - | ||||||||||||||||||||||||||||||
2131 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2132 | if (d->hData.startMargin == m)
| 12-24 | ||||||||||||||||||||||||||||||
2133 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||||||||||||||||||||||||||
2134 | d->hData.startMargin = m; | - | ||||||||||||||||||||||||||||||
2135 | d->hData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2136 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-24 | ||||||||||||||||||||||||||||||
2137 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2138 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
2139 | } executed 24 times by 3 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||||||||
2140 | emit leftMarginChanged(); | - | ||||||||||||||||||||||||||||||
2141 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2142 | } executed 24 times by 3 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||||||||
2143 | - | |||||||||||||||||||||||||||||||
2144 | qreal QQuickFlickable::rightMargin() const | - | ||||||||||||||||||||||||||||||
2145 | { | - | ||||||||||||||||||||||||||||||
2146 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2147 | return d->hData.endMargin; executed 8 times by 1 test: return d->hData.endMargin; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2148 | } | - | ||||||||||||||||||||||||||||||
2149 | - | |||||||||||||||||||||||||||||||
2150 | void QQuickFlickable::setRightMargin(qreal m) | - | ||||||||||||||||||||||||||||||
2151 | { | - | ||||||||||||||||||||||||||||||
2152 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2153 | if (d->hData.endMargin == m)
| 8-22 | ||||||||||||||||||||||||||||||
2154 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2155 | d->hData.endMargin = m; | - | ||||||||||||||||||||||||||||||
2156 | d->hData.markExtentsDirty(); | - | ||||||||||||||||||||||||||||||
2157 | if (!d->pressed && !d->hData.moving && !d->vData.moving) {
| 0-22 | ||||||||||||||||||||||||||||||
2158 | d->fixupMode = QQuickFlickablePrivate::Immediate; | - | ||||||||||||||||||||||||||||||
2159 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
2160 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2161 | emit rightMarginChanged(); | - | ||||||||||||||||||||||||||||||
2162 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2163 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||||||||
2165 | /*! | - | ||||||||||||||||||||||||||||||
2166 | \qmlproperty real QtQuick::Flickable::originX | - | ||||||||||||||||||||||||||||||
2167 | \qmlproperty real QtQuick::Flickable::originY | - | ||||||||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||||||||
2169 | These properties hold the origin of the content. This value always refers | - | ||||||||||||||||||||||||||||||
2170 | to the top-left position of the content regardless of layout direction. | - | ||||||||||||||||||||||||||||||
2171 | - | |||||||||||||||||||||||||||||||
2172 | This is usually (0,0), however ListView and GridView may have an arbitrary | - | ||||||||||||||||||||||||||||||
2173 | origin due to delegate size variation, or item insertion/removal outside | - | ||||||||||||||||||||||||||||||
2174 | the visible region. | - | ||||||||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||||||||
2176 | \sa contentX, contentY | - | ||||||||||||||||||||||||||||||
2177 | */ | - | ||||||||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||||||||
2179 | qreal QQuickFlickable::originY() const | - | ||||||||||||||||||||||||||||||
2180 | { | - | ||||||||||||||||||||||||||||||
2181 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2182 | return -minYExtent() + d->vData.startMargin; executed 27003 times by 17 tests: return -minYExtent() + d->vData.startMargin; Executed by:
| 27003 | ||||||||||||||||||||||||||||||
2183 | } | - | ||||||||||||||||||||||||||||||
2184 | - | |||||||||||||||||||||||||||||||
2185 | qreal QQuickFlickable::originX() const | - | ||||||||||||||||||||||||||||||
2186 | { | - | ||||||||||||||||||||||||||||||
2187 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2188 | return -minXExtent() + d->hData.startMargin; executed 5883 times by 9 tests: return -minXExtent() + d->hData.startMargin; Executed by:
| 5883 | ||||||||||||||||||||||||||||||
2189 | } | - | ||||||||||||||||||||||||||||||
2190 | - | |||||||||||||||||||||||||||||||
2191 | - | |||||||||||||||||||||||||||||||
2192 | /*! | - | ||||||||||||||||||||||||||||||
2193 | \qmlmethod QtQuick::Flickable::resizeContent(real width, real height, QPointF center) | - | ||||||||||||||||||||||||||||||
2194 | - | |||||||||||||||||||||||||||||||
2195 | Resizes the content to \a width x \a height about \a center. | - | ||||||||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||||||||
2197 | This does not scale the contents of the Flickable - it only resizes the \l contentWidth | - | ||||||||||||||||||||||||||||||
2198 | and \l contentHeight. | - | ||||||||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||||||||
2200 | Resizing the content may result in the content being positioned outside | - | ||||||||||||||||||||||||||||||
2201 | the bounds of the Flickable. Calling \l returnToBounds() will | - | ||||||||||||||||||||||||||||||
2202 | move the content back within legal bounds. | - | ||||||||||||||||||||||||||||||
2203 | */ | - | ||||||||||||||||||||||||||||||
2204 | void QQuickFlickable::resizeContent(qreal w, qreal h, QPointF center) | - | ||||||||||||||||||||||||||||||
2205 | { | - | ||||||||||||||||||||||||||||||
2206 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2207 | const qreal oldHSize = d->hData.viewSize; | - | ||||||||||||||||||||||||||||||
2208 | const qreal oldVSize = d->vData.viewSize; | - | ||||||||||||||||||||||||||||||
2209 | const bool needToUpdateWidth = w != oldHSize; | - | ||||||||||||||||||||||||||||||
2210 | const bool needToUpdateHeight = h != oldVSize; | - | ||||||||||||||||||||||||||||||
2211 | d->hData.viewSize = w; | - | ||||||||||||||||||||||||||||||
2212 | d->vData.viewSize = h; | - | ||||||||||||||||||||||||||||||
2213 | d->contentItem->setSize(QSizeF(w, h)); | - | ||||||||||||||||||||||||||||||
2214 | if (needToUpdateWidth)
| 0-2 | ||||||||||||||||||||||||||||||
2215 | emit contentWidthChanged(); executed 2 times by 1 test: contentWidthChanged(); Executed by:
| 2 | ||||||||||||||||||||||||||||||
2216 | if (needToUpdateHeight)
| 0-2 | ||||||||||||||||||||||||||||||
2217 | emit contentHeightChanged(); executed 2 times by 1 test: contentHeightChanged(); Executed by:
| 2 | ||||||||||||||||||||||||||||||
2218 | - | |||||||||||||||||||||||||||||||
2219 | if (center.x() != 0) {
| 0-2 | ||||||||||||||||||||||||||||||
2220 | qreal pos = center.x() * w / oldHSize; | - | ||||||||||||||||||||||||||||||
2221 | setContentX(contentX() + pos - center.x()); | - | ||||||||||||||||||||||||||||||
2222 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
2223 | if (center.y() != 0) {
| 0-2 | ||||||||||||||||||||||||||||||
2224 | qreal pos = center.y() * h / oldVSize; | - | ||||||||||||||||||||||||||||||
2225 | setContentY(contentY() + pos - center.y()); | - | ||||||||||||||||||||||||||||||
2226 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
2227 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2228 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
2229 | - | |||||||||||||||||||||||||||||||
2230 | /*! | - | ||||||||||||||||||||||||||||||
2231 | \qmlmethod QtQuick::Flickable::returnToBounds() | - | ||||||||||||||||||||||||||||||
2232 | - | |||||||||||||||||||||||||||||||
2233 | Ensures the content is within legal bounds. | - | ||||||||||||||||||||||||||||||
2234 | - | |||||||||||||||||||||||||||||||
2235 | This may be called to ensure that the content is within legal bounds | - | ||||||||||||||||||||||||||||||
2236 | after manually positioning the content. | - | ||||||||||||||||||||||||||||||
2237 | */ | - | ||||||||||||||||||||||||||||||
2238 | void QQuickFlickable::returnToBounds() | - | ||||||||||||||||||||||||||||||
2239 | { | - | ||||||||||||||||||||||||||||||
2240 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2241 | d->fixupX(); | - | ||||||||||||||||||||||||||||||
2242 | d->fixupY(); | - | ||||||||||||||||||||||||||||||
2243 | } executed 80 times by 6 tests: end of block Executed by:
| 80 | ||||||||||||||||||||||||||||||
2244 | - | |||||||||||||||||||||||||||||||
2245 | qreal QQuickFlickable::vWidth() const | - | ||||||||||||||||||||||||||||||
2246 | { | - | ||||||||||||||||||||||||||||||
2247 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2248 | if (d->hData.viewSize < 0)
| 1381-19012 | ||||||||||||||||||||||||||||||
2249 | return width(); executed 1381 times by 8 tests: return width(); Executed by:
| 1381 | ||||||||||||||||||||||||||||||
2250 | else | - | ||||||||||||||||||||||||||||||
2251 | return d->hData.viewSize; executed 19012 times by 8 tests: return d->hData.viewSize; Executed by:
| 19012 | ||||||||||||||||||||||||||||||
2252 | } | - | ||||||||||||||||||||||||||||||
2253 | - | |||||||||||||||||||||||||||||||
2254 | qreal QQuickFlickable::vHeight() const | - | ||||||||||||||||||||||||||||||
2255 | { | - | ||||||||||||||||||||||||||||||
2256 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2257 | if (d->vData.viewSize < 0)
| 648-19712 | ||||||||||||||||||||||||||||||
2258 | return height(); executed 648 times by 8 tests: return height(); Executed by:
| 648 | ||||||||||||||||||||||||||||||
2259 | else | - | ||||||||||||||||||||||||||||||
2260 | return d->vData.viewSize; executed 19712 times by 8 tests: return d->vData.viewSize; Executed by:
| 19712 | ||||||||||||||||||||||||||||||
2261 | } | - | ||||||||||||||||||||||||||||||
2262 | - | |||||||||||||||||||||||||||||||
2263 | bool QQuickFlickable::xflick() const | - | ||||||||||||||||||||||||||||||
2264 | { | - | ||||||||||||||||||||||||||||||
2265 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2266 | if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vWidth() > width()))
| 0-21919 | ||||||||||||||||||||||||||||||
2267 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
2268 | if (d->flickableDirection == QQuickFlickable::AutoFlickDirection)
| 5090-16829 | ||||||||||||||||||||||||||||||
2269 | return std::floor(qAbs(vWidth() - width())); executed 5090 times by 5 tests: return std::floor(qAbs(vWidth() - width())); Executed by:
| 5090 | ||||||||||||||||||||||||||||||
2270 | return d->flickableDirection & QQuickFlickable::HorizontalFlick; executed 16829 times by 5 tests: return d->flickableDirection & QQuickFlickable::HorizontalFlick; Executed by:
| 16829 | ||||||||||||||||||||||||||||||
2271 | } | - | ||||||||||||||||||||||||||||||
2272 | - | |||||||||||||||||||||||||||||||
2273 | bool QQuickFlickable::yflick() const | - | ||||||||||||||||||||||||||||||
2274 | { | - | ||||||||||||||||||||||||||||||
2275 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2276 | if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vHeight() > height()))
| 0-38229 | ||||||||||||||||||||||||||||||
2277 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
2278 | if (d->flickableDirection == QQuickFlickable::AutoFlickDirection)
| 5097-33132 | ||||||||||||||||||||||||||||||
2279 | return std::floor(qAbs(vHeight() - height())); executed 5097 times by 5 tests: return std::floor(qAbs(vHeight() - height())); Executed by:
| 5097 | ||||||||||||||||||||||||||||||
2280 | return d->flickableDirection & QQuickFlickable::VerticalFlick; executed 33132 times by 8 tests: return d->flickableDirection & QQuickFlickable::VerticalFlick; Executed by:
| 33132 | ||||||||||||||||||||||||||||||
2281 | } | - | ||||||||||||||||||||||||||||||
2282 | - | |||||||||||||||||||||||||||||||
2283 | void QQuickFlickable::mouseUngrabEvent() | - | ||||||||||||||||||||||||||||||
2284 | { | - | ||||||||||||||||||||||||||||||
2285 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2286 | // if our mouse grab has been removed (probably by another Flickable), | - | ||||||||||||||||||||||||||||||
2287 | // fix our state | - | ||||||||||||||||||||||||||||||
2288 | if (!d->replayingPressEvent)
| 2-812 | ||||||||||||||||||||||||||||||
2289 | d->cancelInteraction(); executed 812 times by 7 tests: d->cancelInteraction(); Executed by:
| 812 | ||||||||||||||||||||||||||||||
2290 | } executed 814 times by 7 tests: end of block Executed by:
| 814 | ||||||||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||||||||
2292 | void QQuickFlickablePrivate::cancelInteraction() | - | ||||||||||||||||||||||||||||||
2293 | { | - | ||||||||||||||||||||||||||||||
2294 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2295 | if (pressed) {
| 88-740 | ||||||||||||||||||||||||||||||
2296 | clearDelayedPress(); | - | ||||||||||||||||||||||||||||||
2297 | pressed = false; | - | ||||||||||||||||||||||||||||||
2298 | draggingEnding(); | - | ||||||||||||||||||||||||||||||
2299 | stealMouse = false; | - | ||||||||||||||||||||||||||||||
2300 | q->setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
2301 | fixupX(); | - | ||||||||||||||||||||||||||||||
2302 | fixupY(); | - | ||||||||||||||||||||||||||||||
2303 | if (!isViewMoving())
| 18-70 | ||||||||||||||||||||||||||||||
2304 | q->movementEnding(); executed 70 times by 2 tests: q->movementEnding(); Executed by:
| 70 | ||||||||||||||||||||||||||||||
2305 | } executed 88 times by 3 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||||||||
2306 | } executed 828 times by 8 tests: end of block Executed by:
| 828 | ||||||||||||||||||||||||||||||
2307 | - | |||||||||||||||||||||||||||||||
2308 | /*! | - | ||||||||||||||||||||||||||||||
2309 | QQuickFlickable::filterMouseEvent checks filtered mouse events and potentially steals them. | - | ||||||||||||||||||||||||||||||
2310 | - | |||||||||||||||||||||||||||||||
2311 | This is how flickable takes over events from other items (\a receiver) that are on top of it. | - | ||||||||||||||||||||||||||||||
2312 | It filters their events and may take over (grab) the \a event. | - | ||||||||||||||||||||||||||||||
2313 | Return true if the mouse event will be stolen. | - | ||||||||||||||||||||||||||||||
2314 | \internal | - | ||||||||||||||||||||||||||||||
2315 | */ | - | ||||||||||||||||||||||||||||||
2316 | bool QQuickFlickable::filterMouseEvent(QQuickItem *receiver, QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
2317 | { | - | ||||||||||||||||||||||||||||||
2318 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2319 | QPointF localPos = mapFromScene(event->windowPos()); | - | ||||||||||||||||||||||||||||||
2320 | - | |||||||||||||||||||||||||||||||
2321 | Q_ASSERT_X(receiver != this, "", "Flickable received a filter event for itself"); | - | ||||||||||||||||||||||||||||||
2322 | if (receiver == this && d->stealMouse) {
| 0-1637 | ||||||||||||||||||||||||||||||
2323 | // we are already the grabber and we do want the mouse event to ourselves. | - | ||||||||||||||||||||||||||||||
2324 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
2325 | } | - | ||||||||||||||||||||||||||||||
2326 | - | |||||||||||||||||||||||||||||||
2327 | bool receiverDisabled = receiver && !receiver->isEnabled();
| 0-1637 | ||||||||||||||||||||||||||||||
2328 | bool stealThisEvent = d->stealMouse; | - | ||||||||||||||||||||||||||||||
2329 | bool receiverKeepsGrab = receiver && (receiver->keepMouseGrab() || receiver->keepTouchGrab());
| 0-1637 | ||||||||||||||||||||||||||||||
2330 | if ((stealThisEvent || contains(localPos)) && (!receiver || !receiverKeepsGrab || receiverDisabled)) {
| 0-1629 | ||||||||||||||||||||||||||||||
2331 | QScopedPointer<QMouseEvent> mouseEvent(QQuickWindowPrivate::cloneMouseEvent(event, &localPos)); | - | ||||||||||||||||||||||||||||||
2332 | mouseEvent->setAccepted(false); | - | ||||||||||||||||||||||||||||||
2333 | - | |||||||||||||||||||||||||||||||
2334 | switch (mouseEvent->type()) { | - | ||||||||||||||||||||||||||||||
2335 | case QEvent::MouseMove: executed 554 times by 6 tests: case QEvent::MouseMove: Executed by:
| 554 | ||||||||||||||||||||||||||||||
2336 | d->handleMouseMoveEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
2337 | break; executed 554 times by 6 tests: break; Executed by:
| 554 | ||||||||||||||||||||||||||||||
2338 | case QEvent::MouseButtonPress: executed 655 times by 7 tests: case QEvent::MouseButtonPress: Executed by:
| 655 | ||||||||||||||||||||||||||||||
2339 | d->handleMousePressEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
2340 | d->captureDelayedPress(receiver, event); | - | ||||||||||||||||||||||||||||||
2341 | stealThisEvent = d->stealMouse; // Update stealThisEvent in case changed by function call above | - | ||||||||||||||||||||||||||||||
2342 | break; executed 655 times by 7 tests: break; Executed by:
| 655 | ||||||||||||||||||||||||||||||
2343 | case QEvent::MouseButtonRelease: executed 46 times by 4 tests: case QEvent::MouseButtonRelease: Executed by:
| 46 | ||||||||||||||||||||||||||||||
2344 | d->handleMouseReleaseEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
2345 | stealThisEvent = d->stealMouse; | - | ||||||||||||||||||||||||||||||
2346 | break; executed 46 times by 4 tests: break; Executed by:
| 46 | ||||||||||||||||||||||||||||||
2347 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
2348 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
2349 | } | - | ||||||||||||||||||||||||||||||
2350 | if ((receiver && stealThisEvent && !receiverKeepsGrab && receiver != this) || receiverDisabled) {
| 0-1255 | ||||||||||||||||||||||||||||||
2351 | d->clearDelayedPress(); | - | ||||||||||||||||||||||||||||||
2352 | grabMouse(); | - | ||||||||||||||||||||||||||||||
2353 | } else if (d->delayedPressEvent) { executed 139 times by 7 tests: end of block Executed by:
| 16-1100 | ||||||||||||||||||||||||||||||
2354 | grabMouse(); | - | ||||||||||||||||||||||||||||||
2355 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
2356 | - | |||||||||||||||||||||||||||||||
2357 | const bool filtered = stealThisEvent || d->delayedPressEvent || receiverDisabled;
| 0-1116 | ||||||||||||||||||||||||||||||
2358 | if (filtered) {
| 155-1100 | ||||||||||||||||||||||||||||||
2359 | event->setAccepted(true); | - | ||||||||||||||||||||||||||||||
2360 | } executed 155 times by 7 tests: end of block Executed by:
| 155 | ||||||||||||||||||||||||||||||
2361 | return filtered; executed 1255 times by 7 tests: return filtered; Executed by:
| 1255 | ||||||||||||||||||||||||||||||
2362 | } else if (d->lastPosTime != -1) {
| 56-326 | ||||||||||||||||||||||||||||||
2363 | d->lastPosTime = -1; | - | ||||||||||||||||||||||||||||||
2364 | returnToBounds(); | - | ||||||||||||||||||||||||||||||
2365 | } executed 56 times by 5 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||||||||
2366 | if (event->type() == QEvent::MouseButtonRelease || (receiverKeepsGrab && !receiverDisabled)) {
| 0-322 | ||||||||||||||||||||||||||||||
2367 | // mouse released, or another item has claimed the grab | - | ||||||||||||||||||||||||||||||
2368 | d->lastPosTime = -1; | - | ||||||||||||||||||||||||||||||
2369 | d->clearDelayedPress(); | - | ||||||||||||||||||||||||||||||
2370 | d->stealMouse = false; | - | ||||||||||||||||||||||||||||||
2371 | d->pressed = false; | - | ||||||||||||||||||||||||||||||
2372 | } executed 378 times by 6 tests: end of block Executed by:
| 378 | ||||||||||||||||||||||||||||||
2373 | return false; executed 382 times by 6 tests: return false; Executed by:
| 382 | ||||||||||||||||||||||||||||||
2374 | } | - | ||||||||||||||||||||||||||||||
2375 | - | |||||||||||||||||||||||||||||||
2376 | - | |||||||||||||||||||||||||||||||
2377 | bool QQuickFlickable::childMouseEventFilter(QQuickItem *i, QEvent *e) | - | ||||||||||||||||||||||||||||||
2378 | { | - | ||||||||||||||||||||||||||||||
2379 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2380 | if (!isVisible() || !isEnabled() || !isInteractive()) {
| 0-2169 | ||||||||||||||||||||||||||||||
2381 | d->cancelInteraction(); | - | ||||||||||||||||||||||||||||||
2382 | return QQuickItem::childMouseEventFilter(i, e); never executed: return QQuickItem::childMouseEventFilter(i, e); | 0 | ||||||||||||||||||||||||||||||
2383 | } | - | ||||||||||||||||||||||||||||||
2384 | - | |||||||||||||||||||||||||||||||
2385 | switch (e->type()) { | - | ||||||||||||||||||||||||||||||
2386 | case QEvent::MouseButtonPress: executed 659 times by 7 tests: case QEvent::MouseButtonPress: Executed by:
| 659 | ||||||||||||||||||||||||||||||
2387 | case QEvent::MouseMove: executed 872 times by 6 tests: case QEvent::MouseMove: Executed by:
| 872 | ||||||||||||||||||||||||||||||
2388 | case QEvent::MouseButtonRelease: executed 106 times by 6 tests: case QEvent::MouseButtonRelease: Executed by:
| 106 | ||||||||||||||||||||||||||||||
2389 | return filterMouseEvent(i, static_cast<QMouseEvent *>(e)); executed 1637 times by 7 tests: return filterMouseEvent(i, static_cast<QMouseEvent *>(e)); Executed by:
| 1637 | ||||||||||||||||||||||||||||||
2390 | case QEvent::UngrabMouse: executed 160 times by 5 tests: case QEvent::UngrabMouse: Executed by:
| 160 | ||||||||||||||||||||||||||||||
2391 | if (d->window && d->window->mouseGrabberItem() && d->window->mouseGrabberItem() != this) {
| 0-160 | ||||||||||||||||||||||||||||||
2392 | // The grab has been taken away from a child and given to some other item. | - | ||||||||||||||||||||||||||||||
2393 | mouseUngrabEvent(); | - | ||||||||||||||||||||||||||||||
2394 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||||||||
2395 | break; executed 160 times by 5 tests: break; Executed by:
| 160 | ||||||||||||||||||||||||||||||
2396 | default: executed 372 times by 3 tests: default: Executed by:
| 372 | ||||||||||||||||||||||||||||||
2397 | break; executed 372 times by 3 tests: break; Executed by:
| 372 | ||||||||||||||||||||||||||||||
2398 | } | - | ||||||||||||||||||||||||||||||
2399 | - | |||||||||||||||||||||||||||||||
2400 | return QQuickItem::childMouseEventFilter(i, e); executed 532 times by 6 tests: return QQuickItem::childMouseEventFilter(i, e); Executed by:
| 532 | ||||||||||||||||||||||||||||||
2401 | } | - | ||||||||||||||||||||||||||||||
2402 | - | |||||||||||||||||||||||||||||||
2403 | /*! | - | ||||||||||||||||||||||||||||||
2404 | \qmlproperty real QtQuick::Flickable::maximumFlickVelocity | - | ||||||||||||||||||||||||||||||
2405 | This property holds the maximum velocity that the user can flick the view in pixels/second. | - | ||||||||||||||||||||||||||||||
2406 | - | |||||||||||||||||||||||||||||||
2407 | The default value is platform dependent. | - | ||||||||||||||||||||||||||||||
2408 | */ | - | ||||||||||||||||||||||||||||||
2409 | qreal QQuickFlickable::maximumFlickVelocity() const | - | ||||||||||||||||||||||||||||||
2410 | { | - | ||||||||||||||||||||||||||||||
2411 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2412 | return d->maxVelocity; executed 8 times by 1 test: return d->maxVelocity; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2413 | } | - | ||||||||||||||||||||||||||||||
2414 | - | |||||||||||||||||||||||||||||||
2415 | void QQuickFlickable::setMaximumFlickVelocity(qreal v) | - | ||||||||||||||||||||||||||||||
2416 | { | - | ||||||||||||||||||||||||||||||
2417 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2418 | if (v == d->maxVelocity)
| 2-6 | ||||||||||||||||||||||||||||||
2419 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||||||||
2420 | d->maxVelocity = v; | - | ||||||||||||||||||||||||||||||
2421 | emit maximumFlickVelocityChanged(); | - | ||||||||||||||||||||||||||||||
2422 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
2423 | - | |||||||||||||||||||||||||||||||
2424 | /*! | - | ||||||||||||||||||||||||||||||
2425 | \qmlproperty real QtQuick::Flickable::flickDeceleration | - | ||||||||||||||||||||||||||||||
2426 | This property holds the rate at which a flick will decelerate. | - | ||||||||||||||||||||||||||||||
2427 | - | |||||||||||||||||||||||||||||||
2428 | The default value is platform dependent. | - | ||||||||||||||||||||||||||||||
2429 | */ | - | ||||||||||||||||||||||||||||||
2430 | qreal QQuickFlickable::flickDeceleration() const | - | ||||||||||||||||||||||||||||||
2431 | { | - | ||||||||||||||||||||||||||||||
2432 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2433 | return d->deceleration; executed 6 times by 2 tests: return d->deceleration; Executed by:
| 6 | ||||||||||||||||||||||||||||||
2434 | } | - | ||||||||||||||||||||||||||||||
2435 | - | |||||||||||||||||||||||||||||||
2436 | void QQuickFlickable::setFlickDeceleration(qreal deceleration) | - | ||||||||||||||||||||||||||||||
2437 | { | - | ||||||||||||||||||||||||||||||
2438 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2439 | if (deceleration == d->deceleration)
| 2-40 | ||||||||||||||||||||||||||||||
2440 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||||||||
2441 | d->deceleration = deceleration; | - | ||||||||||||||||||||||||||||||
2442 | emit flickDecelerationChanged(); | - | ||||||||||||||||||||||||||||||
2443 | } executed 40 times by 4 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||||||||
2444 | - | |||||||||||||||||||||||||||||||
2445 | bool QQuickFlickable::isFlicking() const | - | ||||||||||||||||||||||||||||||
2446 | { | - | ||||||||||||||||||||||||||||||
2447 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2448 | return d->hData.flicking || d->vData.flicking; executed 30528 times by 14 tests: return d->hData.flicking || d->vData.flicking; Executed by:
| 30528 | ||||||||||||||||||||||||||||||
2449 | } | - | ||||||||||||||||||||||||||||||
2450 | - | |||||||||||||||||||||||||||||||
2451 | /*! | - | ||||||||||||||||||||||||||||||
2452 | \qmlproperty bool QtQuick::Flickable::flicking | - | ||||||||||||||||||||||||||||||
2453 | \qmlproperty bool QtQuick::Flickable::flickingHorizontally | - | ||||||||||||||||||||||||||||||
2454 | \qmlproperty bool QtQuick::Flickable::flickingVertically | - | ||||||||||||||||||||||||||||||
2455 | - | |||||||||||||||||||||||||||||||
2456 | These properties describe whether the view is currently moving horizontally, | - | ||||||||||||||||||||||||||||||
2457 | vertically or in either direction, due to the user flicking the view. | - | ||||||||||||||||||||||||||||||
2458 | */ | - | ||||||||||||||||||||||||||||||
2459 | bool QQuickFlickable::isFlickingHorizontally() const | - | ||||||||||||||||||||||||||||||
2460 | { | - | ||||||||||||||||||||||||||||||
2461 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2462 | return d->hData.flicking; never executed: return d->hData.flicking; | 0 | ||||||||||||||||||||||||||||||
2463 | } | - | ||||||||||||||||||||||||||||||
2464 | - | |||||||||||||||||||||||||||||||
2465 | bool QQuickFlickable::isFlickingVertically() const | - | ||||||||||||||||||||||||||||||
2466 | { | - | ||||||||||||||||||||||||||||||
2467 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2468 | return d->vData.flicking; never executed: return d->vData.flicking; | 0 | ||||||||||||||||||||||||||||||
2469 | } | - | ||||||||||||||||||||||||||||||
2470 | - | |||||||||||||||||||||||||||||||
2471 | /*! | - | ||||||||||||||||||||||||||||||
2472 | \qmlproperty bool QtQuick::Flickable::dragging | - | ||||||||||||||||||||||||||||||
2473 | \qmlproperty bool QtQuick::Flickable::draggingHorizontally | - | ||||||||||||||||||||||||||||||
2474 | \qmlproperty bool QtQuick::Flickable::draggingVertically | - | ||||||||||||||||||||||||||||||
2475 | - | |||||||||||||||||||||||||||||||
2476 | These properties describe whether the view is currently moving horizontally, | - | ||||||||||||||||||||||||||||||
2477 | vertically or in either direction, due to the user dragging the view. | - | ||||||||||||||||||||||||||||||
2478 | */ | - | ||||||||||||||||||||||||||||||
2479 | bool QQuickFlickable::isDragging() const | - | ||||||||||||||||||||||||||||||
2480 | { | - | ||||||||||||||||||||||||||||||
2481 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2482 | return d->hData.dragging || d->vData.dragging; executed 554 times by 3 tests: return d->hData.dragging || d->vData.dragging; Executed by:
| 554 | ||||||||||||||||||||||||||||||
2483 | } | - | ||||||||||||||||||||||||||||||
2484 | - | |||||||||||||||||||||||||||||||
2485 | bool QQuickFlickable::isDraggingHorizontally() const | - | ||||||||||||||||||||||||||||||
2486 | { | - | ||||||||||||||||||||||||||||||
2487 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2488 | return d->hData.dragging; never executed: return d->hData.dragging; | 0 | ||||||||||||||||||||||||||||||
2489 | } | - | ||||||||||||||||||||||||||||||
2490 | - | |||||||||||||||||||||||||||||||
2491 | bool QQuickFlickable::isDraggingVertically() const | - | ||||||||||||||||||||||||||||||
2492 | { | - | ||||||||||||||||||||||||||||||
2493 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2494 | return d->vData.dragging; never executed: return d->vData.dragging; | 0 | ||||||||||||||||||||||||||||||
2495 | } | - | ||||||||||||||||||||||||||||||
2496 | - | |||||||||||||||||||||||||||||||
2497 | void QQuickFlickablePrivate::draggingStarting() | - | ||||||||||||||||||||||||||||||
2498 | { | - | ||||||||||||||||||||||||||||||
2499 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2500 | bool wasDragging = hData.dragging || vData.dragging;
| 1184-3356 | ||||||||||||||||||||||||||||||
2501 | if (hMoved && !hData.dragging) {
| 376-2980 | ||||||||||||||||||||||||||||||
2502 | hData.dragging = true; | - | ||||||||||||||||||||||||||||||
2503 | emit q->draggingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
2504 | } executed 376 times by 6 tests: end of block Executed by:
| 376 | ||||||||||||||||||||||||||||||
2505 | if (vMoved && !vData.dragging) {
| 392-2663 | ||||||||||||||||||||||||||||||
2506 | vData.dragging = true; | - | ||||||||||||||||||||||||||||||
2507 | emit q->draggingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
2508 | } executed 392 times by 5 tests: end of block Executed by:
| 392 | ||||||||||||||||||||||||||||||
2509 | if (!wasDragging && (hData.dragging || vData.dragging)) {
| 326-2499 | ||||||||||||||||||||||||||||||
2510 | emit q->draggingChanged(); | - | ||||||||||||||||||||||||||||||
2511 | emit q->dragStarted(); | - | ||||||||||||||||||||||||||||||
2512 | } executed 702 times by 7 tests: end of block Executed by:
| 702 | ||||||||||||||||||||||||||||||
2513 | } executed 4540 times by 7 tests: end of block Executed by:
| 4540 | ||||||||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||||||||
2515 | void QQuickFlickablePrivate::draggingEnding() | - | ||||||||||||||||||||||||||||||
2516 | { | - | ||||||||||||||||||||||||||||||
2517 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2518 | bool wasDragging = hData.dragging || vData.dragging;
| 156-482 | ||||||||||||||||||||||||||||||
2519 | if (hData.dragging) {
| 376-482 | ||||||||||||||||||||||||||||||
2520 | hData.dragging = false; | - | ||||||||||||||||||||||||||||||
2521 | emit q->draggingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
2522 | } executed 376 times by 6 tests: end of block Executed by:
| 376 | ||||||||||||||||||||||||||||||
2523 | if (vData.dragging) {
| 392-466 | ||||||||||||||||||||||||||||||
2524 | vData.dragging = false; | - | ||||||||||||||||||||||||||||||
2525 | emit q->draggingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
2526 | } executed 392 times by 5 tests: end of block Executed by:
| 392 | ||||||||||||||||||||||||||||||
2527 | if (wasDragging && !hData.dragging && !vData.dragging) {
| 0-702 | ||||||||||||||||||||||||||||||
2528 | emit q->draggingChanged(); | - | ||||||||||||||||||||||||||||||
2529 | emit q->dragEnded(); | - | ||||||||||||||||||||||||||||||
2530 | } executed 702 times by 7 tests: end of block Executed by:
| 702 | ||||||||||||||||||||||||||||||
2531 | hData.inRebound = false; | - | ||||||||||||||||||||||||||||||
2532 | vData.inRebound = false; | - | ||||||||||||||||||||||||||||||
2533 | } executed 858 times by 7 tests: end of block Executed by:
| 858 | ||||||||||||||||||||||||||||||
2534 | - | |||||||||||||||||||||||||||||||
2535 | bool QQuickFlickablePrivate::isViewMoving() const | - | ||||||||||||||||||||||||||||||
2536 | { | - | ||||||||||||||||||||||||||||||
2537 | if (timeline.isActive()
| 130-718 | ||||||||||||||||||||||||||||||
2538 | || (hData.transitionToBounds && hData.transitionToBounds->isActive())
| 0-130 | ||||||||||||||||||||||||||||||
2539 | || (vData.transitionToBounds && vData.transitionToBounds->isActive()) ) {
| 0-130 | ||||||||||||||||||||||||||||||
2540 | return true; executed 718 times by 7 tests: return true; Executed by:
| 718 | ||||||||||||||||||||||||||||||
2541 | } | - | ||||||||||||||||||||||||||||||
2542 | return false; executed 130 times by 4 tests: return false; Executed by:
| 130 | ||||||||||||||||||||||||||||||
2543 | } | - | ||||||||||||||||||||||||||||||
2544 | - | |||||||||||||||||||||||||||||||
2545 | /*! | - | ||||||||||||||||||||||||||||||
2546 | \qmlproperty int QtQuick::Flickable::pressDelay | - | ||||||||||||||||||||||||||||||
2547 | - | |||||||||||||||||||||||||||||||
2548 | This property holds the time to delay (ms) delivering a press to | - | ||||||||||||||||||||||||||||||
2549 | children of the Flickable. This can be useful where reacting | - | ||||||||||||||||||||||||||||||
2550 | to a press before a flicking action has undesirable effects. | - | ||||||||||||||||||||||||||||||
2551 | - | |||||||||||||||||||||||||||||||
2552 | If the flickable is dragged/flicked before the delay times out | - | ||||||||||||||||||||||||||||||
2553 | the press event will not be delivered. If the button is released | - | ||||||||||||||||||||||||||||||
2554 | within the timeout, both the press and release will be delivered. | - | ||||||||||||||||||||||||||||||
2555 | - | |||||||||||||||||||||||||||||||
2556 | Note that for nested Flickables with pressDelay set, the pressDelay of | - | ||||||||||||||||||||||||||||||
2557 | outer Flickables is overridden by the innermost Flickable. If the drag | - | ||||||||||||||||||||||||||||||
2558 | exceeds the platform drag threshold, the press event will be delivered | - | ||||||||||||||||||||||||||||||
2559 | regardless of this property. | - | ||||||||||||||||||||||||||||||
2560 | - | |||||||||||||||||||||||||||||||
2561 | \sa QStyleHints | - | ||||||||||||||||||||||||||||||
2562 | */ | - | ||||||||||||||||||||||||||||||
2563 | int QQuickFlickable::pressDelay() const | - | ||||||||||||||||||||||||||||||
2564 | { | - | ||||||||||||||||||||||||||||||
2565 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2566 | return d->pressDelay; executed 20 times by 1 test: return d->pressDelay; Executed by:
| 20 | ||||||||||||||||||||||||||||||
2567 | } | - | ||||||||||||||||||||||||||||||
2568 | - | |||||||||||||||||||||||||||||||
2569 | void QQuickFlickable::setPressDelay(int delay) | - | ||||||||||||||||||||||||||||||
2570 | { | - | ||||||||||||||||||||||||||||||
2571 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2572 | if (d->pressDelay == delay)
| 22-24 | ||||||||||||||||||||||||||||||
2573 | return; executed 24 times by 1 test: return; Executed by:
| 24 | ||||||||||||||||||||||||||||||
2574 | d->pressDelay = delay; | - | ||||||||||||||||||||||||||||||
2575 | emit pressDelayChanged(); | - | ||||||||||||||||||||||||||||||
2576 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||||||||
2577 | - | |||||||||||||||||||||||||||||||
2578 | /*! | - | ||||||||||||||||||||||||||||||
2579 | \qmlproperty bool QtQuick::Flickable::moving | - | ||||||||||||||||||||||||||||||
2580 | \qmlproperty bool QtQuick::Flickable::movingHorizontally | - | ||||||||||||||||||||||||||||||
2581 | \qmlproperty bool QtQuick::Flickable::movingVertically | - | ||||||||||||||||||||||||||||||
2582 | - | |||||||||||||||||||||||||||||||
2583 | These properties describe whether the view is currently moving horizontally, | - | ||||||||||||||||||||||||||||||
2584 | vertically or in either direction, due to the user either dragging or | - | ||||||||||||||||||||||||||||||
2585 | flicking the view. | - | ||||||||||||||||||||||||||||||
2586 | */ | - | ||||||||||||||||||||||||||||||
2587 | - | |||||||||||||||||||||||||||||||
2588 | bool QQuickFlickable::isMoving() const | - | ||||||||||||||||||||||||||||||
2589 | { | - | ||||||||||||||||||||||||||||||
2590 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2591 | return d->hData.moving || d->vData.moving; executed 43349 times by 16 tests: return d->hData.moving || d->vData.moving; Executed by:
| 43349 | ||||||||||||||||||||||||||||||
2592 | } | - | ||||||||||||||||||||||||||||||
2593 | - | |||||||||||||||||||||||||||||||
2594 | bool QQuickFlickable::isMovingHorizontally() const | - | ||||||||||||||||||||||||||||||
2595 | { | - | ||||||||||||||||||||||||||||||
2596 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2597 | return d->hData.moving; executed 2 times by 1 test: return d->hData.moving; Executed by:
| 2 | ||||||||||||||||||||||||||||||
2598 | } | - | ||||||||||||||||||||||||||||||
2599 | - | |||||||||||||||||||||||||||||||
2600 | bool QQuickFlickable::isMovingVertically() const | - | ||||||||||||||||||||||||||||||
2601 | { | - | ||||||||||||||||||||||||||||||
2602 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2603 | return d->vData.moving; executed 2 times by 1 test: return d->vData.moving; Executed by:
| 2 | ||||||||||||||||||||||||||||||
2604 | } | - | ||||||||||||||||||||||||||||||
2605 | - | |||||||||||||||||||||||||||||||
2606 | void QQuickFlickable::velocityTimelineCompleted() | - | ||||||||||||||||||||||||||||||
2607 | { | - | ||||||||||||||||||||||||||||||
2608 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2609 | if ( (d->hData.transitionToBounds && d->hData.transitionToBounds->isActive())
| 0-1275 | ||||||||||||||||||||||||||||||
2610 | || (d->vData.transitionToBounds && d->vData.transitionToBounds->isActive()) ) {
| 0-1275 | ||||||||||||||||||||||||||||||
2611 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
2612 | } | - | ||||||||||||||||||||||||||||||
2613 | // With subclasses such as GridView, velocityTimeline.completed is emitted repeatedly: | - | ||||||||||||||||||||||||||||||
2614 | // for example setting currentIndex results in a visual "flick" which the user | - | ||||||||||||||||||||||||||||||
2615 | // didn't initiate directly. We don't want to end movement repeatedly, and in | - | ||||||||||||||||||||||||||||||
2616 | // that case movementEnding will happen after the sequence of movements ends. | - | ||||||||||||||||||||||||||||||
2617 | if (d->vData.flicking)
| 0-1275 | ||||||||||||||||||||||||||||||
2618 | movementEnding(); never executed: movementEnding(); | 0 | ||||||||||||||||||||||||||||||
2619 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2620 | } executed 1275 times by 3 tests: end of block Executed by:
| 1275 | ||||||||||||||||||||||||||||||
2621 | - | |||||||||||||||||||||||||||||||
2622 | void QQuickFlickable::timelineCompleted() | - | ||||||||||||||||||||||||||||||
2623 | { | - | ||||||||||||||||||||||||||||||
2624 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2625 | if ( (d->hData.transitionToBounds && d->hData.transitionToBounds->isActive())
| 0-4304 | ||||||||||||||||||||||||||||||
2626 | || (d->vData.transitionToBounds && d->vData.transitionToBounds->isActive()) ) {
| 0-4304 | ||||||||||||||||||||||||||||||
2627 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
2628 | } | - | ||||||||||||||||||||||||||||||
2629 | movementEnding(); | - | ||||||||||||||||||||||||||||||
2630 | d->updateBeginningEnd(); | - | ||||||||||||||||||||||||||||||
2631 | } executed 4304 times by 9 tests: end of block Executed by:
| 4304 | ||||||||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||||||||
2633 | void QQuickFlickable::movementStarting() | - | ||||||||||||||||||||||||||||||
2634 | { | - | ||||||||||||||||||||||||||||||
2635 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2636 | bool wasMoving = d->hData.moving || d->vData.moving;
| 0-691 | ||||||||||||||||||||||||||||||
2637 | if (d->hMoved && !d->hData.moving) {
| 0-384 | ||||||||||||||||||||||||||||||
2638 | d->hData.moving = true; | - | ||||||||||||||||||||||||||||||
2639 | emit movingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
2640 | } executed 384 times by 6 tests: end of block Executed by:
| 384 | ||||||||||||||||||||||||||||||
2641 | if (d->vMoved && !d->vData.moving) {
| 0-381 | ||||||||||||||||||||||||||||||
2642 | d->vData.moving = true; | - | ||||||||||||||||||||||||||||||
2643 | emit movingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
2644 | } executed 381 times by 5 tests: end of block Executed by:
| 381 | ||||||||||||||||||||||||||||||
2645 | - | |||||||||||||||||||||||||||||||
2646 | if (!wasMoving && (d->hData.moving || d->vData.moving)) {
| 0-691 | ||||||||||||||||||||||||||||||
2647 | emit movingChanged(); | - | ||||||||||||||||||||||||||||||
2648 | emit movementStarted(); | - | ||||||||||||||||||||||||||||||
2649 | } executed 691 times by 7 tests: end of block Executed by:
| 691 | ||||||||||||||||||||||||||||||
2650 | } executed 691 times by 7 tests: end of block Executed by:
| 691 | ||||||||||||||||||||||||||||||
2651 | - | |||||||||||||||||||||||||||||||
2652 | void QQuickFlickable::movementEnding() | - | ||||||||||||||||||||||||||||||
2653 | { | - | ||||||||||||||||||||||||||||||
2654 | movementEnding(true, true); | - | ||||||||||||||||||||||||||||||
2655 | } executed 4436 times by 9 tests: end of block Executed by:
| 4436 | ||||||||||||||||||||||||||||||
2656 | - | |||||||||||||||||||||||||||||||
2657 | void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding) | - | ||||||||||||||||||||||||||||||
2658 | { | - | ||||||||||||||||||||||||||||||
2659 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2660 | - | |||||||||||||||||||||||||||||||
2661 | // emit flicking signals | - | ||||||||||||||||||||||||||||||
2662 | bool wasFlicking = d->hData.flicking || d->vData.flicking;
| 260-4150 | ||||||||||||||||||||||||||||||
2663 | if (hMovementEnding && d->hData.flicking) {
| 24-4460 | ||||||||||||||||||||||||||||||
2664 | d->hData.flicking = false; | - | ||||||||||||||||||||||||||||||
2665 | emit flickingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
2666 | } executed 334 times by 6 tests: end of block Executed by:
| 334 | ||||||||||||||||||||||||||||||
2667 | if (vMovementEnding && d->vData.flicking) {
| 24-4460 | ||||||||||||||||||||||||||||||
2668 | d->vData.flicking = false; | - | ||||||||||||||||||||||||||||||
2669 | emit flickingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
2670 | } executed 294 times by 5 tests: end of block Executed by:
| 294 | ||||||||||||||||||||||||||||||
2671 | if (wasFlicking && (!d->hData.flicking || !d->vData.flicking)) {
| 0-3890 | ||||||||||||||||||||||||||||||
2672 | emit flickingChanged(); | - | ||||||||||||||||||||||||||||||
2673 | emit flickEnded(); | - | ||||||||||||||||||||||||||||||
2674 | } executed 594 times by 7 tests: end of block Executed by:
| 594 | ||||||||||||||||||||||||||||||
2675 | - | |||||||||||||||||||||||||||||||
2676 | // emit moving signals | - | ||||||||||||||||||||||||||||||
2677 | bool wasMoving = isMoving(); | - | ||||||||||||||||||||||||||||||
2678 | if (hMovementEnding && d->hData.moving
| 24-4460 | ||||||||||||||||||||||||||||||
2679 | && (!d->pressed && !d->stealMouse)) {
| 0-372 | ||||||||||||||||||||||||||||||
2680 | d->hData.moving = false; | - | ||||||||||||||||||||||||||||||
2681 | d->hMoved = false; | - | ||||||||||||||||||||||||||||||
2682 | emit movingHorizontallyChanged(); | - | ||||||||||||||||||||||||||||||
2683 | } executed 372 times by 6 tests: end of block Executed by:
| 372 | ||||||||||||||||||||||||||||||
2684 | if (vMovementEnding && d->vData.moving
| 24-4460 | ||||||||||||||||||||||||||||||
2685 | && (!d->pressed && !d->stealMouse)) {
| 0-359 | ||||||||||||||||||||||||||||||
2686 | d->vData.moving = false; | - | ||||||||||||||||||||||||||||||
2687 | d->vMoved = false; | - | ||||||||||||||||||||||||||||||
2688 | emit movingVerticallyChanged(); | - | ||||||||||||||||||||||||||||||
2689 | } executed 359 times by 5 tests: end of block Executed by:
| 359 | ||||||||||||||||||||||||||||||
2690 | if (wasMoving && !isMoving()) {
| 33-3786 | ||||||||||||||||||||||||||||||
2691 | emit movingChanged(); | - | ||||||||||||||||||||||||||||||
2692 | emit movementEnded(); | - | ||||||||||||||||||||||||||||||
2693 | } executed 665 times by 7 tests: end of block Executed by:
| 665 | ||||||||||||||||||||||||||||||
2694 | - | |||||||||||||||||||||||||||||||
2695 | if (hMovementEnding) {
| 24-4460 | ||||||||||||||||||||||||||||||
2696 | d->hData.fixingUp = false; | - | ||||||||||||||||||||||||||||||
2697 | d->hData.smoothVelocity.setValue(0); | - | ||||||||||||||||||||||||||||||
2698 | d->hData.previousDragDelta = 0.0; | - | ||||||||||||||||||||||||||||||
2699 | } executed 4460 times by 9 tests: end of block Executed by:
| 4460 | ||||||||||||||||||||||||||||||
2700 | if (vMovementEnding) {
| 24-4460 | ||||||||||||||||||||||||||||||
2701 | d->vData.fixingUp = false; | - | ||||||||||||||||||||||||||||||
2702 | d->vData.smoothVelocity.setValue(0); | - | ||||||||||||||||||||||||||||||
2703 | d->vData.previousDragDelta = 0.0; | - | ||||||||||||||||||||||||||||||
2704 | } executed 4460 times by 9 tests: end of block Executed by:
| 4460 | ||||||||||||||||||||||||||||||
2705 | } executed 4484 times by 9 tests: end of block Executed by:
| 4484 | ||||||||||||||||||||||||||||||
2706 | - | |||||||||||||||||||||||||||||||
2707 | void QQuickFlickablePrivate::updateVelocity() | - | ||||||||||||||||||||||||||||||
2708 | { | - | ||||||||||||||||||||||||||||||
2709 | Q_Q(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2710 | emit q->horizontalVelocityChanged(); | - | ||||||||||||||||||||||||||||||
2711 | emit q->verticalVelocityChanged(); | - | ||||||||||||||||||||||||||||||
2712 | } executed 20773 times by 8 tests: end of block Executed by:
| 20773 | ||||||||||||||||||||||||||||||
2713 | - | |||||||||||||||||||||||||||||||
2714 | /*! | - | ||||||||||||||||||||||||||||||
2715 | \qmlproperty real QtQuick::Flickable::horizontalOvershoot | - | ||||||||||||||||||||||||||||||
2716 | \since 5.9 | - | ||||||||||||||||||||||||||||||
2717 | - | |||||||||||||||||||||||||||||||
2718 | This property holds the horizontal overshoot, that is, the horizontal distance by | - | ||||||||||||||||||||||||||||||
2719 | which the contents has been dragged or flicked past the bounds of the flickable. | - | ||||||||||||||||||||||||||||||
2720 | The value is negative when the content is dragged or flicked beyond the beginning, | - | ||||||||||||||||||||||||||||||
2721 | and positive when beyond the end; \c 0.0 otherwise. | - | ||||||||||||||||||||||||||||||
2722 | - | |||||||||||||||||||||||||||||||
2723 | Whether the values are reported for dragging and/or flicking is determined by | - | ||||||||||||||||||||||||||||||
2724 | \l boundsBehavior. The overshoot distance is reported even when \l boundsMovement | - | ||||||||||||||||||||||||||||||
2725 | is \c Flickable.StopAtBounds. | - | ||||||||||||||||||||||||||||||
2726 | - | |||||||||||||||||||||||||||||||
2727 | \sa verticalOvershoot, boundsBehavior, boundsMovement | - | ||||||||||||||||||||||||||||||
2728 | */ | - | ||||||||||||||||||||||||||||||
2729 | qreal QQuickFlickable::horizontalOvershoot() const | - | ||||||||||||||||||||||||||||||
2730 | { | - | ||||||||||||||||||||||||||||||
2731 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2732 | return d->hData.overshoot; executed 1112 times by 1 test: return d->hData.overshoot; Executed by:
| 1112 | ||||||||||||||||||||||||||||||
2733 | } | - | ||||||||||||||||||||||||||||||
2734 | - | |||||||||||||||||||||||||||||||
2735 | /*! | - | ||||||||||||||||||||||||||||||
2736 | \qmlproperty real QtQuick::Flickable::verticalOvershoot | - | ||||||||||||||||||||||||||||||
2737 | \since 5.9 | - | ||||||||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||||||||
2739 | This property holds the vertical overshoot, that is, the vertical distance by | - | ||||||||||||||||||||||||||||||
2740 | which the contents has been dragged or flicked past the bounds of the flickable. | - | ||||||||||||||||||||||||||||||
2741 | The value is negative when the content is dragged or flicked beyond the beginning, | - | ||||||||||||||||||||||||||||||
2742 | and positive when beyond the end; \c 0.0 otherwise. | - | ||||||||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||||||||
2744 | Whether the values are reported for dragging and/or flicking is determined by | - | ||||||||||||||||||||||||||||||
2745 | \l boundsBehavior. The overshoot distance is reported even when \l boundsMovement | - | ||||||||||||||||||||||||||||||
2746 | is \c Flickable.StopAtBounds. | - | ||||||||||||||||||||||||||||||
2747 | - | |||||||||||||||||||||||||||||||
2748 | \sa horizontalOvershoot, boundsBehavior, boundsMovement | - | ||||||||||||||||||||||||||||||
2749 | */ | - | ||||||||||||||||||||||||||||||
2750 | qreal QQuickFlickable::verticalOvershoot() const | - | ||||||||||||||||||||||||||||||
2751 | { | - | ||||||||||||||||||||||||||||||
2752 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2753 | return d->vData.overshoot; executed 1098 times by 2 tests: return d->vData.overshoot; Executed by:
| 1098 | ||||||||||||||||||||||||||||||
2754 | } | - | ||||||||||||||||||||||||||||||
2755 | - | |||||||||||||||||||||||||||||||
2756 | /*! | - | ||||||||||||||||||||||||||||||
2757 | \qmlproperty enumeration QtQuick::Flickable::boundsMovement | - | ||||||||||||||||||||||||||||||
2758 | \since 5.10 | - | ||||||||||||||||||||||||||||||
2759 | - | |||||||||||||||||||||||||||||||
2760 | This property holds whether the flickable will give a feeling that the edges of the | - | ||||||||||||||||||||||||||||||
2761 | view are soft, rather than a hard physical boundary. | - | ||||||||||||||||||||||||||||||
2762 | - | |||||||||||||||||||||||||||||||
2763 | The \c boundsMovement can be one of: | - | ||||||||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||||||||
2765 | \list | - | ||||||||||||||||||||||||||||||
2766 | \li Flickable.StopAtBounds - this allows implementing custom edge effects where the | - | ||||||||||||||||||||||||||||||
2767 | contents do not follow drags or flicks beyond the bounds of the flickable. The values | - | ||||||||||||||||||||||||||||||
2768 | of \l horizontalOvershoot and \l verticalOvershoot can be utilized to implement custom | - | ||||||||||||||||||||||||||||||
2769 | edge effects. | - | ||||||||||||||||||||||||||||||
2770 | \li Flickable.FollowBoundsBehavior (default) - whether the contents follow drags or | - | ||||||||||||||||||||||||||||||
2771 | flicks beyond the bounds of the flickable is determined by \l boundsBehavior. | - | ||||||||||||||||||||||||||||||
2772 | \endlist | - | ||||||||||||||||||||||||||||||
2773 | - | |||||||||||||||||||||||||||||||
2774 | The following example keeps the contents within bounds and instead applies a flip | - | ||||||||||||||||||||||||||||||
2775 | effect when flicked over horizontal bounds: | - | ||||||||||||||||||||||||||||||
2776 | \code | - | ||||||||||||||||||||||||||||||
2777 | Flickable { | - | ||||||||||||||||||||||||||||||
2778 | id: flickable | - | ||||||||||||||||||||||||||||||
2779 | boundsMovement: Flickable.StopAtBounds | - | ||||||||||||||||||||||||||||||
2780 | boundsBehavior: Flickable.DragAndOvershootBounds | - | ||||||||||||||||||||||||||||||
2781 | transform: Rotation { | - | ||||||||||||||||||||||||||||||
2782 | axis { x: 0; y: 1; z: 0 } | - | ||||||||||||||||||||||||||||||
2783 | origin.x: flickable.width / 2 | - | ||||||||||||||||||||||||||||||
2784 | origin.y: flickable.height / 2 | - | ||||||||||||||||||||||||||||||
2785 | angle: Math.min(30, Math.max(-30, flickable.horizontalOvershoot)) | - | ||||||||||||||||||||||||||||||
2786 | } | - | ||||||||||||||||||||||||||||||
2787 | } | - | ||||||||||||||||||||||||||||||
2788 | \endcode | - | ||||||||||||||||||||||||||||||
2789 | - | |||||||||||||||||||||||||||||||
2790 | The following example keeps the contents within bounds and instead applies an opacity | - | ||||||||||||||||||||||||||||||
2791 | effect when dragged over vertical bounds: | - | ||||||||||||||||||||||||||||||
2792 | \code | - | ||||||||||||||||||||||||||||||
2793 | Flickable { | - | ||||||||||||||||||||||||||||||
2794 | boundsMovement: Flickable.StopAtBounds | - | ||||||||||||||||||||||||||||||
2795 | boundsBehavior: Flickable.DragOverBounds | - | ||||||||||||||||||||||||||||||
2796 | opacity: Math.max(0.5, 1.0 - Math.abs(verticalOvershoot) / height) | - | ||||||||||||||||||||||||||||||
2797 | } | - | ||||||||||||||||||||||||||||||
2798 | \endcode | - | ||||||||||||||||||||||||||||||
2799 | - | |||||||||||||||||||||||||||||||
2800 | \sa boundsBehavior, verticalOvershoot, horizontalOvershoot | - | ||||||||||||||||||||||||||||||
2801 | */ | - | ||||||||||||||||||||||||||||||
2802 | QQuickFlickable::BoundsMovement QQuickFlickable::boundsMovement() const | - | ||||||||||||||||||||||||||||||
2803 | { | - | ||||||||||||||||||||||||||||||
2804 | Q_D(const QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2805 | return d->boundsMovement; never executed: return d->boundsMovement; | 0 | ||||||||||||||||||||||||||||||
2806 | } | - | ||||||||||||||||||||||||||||||
2807 | - | |||||||||||||||||||||||||||||||
2808 | void QQuickFlickable::setBoundsMovement(BoundsMovement movement) | - | ||||||||||||||||||||||||||||||
2809 | { | - | ||||||||||||||||||||||||||||||
2810 | Q_D(QQuickFlickable); | - | ||||||||||||||||||||||||||||||
2811 | if (d->boundsMovement == movement)
| 6-8 | ||||||||||||||||||||||||||||||
2812 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||||||||
2813 | - | |||||||||||||||||||||||||||||||
2814 | d->boundsMovement = movement; | - | ||||||||||||||||||||||||||||||
2815 | emit boundsMovementChanged(); | - | ||||||||||||||||||||||||||||||
2816 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
2817 | - | |||||||||||||||||||||||||||||||
2818 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
2819 | - | |||||||||||||||||||||||||||||||
2820 | #include "moc_qquickflickable_p.cpp" | - | ||||||||||||||||||||||||||||||
Source code | Switch to Preprocessed file |