animation/qabstractanimation.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42/*! -
43 \class QAbstractAnimation -
44 \inmodule QtCore -
45 \ingroup animation -
46 \brief The QAbstractAnimation class is the base of all animations. -
47 \since 4.6 -
48 -
49 The class defines the functions for the functionality shared by -
50 all animations. By inheriting this class, you can create custom -
51 animations that plug into the rest of the animation framework. -
52 -
53 The progress of an animation is given by its current time -
54 (currentLoopTime()), which is measured in milliseconds from the start -
55 of the animation (0) to its end (duration()). The value is updated -
56 automatically while the animation is running. It can also be set -
57 directly with setCurrentTime(). -
58 -
59 At any point an animation is in one of three states: -
60 \l{QAbstractAnimation::}{Running}, -
61 \l{QAbstractAnimation::}{Stopped}, or -
62 \l{QAbstractAnimation::}{Paused}--as defined by the -
63 \l{QAbstractAnimation::}{State} enum. The current state can be -
64 changed by calling start(), stop(), pause(), or resume(). An -
65 animation will always reset its \l{currentTime()}{current time} -
66 when it is started. If paused, it will continue with the same -
67 current time when resumed. When an animation is stopped, it cannot -
68 be resumed, but will keep its current time (until started again). -
69 QAbstractAnimation will emit stateChanged() whenever its state -
70 changes. -
71 -
72 An animation can loop any number of times by setting the loopCount -
73 property. When an animation's current time reaches its duration(), -
74 it will reset the current time and keep running. A loop count of 1 -
75 (the default value) means that the animation will run one time. -
76 Note that a duration of -1 means that the animation will run until -
77 stopped; the current time will increase indefinitely. When the -
78 current time equals duration() and the animation is in its -
79 final loop, the \l{QAbstractAnimation::}{Stopped} state is -
80 entered, and the finished() signal is emitted. -
81 -
82 QAbstractAnimation provides pure virtual functions used by -
83 subclasses to track the progress of the animation: duration() and -
84 updateCurrentTime(). The duration() function lets you report a -
85 duration for the animation (as discussed above). The animation -
86 framework calls updateCurrentTime() when current time has changed. -
87 By reimplementing this function, you can track the animation -
88 progress. Note that neither the interval between calls nor the -
89 number of calls to this function are defined; though, it will -
90 normally be 60 updates per second. -
91 -
92 By reimplementing updateState(), you can track the animation's -
93 state changes, which is particularly useful for animations that -
94 are not driven by time. -
95 -
96 \sa QVariantAnimation, QPropertyAnimation, QAnimationGroup, {The Animation Framework} -
97*/ -
98 -
99/*! -
100 \enum QAbstractAnimation::DeletionPolicy -
101 -
102 \value KeepWhenStopped The animation will not be deleted when stopped. -
103 \value DeleteWhenStopped The animation will be automatically deleted when -
104 stopped. -
105*/ -
106 -
107/*! -
108 \fn QAbstractAnimation::finished() -
109 -
110 QAbstractAnimation emits this signal after the animation has stopped and -
111 has reached the end. -
112 -
113 This signal is emitted after stateChanged(). -
114 -
115 \sa stateChanged() -
116*/ -
117 -
118/*! -
119 \fn QAbstractAnimation::stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -
120 -
121 QAbstractAnimation emits this signal whenever the state of the animation has -
122 changed from \a oldState to \a newState. This signal is emitted after the virtual -
123 updateState() function is called. -
124 -
125 \sa updateState() -
126*/ -
127 -
128/*! -
129 \fn QAbstractAnimation::currentLoopChanged(int currentLoop) -
130 -
131 QAbstractAnimation emits this signal whenever the current loop -
132 changes. \a currentLoop is the current loop. -
133 -
134 \sa currentLoop(), loopCount() -
135*/ -
136 -
137/*! -
138 \fn QAbstractAnimation::directionChanged(QAbstractAnimation::Direction newDirection); -
139 -
140 QAbstractAnimation emits this signal whenever the direction has been -
141 changed. \a newDirection is the new direction. -
142 -
143 \sa direction -
144*/ -
145 -
146#include "qabstractanimation.h" -
147#include "qanimationgroup.h" -
148 -
149#include <QtCore/qdebug.h> -
150 -
151#include "qabstractanimation_p.h" -
152 -
153#include <QtCore/qmath.h> -
154#include <QtCore/qthreadstorage.h> -
155#include <QtCore/qcoreevent.h> -
156#include <QtCore/qpointer.h> -
157 -
158#ifndef QT_NO_ANIMATION -
159 -
160#define DEFAULT_TIMER_INTERVAL 16 -
161#define PAUSE_TIMER_COARSE_THRESHOLD 2000 -
162 -
163QT_BEGIN_NAMESPACE -
164 -
165/*! -
166 \class QAbstractAnimationTimer -
167 \inmodule QtCore -
168 \brief QAbstractAnimationTimer is the base class for animation timers. -
169 \internal -
170 -
171 Subclass QAbstractAnimationTimer to provide an animation timer that is run by -
172 QUnifiedTimer and can in turn be used to run any number of animations. -
173 -
174 Currently two subclasses have been implemented: QAnimationTimer to drive the Qt C++ -
175 animation framework (QAbstractAnimation and subclasses) and QDeclarativeAnimationTimer -
176 to drive the Qt QML animation framework. -
177*/ -
178 -
179/*! -
180 \fn virtual void QAbstractAnimationTimer::updateAnimationsTime(qint64 delta) = 0; -
181 \internal -
182 -
183 This pure virtual function is called when the animation timer needs to update -
184 the current time for all animations it is running. -
185*/ -
186 -
187/*! -
188 \fn virtual void QAbstractAnimationTimer::restartAnimationTimer() = 0; -
189 \internal -
190 -
191 This pure virtual function restarts the animation timer as needed. -
192 -
193 Classes implementing this function may choose to pause or resume the timer -
194 as appropriate, or conditionally restart it. -
195*/ -
196 -
197/*! -
198 \fn virtual int QAbstractAnimationTimer::runningAnimationCount() = 0; -
199 \internal -
200 -
201 This pure virtual function returns the number of animations the timer is running. -
202 This information is useful for profiling. -
203*/ -
204 -
205/*! -
206 \class QUnifiedTimer -
207 \inmodule QtCore -
208 \brief QUnifiedTimer provides a unified timing mechanism for animations in Qt C++ and QML. -
209 \internal -
210 -
211 QUnifiedTimer allows animations run by Qt to share a single timer. This keeps animations -
212 visually in sync, as well as being more efficient than running numerous timers. -
213 -
214 QUnifiedTimer drives animations indirectly, via QAbstractAnimationTimer. -
215*/ -
216 -
217#ifndef QT_NO_THREAD -
218Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:5540
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:5522
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-5540
219#endif -
220 -
221QUnifiedTimer::QUnifiedTimer() : -
222 QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), -
223 currentAnimationIdx(0), insideTick(false), insideRestart(false), consistentTiming(false), slowMode(false), -
224 startTimersPending(false), stopTimerPending(false), -
225 slowdownFactor(5.0f), profilerCallback(0) -
226{ -
227 time.invalidate();
executed (the execution status of this line is deduced): time.invalidate();
-
228 driver = &defaultDriver;
executed (the execution status of this line is deduced): driver = &defaultDriver;
-
229}
executed: }
Execution Count:9
9
230 -
231 -
232QUnifiedTimer *QUnifiedTimer::instance(bool create) -
233{ -
234 QUnifiedTimer *inst;
executed (the execution status of this line is deduced): QUnifiedTimer *inst;
-
235#ifndef QT_NO_THREAD -
236 if (create && !unifiedTimer()->hasLocalData()) {
evaluated: create
TRUEFALSE
yes
Evaluation Count:1433
yes
Evaluation Count:625
evaluated: !unifiedTimer()->hasLocalData()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1424
9-1433
237 inst = new QUnifiedTimer;
executed (the execution status of this line is deduced): inst = new QUnifiedTimer;
-
238 unifiedTimer()->setLocalData(inst);
executed (the execution status of this line is deduced): unifiedTimer()->setLocalData(inst);
-
239 } else {
executed: }
Execution Count:9
9
240 inst = unifiedTimer() ? unifiedTimer()->localData() : 0;
partially evaluated: unifiedTimer()
TRUEFALSE
yes
Evaluation Count:2049
no
Evaluation Count:0
0-2049
241 }
executed: }
Execution Count:2049
2049
242#else -
243 static QUnifiedTimer unifiedTimer; -
244 inst = &unifiedTimer; -
245#endif -
246 return inst;
executed: return inst;
Execution Count:2058
2058
247} -
248 -
249QUnifiedTimer *QUnifiedTimer::instance() -
250{ -
251 return instance(true);
executed: return instance(true);
Execution Count:1353
1353
252} -
253 -
254void QUnifiedTimer::maybeUpdateAnimationsToCurrentTime() -
255{ -
256 if (time.elapsed() - lastTick > 50)
evaluated: time.elapsed() - lastTick > 50
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
257 updateAnimationTimers(driver->elapsed());
executed: updateAnimationTimers(driver->elapsed());
Execution Count:1
1
258}
executed: }
Execution Count:2
2
259 -
260void QUnifiedTimer::updateAnimationTimers(qint64 currentTick) -
261{ -
262 //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations -
263 if(insideTick)
partially evaluated: insideTick
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1323
0-1323
264 return;
never executed: return;
0
265 -
266 qint64 totalElapsed = currentTick >= 0 ? currentTick : time.elapsed();
evaluated: currentTick >= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1322
1-1322
267 -
268 // ignore consistentTiming in case the pause timer is active -
269 qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
evaluated: consistentTiming
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1226
evaluated: !pauseTimer.isActive()
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:18
18-1226
270 timingInterval : totalElapsed - lastTick;
executed (the execution status of this line is deduced): timingInterval : totalElapsed - lastTick;
-
271 if (slowMode) {
partially evaluated: slowMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1323
0-1323
272 if (slowdownFactor > 0)
never evaluated: slowdownFactor > 0
0
273 delta = qRound(delta / slowdownFactor);
never executed: delta = qRound(delta / slowdownFactor);
0
274 else -
275 delta = 0;
never executed: delta = 0;
0
276 } -
277 -
278 lastTick = totalElapsed;
executed (the execution status of this line is deduced): lastTick = totalElapsed;
-
279 -
280 //we make sure we only call update time if the time has actually changed -
281 //it might happen in some cases that the time doesn't change because events are delayed -
282 //when the CPU load is high -
283 if (delta) {
evaluated: delta
TRUEFALSE
yes
Evaluation Count:1322
yes
Evaluation Count:1
1-1322
284 insideTick = true;
executed (the execution status of this line is deduced): insideTick = true;
-
285 if (profilerCallback)
partially evaluated: profilerCallback
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1322
0-1322
286 profilerCallback(delta);
never executed: profilerCallback(delta);
0
287 for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) {
evaluated: currentAnimationIdx < animationTimers.count()
TRUEFALSE
yes
Evaluation Count:1316
yes
Evaluation Count:1322
1316-1322
288 QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
executed (the execution status of this line is deduced): QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
-
289 animation->updateAnimationsTime(delta);
executed (the execution status of this line is deduced): animation->updateAnimationsTime(delta);
-
290 }
executed: }
Execution Count:1316
1316
291 insideTick = false;
executed (the execution status of this line is deduced): insideTick = false;
-
292 currentAnimationIdx = 0;
executed (the execution status of this line is deduced): currentAnimationIdx = 0;
-
293 }
executed: }
Execution Count:1322
1322
294}
executed: }
Execution Count:1323
1323
295 -
296int QUnifiedTimer::runningAnimationCount() -
297{ -
298 int count = 0;
never executed (the execution status of this line is deduced): int count = 0;
-
299 for (int i = 0; i < animationTimers.count(); ++i)
never evaluated: i < animationTimers.count()
0
300 count += animationTimers.at(i)->runningAnimationCount();
never executed: count += animationTimers.at(i)->runningAnimationCount();
0
301 return count;
never executed: return count;
0
302} -
303 -
304void QUnifiedTimer::registerProfilerCallback(void (*cb)(qint64)) -
305{ -
306 profilerCallback = cb;
never executed (the execution status of this line is deduced): profilerCallback = cb;
-
307}
never executed: }
0
308 -
309void QUnifiedTimer::localRestart() -
310{ -
311 if (insideRestart)
evaluated: insideRestart
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:1412
21-1412
312 return;
executed: return;
Execution Count:21
21
313 -
314 if (!pausedAnimationTimers.isEmpty() && (animationTimers.count() + animationTimersToStart.count() == pausedAnimationTimers.count())) {
evaluated: !pausedAnimationTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:1380
partially evaluated: (animationTimers.count() + animationTimersToStart.count() == pausedAnimationTimers.count())
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-1380
315 driver->stop();
executed (the execution status of this line is deduced): driver->stop();
-
316 int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
executed (the execution status of this line is deduced): int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
-
317 // use a precise timer if the pause will be short -
318 Qt::TimerType timerType = closestTimeToFinish < PAUSE_TIMER_COARSE_THRESHOLD ? Qt::PreciseTimer : Qt::CoarseTimer;
partially evaluated: closestTimeToFinish < 2000
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
319 pauseTimer.start(closestTimeToFinish, timerType, this);
executed (the execution status of this line is deduced): pauseTimer.start(closestTimeToFinish, timerType, this);
-
320 } else if (!driver->isRunning()) {
executed: }
Execution Count:32
evaluated: !driver->isRunning()
TRUEFALSE
yes
Evaluation Count:82
yes
Evaluation Count:1298
32-1298
321 if (pauseTimer.isActive())
evaluated: pauseTimer.isActive()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:70
12-70
322 pauseTimer.stop();
executed: pauseTimer.stop();
Execution Count:12
12
323 driver->setStartTime(time.isValid() ? time.elapsed() : 0);
executed (the execution status of this line is deduced): driver->setStartTime(time.isValid() ? time.elapsed() : 0);
-
324 driver->start();
executed (the execution status of this line is deduced): driver->start();
-
325 }
executed: }
Execution Count:82
82
326 -
327} -
328 -
329void QUnifiedTimer::restart() -
330{ -
331 insideRestart = true;
executed (the execution status of this line is deduced): insideRestart = true;
-
332 for (int i = 0; i < animationTimers.count(); ++i)
evaluated: i < animationTimers.count()
TRUEFALSE
yes
Evaluation Count:1313
yes
Evaluation Count:1319
1313-1319
333 animationTimers.at(i)->restartAnimationTimer();
executed: animationTimers.at(i)->restartAnimationTimer();
Execution Count:1313
1313
334 insideRestart = false;
executed (the execution status of this line is deduced): insideRestart = false;
-
335 -
336 localRestart();
executed (the execution status of this line is deduced): localRestart();
-
337}
executed: }
Execution Count:1319
1319
338 -
339void QUnifiedTimer::setTimingInterval(int interval) -
340{ -
341 timingInterval = interval;
never executed (the execution status of this line is deduced): timingInterval = interval;
-
342 -
343 if (driver->isRunning() && !pauseTimer.isActive()) {
never evaluated: driver->isRunning()
never evaluated: !pauseTimer.isActive()
0
344 //we changed the timing interval -
345 driver->stop();
never executed (the execution status of this line is deduced): driver->stop();
-
346 driver->setStartTime(time.isValid() ? time.elapsed() : 0);
never executed (the execution status of this line is deduced): driver->setStartTime(time.isValid() ? time.elapsed() : 0);
-
347 driver->start();
never executed (the execution status of this line is deduced): driver->start();
-
348 }
never executed: }
0
349}
never executed: }
0
350 -
351void QUnifiedTimer::startTimers() -
352{ -
353 startTimersPending = false;
executed (the execution status of this line is deduced): startTimersPending = false;
-
354 if (!animationTimers.isEmpty())
partially evaluated: !animationTimers.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:80
0-80
355 updateAnimationTimers(-1);
never executed: updateAnimationTimers(-1);
0
356 -
357 //we transfer the waiting animations into the "really running" state -
358 animationTimers += animationTimersToStart;
executed (the execution status of this line is deduced): animationTimers += animationTimersToStart;
-
359 animationTimersToStart.clear();
executed (the execution status of this line is deduced): animationTimersToStart.clear();
-
360 if (!animationTimers.isEmpty()) {
partially evaluated: !animationTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:80
no
Evaluation Count:0
0-80
361 localRestart();
executed (the execution status of this line is deduced): localRestart();
-
362 if (!time.isValid()) {
partially evaluated: !time.isValid()
TRUEFALSE
yes
Evaluation Count:80
no
Evaluation Count:0
0-80
363 lastTick = 0;
executed (the execution status of this line is deduced): lastTick = 0;
-
364 time.start();
executed (the execution status of this line is deduced): time.start();
-
365 }
executed: }
Execution Count:80
80
366 }
executed: }
Execution Count:80
80
367}
executed: }
Execution Count:80
80
368 -
369void QUnifiedTimer::stopTimer() -
370{ -
371 stopTimerPending = false;
executed (the execution status of this line is deduced): stopTimerPending = false;
-
372 if (animationTimers.isEmpty()) {
partially evaluated: animationTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
0-77
373 driver->stop();
executed (the execution status of this line is deduced): driver->stop();
-
374 pauseTimer.stop();
executed (the execution status of this line is deduced): pauseTimer.stop();
-
375 // invalidate the start reference time -
376 time.invalidate();
executed (the execution status of this line is deduced): time.invalidate();
-
377 }
executed: }
Execution Count:77
77
378}
executed: }
Execution Count:77
77
379 -
380void QUnifiedTimer::timerEvent(QTimerEvent *event) -
381{ -
382 //in the case of consistent timing we make sure the order in which events come is always the same -
383 //for that purpose we do as if the startstoptimer would always fire before the animation timer -
384 if (consistentTiming) {
evaluated: consistentTiming
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:3
3-16
385 if (stopTimerPending)
partially evaluated: stopTimerPending
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
386 stopTimer();
never executed: stopTimer();
0
387 if (startTimersPending)
partially evaluated: startTimersPending
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
388 startTimers();
never executed: startTimers();
0
389 }
executed: }
Execution Count:16
16
390 -
391 if (event->timerId() == pauseTimer.timerId()) {
partially evaluated: event->timerId() == pauseTimer.timerId()
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
392 // update current time on all timers -
393 updateAnimationTimers(-1);
executed (the execution status of this line is deduced): updateAnimationTimers(-1);
-
394 restart();
executed (the execution status of this line is deduced): restart();
-
395 }
executed: }
Execution Count:19
19
396}
executed: }
Execution Count:19
19
397 -
398void QUnifiedTimer::startAnimationTimer(QAbstractAnimationTimer *timer) -
399{ -
400 if (timer->isRegistered)
partially evaluated: timer->isRegistered
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:80
0-80
401 return;
never executed: return;
0
402 timer->isRegistered = true;
executed (the execution status of this line is deduced): timer->isRegistered = true;
-
403 -
404 QUnifiedTimer *inst = instance(true); //we create the instance if needed
executed (the execution status of this line is deduced): QUnifiedTimer *inst = instance(true);
-
405 inst->animationTimersToStart << timer;
executed (the execution status of this line is deduced): inst->animationTimersToStart << timer;
-
406 if (!inst->startTimersPending) {
partially evaluated: !inst->startTimersPending
TRUEFALSE
yes
Evaluation Count:80
no
Evaluation Count:0
0-80
407 inst->startTimersPending = true;
executed (the execution status of this line is deduced): inst->startTimersPending = true;
-
408 QMetaObject::invokeMethod(inst, "startTimers", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(inst, "startTimers", Qt::QueuedConnection);
-
409 }
executed: }
Execution Count:80
80
410}
executed: }
Execution Count:80
80
411 -
412void QUnifiedTimer::stopAnimationTimer(QAbstractAnimationTimer *timer) -
413{ -
414 QUnifiedTimer *inst = QUnifiedTimer::instance(false);
executed (the execution status of this line is deduced): QUnifiedTimer *inst = QUnifiedTimer::instance(false);
-
415 if (inst) {
partially evaluated: inst
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
0-77
416 //at this point the unified timer should have been created -
417 //but it might also have been already destroyed in case the application is shutting down -
418 -
419 if (!timer->isRegistered)
partially evaluated: !timer->isRegistered
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:77
0-77
420 return;
never executed: return;
0
421 timer->isRegistered = false;
executed (the execution status of this line is deduced): timer->isRegistered = false;
-
422 -
423 int idx = inst->animationTimers.indexOf(timer);
executed (the execution status of this line is deduced): int idx = inst->animationTimers.indexOf(timer);
-
424 if (idx != -1) {
partially evaluated: idx != -1
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
0-77
425 inst->animationTimers.removeAt(idx);
executed (the execution status of this line is deduced): inst->animationTimers.removeAt(idx);
-
426 // this is needed if we unregister an animation while its running -
427 if (idx <= inst->currentAnimationIdx)
evaluated: idx <= inst->currentAnimationIdx
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:1
1-76
428 --inst->currentAnimationIdx;
executed: --inst->currentAnimationIdx;
Execution Count:76
76
429 -
430 if (inst->animationTimers.isEmpty() && !inst->stopTimerPending) {
partially evaluated: inst->animationTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
partially evaluated: !inst->stopTimerPending
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
0-77
431 inst->stopTimerPending = true;
executed (the execution status of this line is deduced): inst->stopTimerPending = true;
-
432 QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
-
433 }
executed: }
Execution Count:77
77
434 } else {
executed: }
Execution Count:77
77
435 inst->animationTimersToStart.removeOne(timer);
never executed (the execution status of this line is deduced): inst->animationTimersToStart.removeOne(timer);
-
436 }
never executed: }
0
437 } -
438}
executed: }
Execution Count:77
77
439 -
440void QUnifiedTimer::pauseAnimationTimer(QAbstractAnimationTimer *timer, int duration) -
441{ -
442 QUnifiedTimer *inst = QUnifiedTimer::instance();
executed (the execution status of this line is deduced): QUnifiedTimer *inst = QUnifiedTimer::instance();
-
443 if (!timer->isRegistered)
evaluated: !timer->isRegistered
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:12
10-12
444 inst->startAnimationTimer(timer);
executed: inst->startAnimationTimer(timer);
Execution Count:10
10
445 -
446 bool timerWasPaused = timer->isPaused;
executed (the execution status of this line is deduced): bool timerWasPaused = timer->isPaused;
-
447 timer->isPaused = true;
executed (the execution status of this line is deduced): timer->isPaused = true;
-
448 timer->pauseDuration = duration;
executed (the execution status of this line is deduced): timer->pauseDuration = duration;
-
449 if (!timerWasPaused)
evaluated: !timerWasPaused
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:10
10-12
450 inst->pausedAnimationTimers << timer;
executed: inst->pausedAnimationTimers << timer;
Execution Count:12
12
451 inst->localRestart();
executed (the execution status of this line is deduced): inst->localRestart();
-
452}
executed: }
Execution Count:22
22
453 -
454void QUnifiedTimer::resumeAnimationTimer(QAbstractAnimationTimer *timer) -
455{ -
456 if (!timer->isPaused)
evaluated: !timer->isPaused
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:12
12-76
457 return;
executed: return;
Execution Count:76
76
458 -
459 timer->isPaused = false;
executed (the execution status of this line is deduced): timer->isPaused = false;
-
460 QUnifiedTimer *inst = QUnifiedTimer::instance();
executed (the execution status of this line is deduced): QUnifiedTimer *inst = QUnifiedTimer::instance();
-
461 inst->pausedAnimationTimers.removeOne(timer);
executed (the execution status of this line is deduced): inst->pausedAnimationTimers.removeOne(timer);
-
462 inst->localRestart();
executed (the execution status of this line is deduced): inst->localRestart();
-
463}
executed: }
Execution Count:12
12
464 -
465int QUnifiedTimer::closestPausedAnimationTimerTimeToFinish() -
466{ -
467 int closestTimeToFinish = INT_MAX;
executed (the execution status of this line is deduced): int closestTimeToFinish = 2147483647;
-
468 for (int i = 0; i < pausedAnimationTimers.size(); ++i) {
evaluated: i < pausedAnimationTimers.size()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:32
32
469 int timeToFinish = pausedAnimationTimers.at(i)->pauseDuration;
executed (the execution status of this line is deduced): int timeToFinish = pausedAnimationTimers.at(i)->pauseDuration;
-
470 if (timeToFinish < closestTimeToFinish)
partially evaluated: timeToFinish < closestTimeToFinish
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
471 closestTimeToFinish = timeToFinish;
executed: closestTimeToFinish = timeToFinish;
Execution Count:32
32
472 }
executed: }
Execution Count:32
32
473 return closestTimeToFinish;
executed: return closestTimeToFinish;
Execution Count:32
32
474} -
475 -
476void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d) -
477{ -
478 if (driver != &defaultDriver) {
never evaluated: driver != &defaultDriver
0
479 qWarning("QUnifiedTimer: animation driver already installed...");
never executed (the execution status of this line is deduced): QMessageLogger("animation/qabstractanimation.cpp", 479, __PRETTY_FUNCTION__).warning("QUnifiedTimer: animation driver already installed...");
-
480 return;
never executed: return;
0
481 } -
482 -
483 if (driver->isRunning()) {
never evaluated: driver->isRunning()
0
484 driver->stop();
never executed (the execution status of this line is deduced): driver->stop();
-
485 d->setStartTime(time.isValid() ? time.elapsed() : 0);
never executed (the execution status of this line is deduced): d->setStartTime(time.isValid() ? time.elapsed() : 0);
-
486 d->start();
never executed (the execution status of this line is deduced): d->start();
-
487 }
never executed: }
0
488 -
489 driver = d;
never executed (the execution status of this line is deduced): driver = d;
-
490 -
491}
never executed: }
0
492 -
493void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d) -
494{ -
495 if (driver != d) {
never evaluated: driver != d
0
496 qWarning("QUnifiedTimer: trying to uninstall a driver that is not installed...");
never executed (the execution status of this line is deduced): QMessageLogger("animation/qabstractanimation.cpp", 496, __PRETTY_FUNCTION__).warning("QUnifiedTimer: trying to uninstall a driver that is not installed...");
-
497 return;
never executed: return;
0
498 } -
499 -
500 driver = &defaultDriver;
never executed (the execution status of this line is deduced): driver = &defaultDriver;
-
501 -
502 if (d->isRunning()) {
never evaluated: d->isRunning()
0
503 d->stop();
never executed (the execution status of this line is deduced): d->stop();
-
504 driver->setStartTime(time.isValid() ? time.elapsed() : 0);
never executed (the execution status of this line is deduced): driver->setStartTime(time.isValid() ? time.elapsed() : 0);
-
505 driver->start();
never executed (the execution status of this line is deduced): driver->start();
-
506 }
never executed: }
0
507}
never executed: }
0
508 -
509/*! -
510 Returns true if \a d is the currently installed animation driver -
511 and is not the default animation driver (which can never be uninstalled). -
512*/ -
513bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d) -
514{ -
515 return d == driver && driver != &defaultDriver;
never executed: return d == driver && driver != &defaultDriver;
0
516} -
517 -
518#ifndef QT_NO_THREAD -
519Q_GLOBAL_STATIC(QThreadStorage<QAnimationTimer *>, animationTimer)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:5700
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:5682
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-5700
520#endif -
521 -
522QAnimationTimer::QAnimationTimer() : -
523 QAbstractAnimationTimer(), lastTick(0), -
524 currentAnimationIdx(0), insideTick(false), -
525 startAnimationPending(false), stopTimerPending(false), -
526 runningLeafAnimations(0) -
527{ -
528}
executed: }
Execution Count:18
18
529 -
530QAnimationTimer *QAnimationTimer::instance(bool create) -
531{ -
532 QAnimationTimer *inst;
executed (the execution status of this line is deduced): QAnimationTimer *inst;
-
533#ifndef QT_NO_THREAD -
534 if (create && !animationTimer()->hasLocalData()) {
evaluated: create
TRUEFALSE
yes
Evaluation Count:924
yes
Evaluation Count:1473
evaluated: !animationTimer()->hasLocalData()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:906
18-1473
535 inst = new QAnimationTimer;
executed (the execution status of this line is deduced): inst = new QAnimationTimer;
-
536 animationTimer()->setLocalData(inst);
executed (the execution status of this line is deduced): animationTimer()->setLocalData(inst);
-
537 } else {
executed: }
Execution Count:18
18
538 inst = animationTimer() ? animationTimer()->localData() : 0;
partially evaluated: animationTimer()
TRUEFALSE
yes
Evaluation Count:2379
no
Evaluation Count:0
0-2379
539 }
executed: }
Execution Count:2379
2379
540#else -
541 static QAnimationTimer animationTimer; -
542 inst = &animationTimer; -
543#endif -
544 return inst;
executed: return inst;
Execution Count:2397
2397
545} -
546 -
547QAnimationTimer *QAnimationTimer::instance() -
548{ -
549 return instance(true);
never executed: return instance(true);
0
550} -
551 -
552void QAnimationTimer::ensureTimerUpdate() -
553{ -
554 QAnimationTimer *inst = QAnimationTimer::instance(false);
executed (the execution status of this line is deduced): QAnimationTimer *inst = QAnimationTimer::instance(false);
-
555 QUnifiedTimer *instU = QUnifiedTimer::instance(false);
executed (the execution status of this line is deduced): QUnifiedTimer *instU = QUnifiedTimer::instance(false);
-
556 if (instU && inst && inst->isPaused)
evaluated: instU
TRUEFALSE
yes
Evaluation Count:231
yes
Evaluation Count:308
partially evaluated: inst
TRUEFALSE
yes
Evaluation Count:231
no
Evaluation Count:0
evaluated: inst->isPaused
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:228
0-308
557 instU->updateAnimationTimers(-1);
executed: instU->updateAnimationTimers(-1);
Execution Count:3
3
558}
executed: }
Execution Count:539
539
559 -
560void QAnimationTimer::updateAnimationsTime(qint64 delta) -
561{ -
562 //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations -
563 if (insideTick)
partially evaluated: insideTick
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1316
0-1316
564 return;
never executed: return;
0
565 -
566 lastTick += delta;
executed (the execution status of this line is deduced): lastTick += delta;
-
567 -
568 //we make sure we only call update time if the time has actually changed -
569 //it might happen in some cases that the time doesn't change because events are delayed -
570 //when the CPU load is high -
571 if (delta) {
partially evaluated: delta
TRUEFALSE
yes
Evaluation Count:1316
no
Evaluation Count:0
0-1316
572 insideTick = true;
executed (the execution status of this line is deduced): insideTick = true;
-
573 for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
evaluated: currentAnimationIdx < animations.count()
TRUEFALSE
yes
Evaluation Count:1501
yes
Evaluation Count:1316
1316-1501
574 QAbstractAnimation *animation = animations.at(currentAnimationIdx);
executed (the execution status of this line is deduced): QAbstractAnimation *animation = animations.at(currentAnimationIdx);
-
575 int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
executed (the execution status of this line is deduced): int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
-
576 + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
evaluated: animation->direction() == QAbstractAnimation::Forward
TRUEFALSE
yes
Evaluation Count:1446
yes
Evaluation Count:55
55-1446
577 animation->setCurrentTime(elapsed);
executed (the execution status of this line is deduced): animation->setCurrentTime(elapsed);
-
578 }
executed: }
Execution Count:1501
1501
579 insideTick = false;
executed (the execution status of this line is deduced): insideTick = false;
-
580 currentAnimationIdx = 0;
executed (the execution status of this line is deduced): currentAnimationIdx = 0;
-
581 }
executed: }
Execution Count:1316
1316
582}
executed: }
Execution Count:1316
1316
583 -
584void QAnimationTimer::updateAnimationTimer() -
585{ -
586 QAnimationTimer *inst = QAnimationTimer::instance(false);
executed (the execution status of this line is deduced): QAnimationTimer *inst = QAnimationTimer::instance(false);
-
587 if (inst)
partially evaluated: inst
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
588 inst->restartAnimationTimer();
executed: inst->restartAnimationTimer();
Execution Count:10
10
589}
executed: }
Execution Count:10
10
590 -
591void QAnimationTimer::restartAnimationTimer() -
592{ -
593 if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
evaluated: runningLeafAnimations == 0
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:1328
evaluated: !runningPauseAnimations.isEmpty()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:56
22-1328
594 QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish());
executed: QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish());
Execution Count:22
22
595 else if (isPaused)
evaluated: isPaused
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1373
11-1373
596 QUnifiedTimer::resumeAnimationTimer(this);
executed: QUnifiedTimer::resumeAnimationTimer(this);
Execution Count:11
11
597 else if (!isRegistered)
evaluated: !isRegistered
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:1303
70-1303
598 QUnifiedTimer::startAnimationTimer(this);
executed: QUnifiedTimer::startAnimationTimer(this);
Execution Count:70
70
599} -
600 -
601void QAnimationTimer::startAnimations() -
602{ -
603 startAnimationPending = false;
executed (the execution status of this line is deduced): startAnimationPending = false;
-
604 //force timer to update, which prevents large deltas for our newly added animations -
605 if (!animations.isEmpty())
evaluated: !animations.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:206
2-206
606 QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
executed: QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
Execution Count:2
2
607 -
608 //we transfer the waiting animations into the "really running" state -
609 animations += animationsToStart;
executed (the execution status of this line is deduced): animations += animationsToStart;
-
610 animationsToStart.clear();
executed (the execution status of this line is deduced): animationsToStart.clear();
-
611 if (!animations.isEmpty())
evaluated: !animations.isEmpty()
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:125
83-125
612 restartAnimationTimer();
executed: restartAnimationTimer();
Execution Count:83
83
613}
executed: }
Execution Count:208
208
614 -
615void QAnimationTimer::stopTimer() -
616{ -
617 stopTimerPending = false;
executed (the execution status of this line is deduced): stopTimerPending = false;
-
618 if (animations.isEmpty()) {
evaluated: animations.isEmpty()
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:1
1-77
619 QUnifiedTimer::resumeAnimationTimer(this);
executed (the execution status of this line is deduced): QUnifiedTimer::resumeAnimationTimer(this);
-
620 QUnifiedTimer::stopAnimationTimer(this);
executed (the execution status of this line is deduced): QUnifiedTimer::stopAnimationTimer(this);
-
621 // invalidate the start reference time -
622 lastTick = 0;
executed (the execution status of this line is deduced): lastTick = 0;
-
623 }
executed: }
Execution Count:77
77
624}
executed: }
Execution Count:78
78
625 -
626void QAnimationTimer::registerAnimation(QAbstractAnimation *animation, bool isTopLevel) -
627{ -
628 QAnimationTimer *inst = instance(true); //we create the instance if needed
executed (the execution status of this line is deduced): QAnimationTimer *inst = instance(true);
-
629 inst->registerRunningAnimation(animation);
executed (the execution status of this line is deduced): inst->registerRunningAnimation(animation);
-
630 if (isTopLevel) {
evaluated: isTopLevel
TRUEFALSE
yes
Evaluation Count:507
yes
Evaluation Count:417
417-507
631 Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
executed (the execution status of this line is deduced): qt_noop();
-
632 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
executed (the execution status of this line is deduced): QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
-
633 inst->animationsToStart << animation;
executed (the execution status of this line is deduced): inst->animationsToStart << animation;
-
634 if (!inst->startAnimationPending) {
evaluated: !inst->startAnimationPending
TRUEFALSE
yes
Evaluation Count:211
yes
Evaluation Count:296
211-296
635 inst->startAnimationPending = true;
executed (the execution status of this line is deduced): inst->startAnimationPending = true;
-
636 QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection);
-
637 }
executed: }
Execution Count:211
211
638 }
executed: }
Execution Count:507
507
639}
executed: }
Execution Count:924
924
640 -
641void QAnimationTimer::unregisterAnimation(QAbstractAnimation *animation) -
642{ -
643 QAnimationTimer *inst = QAnimationTimer::instance(false);
executed (the execution status of this line is deduced): QAnimationTimer *inst = QAnimationTimer::instance(false);
-
644 if (inst) {
partially evaluated: inst
TRUEFALSE
yes
Evaluation Count:924
no
Evaluation Count:0
0-924
645 //at this point the unified timer should have been created -
646 //but it might also have been already destroyed in case the application is shutting down -
647 -
648 inst->unregisterRunningAnimation(animation);
executed (the execution status of this line is deduced): inst->unregisterRunningAnimation(animation);
-
649 -
650 if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
evaluated: !QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer
TRUEFALSE
yes
Evaluation Count:417
yes
Evaluation Count:507
417-507
651 return;
executed: return;
Execution Count:417
417
652 -
653 int idx = inst->animations.indexOf(animation);
executed (the execution status of this line is deduced): int idx = inst->animations.indexOf(animation);
-
654 if (idx != -1) {
evaluated: idx != -1
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:410
97-410
655 inst->animations.removeAt(idx);
executed (the execution status of this line is deduced): inst->animations.removeAt(idx);
-
656 // this is needed if we unregister an animation while its running -
657 if (idx <= inst->currentAnimationIdx)
evaluated: idx <= inst->currentAnimationIdx
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:9
9-88
658 --inst->currentAnimationIdx;
executed: --inst->currentAnimationIdx;
Execution Count:88
88
659 -
660 if (inst->animations.isEmpty() && !inst->stopTimerPending) {
evaluated: inst->animations.isEmpty()
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:16
partially evaluated: !inst->stopTimerPending
TRUEFALSE
yes
Evaluation Count:81
no
Evaluation Count:0
0-81
661 inst->stopTimerPending = true;
executed (the execution status of this line is deduced): inst->stopTimerPending = true;
-
662 QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
-
663 }
executed: }
Execution Count:81
81
664 } else {
executed: }
Execution Count:97
97
665 inst->animationsToStart.removeOne(animation);
executed (the execution status of this line is deduced): inst->animationsToStart.removeOne(animation);
-
666 }
executed: }
Execution Count:410
410
667 } -
668 QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false;
executed (the execution status of this line is deduced): QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false;
-
669}
executed: }
Execution Count:507
507
670 -
671void QAnimationTimer::registerRunningAnimation(QAbstractAnimation *animation) -
672{ -
673 if (QAbstractAnimationPrivate::get(animation)->isGroup)
evaluated: QAbstractAnimationPrivate::get(animation)->isGroup
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:812
112-812
674 return;
executed: return;
Execution Count:112
112
675 -
676 if (QAbstractAnimationPrivate::get(animation)->isPause) {
evaluated: QAbstractAnimationPrivate::get(animation)->isPause
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:785
27-785
677 runningPauseAnimations << animation;
executed (the execution status of this line is deduced): runningPauseAnimations << animation;
-
678 } else
executed: }
Execution Count:27
27
679 runningLeafAnimations++;
executed: runningLeafAnimations++;
Execution Count:785
785
680} -
681 -
682void QAnimationTimer::unregisterRunningAnimation(QAbstractAnimation *animation) -
683{ -
684 if (QAbstractAnimationPrivate::get(animation)->isGroup)
evaluated: QAbstractAnimationPrivate::get(animation)->isGroup
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:812
112-812
685 return;
executed: return;
Execution Count:112
112
686 -
687 if (QAbstractAnimationPrivate::get(animation)->isPause)
evaluated: QAbstractAnimationPrivate::get(animation)->isPause
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:785
27-785
688 runningPauseAnimations.removeOne(animation);
executed: runningPauseAnimations.removeOne(animation);
Execution Count:27
27
689 else -
690 runningLeafAnimations--;
executed: runningLeafAnimations--;
Execution Count:785
785
691 Q_ASSERT(runningLeafAnimations >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
692}
executed: }
Execution Count:812
812
693 -
694int QAnimationTimer::closestPauseAnimationTimeToFinish() -
695{ -
696 int closestTimeToFinish = INT_MAX;
executed (the execution status of this line is deduced): int closestTimeToFinish = 2147483647;
-
697 for (int i = 0; i < runningPauseAnimations.size(); ++i) {
evaluated: i < runningPauseAnimations.size()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:22
22-39
698 QAbstractAnimation *animation = runningPauseAnimations.at(i);
executed (the execution status of this line is deduced): QAbstractAnimation *animation = runningPauseAnimations.at(i);
-
699 int timeToFinish;
executed (the execution status of this line is deduced): int timeToFinish;
-
700 -
701 if (animation->direction() == QAbstractAnimation::Forward)
evaluated: animation->direction() == QAbstractAnimation::Forward
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:1
1-38
702 timeToFinish = animation->duration() - animation->currentLoopTime();
executed: timeToFinish = animation->duration() - animation->currentLoopTime();
Execution Count:38
38
703 else -
704 timeToFinish = animation->currentLoopTime();
executed: timeToFinish = animation->currentLoopTime();
Execution Count:1
1
705 -
706 if (timeToFinish < closestTimeToFinish)
evaluated: timeToFinish < closestTimeToFinish
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:13
13-26
707 closestTimeToFinish = timeToFinish;
executed: closestTimeToFinish = timeToFinish;
Execution Count:26
26
708 }
executed: }
Execution Count:39
39
709 return closestTimeToFinish;
executed: return closestTimeToFinish;
Execution Count:22
22
710} -
711 -
712/*! -
713 \class QAnimationDriver -
714 \inmodule QtCore -
715 -
716 \brief The QAnimationDriver class is used to exchange the mechanism that drives animations. -
717 -
718 The default animation system is driven by a timer that fires at regular intervals. -
719 In some scenarios, it is better to drive the animation based on other synchronization -
720 mechanisms, such as the vertical refresh rate of the screen. -
721 -
722 \internal -
723 */ -
724 -
725QAnimationDriver::QAnimationDriver(QObject *parent) -
726 : QObject(*(new QAnimationDriverPrivate), parent) -
727{ -
728}
executed: }
Execution Count:9
9
729 -
730QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent) -
731 : QObject(dd, parent) -
732{ -
733}
never executed: }
0
734 -
735QAnimationDriver::~QAnimationDriver() -
736{ -
737 QUnifiedTimer *timer = QUnifiedTimer::instance(false);
executed (the execution status of this line is deduced): QUnifiedTimer *timer = QUnifiedTimer::instance(false);
-
738 if (timer && timer->canUninstallAnimationDriver(this))
partially evaluated: timer
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
never evaluated: timer->canUninstallAnimationDriver(this)
0-9
739 uninstall();
never executed: uninstall();
0
740}
executed: }
Execution Count:9
9
741 -
742 -
743/*! -
744 Sets the time at which an animation driver should start at. -
745 -
746 This is to take into account that pauses can occur in running -
747 animations which will stop the driver, but the time still -
748 increases. -
749 */ -
750void QAnimationDriver::setStartTime(qint64 startTime) -
751{ -
752 Q_D(QAnimationDriver);
executed (the execution status of this line is deduced): QAnimationDriverPrivate * const d = d_func();
-
753 d->startTime = startTime;
executed (the execution status of this line is deduced): d->startTime = startTime;
-
754}
executed: }
Execution Count:82
82
755 -
756/*! -
757 Returns the start time of the animation. -
758 */ -
759qint64 QAnimationDriver::startTime() const -
760{ -
761 Q_D(const QAnimationDriver);
never executed (the execution status of this line is deduced): const QAnimationDriverPrivate * const d = d_func();
-
762 return d->startTime;
never executed: return d->startTime;
0
763} -
764 -
765 -
766/*! -
767 Advances the animation based to the specified \a timeStep. This function should -
768 be continuously called by the driver subclasses while the animation is running. -
769 -
770 If \a timeStep is positive, it will be used as the current time in the -
771 calculations; otherwise, the current clock time will be used. -
772 */ -
773 -
774void QAnimationDriver::advanceAnimation(qint64 timeStep) -
775{ -
776 QUnifiedTimer *instance = QUnifiedTimer::instance();
executed (the execution status of this line is deduced): QUnifiedTimer *instance = QUnifiedTimer::instance();
-
777 -
778 // update current time on all top level animations -
779 instance->updateAnimationTimers(timeStep);
executed (the execution status of this line is deduced): instance->updateAnimationTimers(timeStep);
-
780 instance->restart();
executed (the execution status of this line is deduced): instance->restart();
-
781}
executed: }
Execution Count:1300
1300
782 -
783 -
784 -
785/*! -
786 Advances the animation. This function should be continously called -
787 by the driver while the animation is running. -
788 */ -
789 -
790void QAnimationDriver::advance() -
791{ -
792 advanceAnimation(-1);
executed (the execution status of this line is deduced): advanceAnimation(-1);
-
793}
executed: }
Execution Count:1300
1300
794 -
795 -
796 -
797/*! -
798 Installs this animation driver. The animation driver is thread local and -
799 will only apply for the thread its installed in. -
800 */ -
801 -
802void QAnimationDriver::install() -
803{ -
804 QUnifiedTimer *timer = QUnifiedTimer::instance(true);
never executed (the execution status of this line is deduced): QUnifiedTimer *timer = QUnifiedTimer::instance(true);
-
805 timer->installAnimationDriver(this);
never executed (the execution status of this line is deduced): timer->installAnimationDriver(this);
-
806}
never executed: }
0
807 -
808 -
809 -
810/*! -
811 Uninstalls this animation driver. -
812 */ -
813 -
814void QAnimationDriver::uninstall() -
815{ -
816 QUnifiedTimer *timer = QUnifiedTimer::instance(true);
never executed (the execution status of this line is deduced): QUnifiedTimer *timer = QUnifiedTimer::instance(true);
-
817 timer->uninstallAnimationDriver(this);
never executed (the execution status of this line is deduced): timer->uninstallAnimationDriver(this);
-
818}
never executed: }
0
819 -
820bool QAnimationDriver::isRunning() const -
821{ -
822 return d_func()->running;
executed: return d_func()->running;
Execution Count:1380
1380
823} -
824 -
825 -
826void QAnimationDriver::start() -
827{ -
828 Q_D(QAnimationDriver);
executed (the execution status of this line is deduced): QAnimationDriverPrivate * const d = d_func();
-
829 if (!d->running) {
partially evaluated: !d->running
TRUEFALSE
yes
Evaluation Count:82
no
Evaluation Count:0
0-82
830 emit started();
executed (the execution status of this line is deduced): started();
-
831 d->running = true;
executed (the execution status of this line is deduced): d->running = true;
-
832 }
executed: }
Execution Count:82
82
833}
executed: }
Execution Count:82
82
834 -
835 -
836void QAnimationDriver::stop() -
837{ -
838 Q_D(QAnimationDriver);
executed (the execution status of this line is deduced): QAnimationDriverPrivate * const d = d_func();
-
839 if (d->running) {
evaluated: d->running
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:30
30-79
840 emit stopped();
executed (the execution status of this line is deduced): stopped();
-
841 d->running = false;
executed (the execution status of this line is deduced): d->running = false;
-
842 }
executed: }
Execution Count:79
79
843}
executed: }
Execution Count:109
109
844 -
845 -
846/*! -
847 \fn qint64 QAnimationDriver::elapsed() const -
848 -
849 Returns the number of milliseconds since the animations was started. -
850 */ -
851 -
852qint64 QAnimationDriver::elapsed() const -
853{ -
854 // The default implementation picks up the elapsed time from the -
855 // unified timer and can ignore the time offset. -
856 return QUnifiedTimer::instance()->time.elapsed();
executed: return QUnifiedTimer::instance()->time.elapsed();
Execution Count:1
1
857} -
858 -
859/*! -
860 \fn QAnimationDriver::started() -
861 -
862 This signal is emitted by the animation framework to notify the driver -
863 that continuous animation has started. -
864 -
865 \internal -
866 */ -
867 -
868/*! -
869 \fn QAnimationDriver::stopped() -
870 -
871 This signal is emitted by the animation framework to notify the driver -
872 that continuous animation has stopped. -
873 -
874 \internal -
875 */ -
876 -
877/*! -
878 The default animation driver just spins the timer... -
879 */ -
880QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer) -
881 : QAnimationDriver(0), m_unified_timer(timer) -
882{ -
883 connect(this, SIGNAL(started()), this, SLOT(startTimer()));
executed (the execution status of this line is deduced): connect(this, "2""started()", this, "1""startTimer()");
-
884 connect(this, SIGNAL(stopped()), this, SLOT(stopTimer()));
executed (the execution status of this line is deduced): connect(this, "2""stopped()", this, "1""stopTimer()");
-
885}
executed: }
Execution Count:9
9
886 -
887void QDefaultAnimationDriver::timerEvent(QTimerEvent *e) -
888{ -
889 Q_ASSERT(e->timerId() == m_timer.timerId());
executed (the execution status of this line is deduced): qt_noop();
-
890 Q_UNUSED(e); // if the assertions are disabled
executed (the execution status of this line is deduced): (void)e;;
-
891 advance();
executed (the execution status of this line is deduced): advance();
-
892}
executed: }
Execution Count:1300
1300
893 -
894void QDefaultAnimationDriver::startTimer() -
895{ -
896 // always use a precise timer to drive animations -
897 m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer, this);
executed (the execution status of this line is deduced): m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer, this);
-
898}
executed: }
Execution Count:82
82
899 -
900void QDefaultAnimationDriver::stopTimer() -
901{ -
902 m_timer.stop();
executed (the execution status of this line is deduced): m_timer.stop();
-
903}
executed: }
Execution Count:79
79
904 -
905 -
906 -
907void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) -
908{ -
909 Q_Q(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimation * const q = q_func();
-
910 if (state == newState)
evaluated: state == newState
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1811
1-1811
911 return;
executed: return;
Execution Count:1
1
912 -
913 if (loopCount == 0)
evaluated: loopCount == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1810
1-1810
914 return;
executed: return;
Execution Count:1
1
915 -
916 QAbstractAnimation::State oldState = state;
executed (the execution status of this line is deduced): QAbstractAnimation::State oldState = state;
-
917 int oldCurrentTime = currentTime;
executed (the execution status of this line is deduced): int oldCurrentTime = currentTime;
-
918 int oldCurrentLoop = currentLoop;
executed (the execution status of this line is deduced): int oldCurrentLoop = currentLoop;
-
919 QAbstractAnimation::Direction oldDirection = direction;
executed (the execution status of this line is deduced): QAbstractAnimation::Direction oldDirection = direction;
-
920 -
921 // check if we should Rewind -
922 if ((newState == QAbstractAnimation::Paused || newState == QAbstractAnimation::Running)
evaluated: newState == QAbstractAnimation::Paused
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:1752
evaluated: newState == QAbstractAnimation::Running
TRUEFALSE
yes
Evaluation Count:924
yes
Evaluation Count:828
58-1752
923 && oldState == QAbstractAnimation::Stopped) {
evaluated: oldState == QAbstractAnimation::Stopped
TRUEFALSE
yes
Evaluation Count:912
yes
Evaluation Count:70
70-912
924 //here we reset the time if needed -
925 //we don't call setCurrentTime because this might change the way the animation -
926 //behaves: changing the state or changing the current value -
927 totalCurrentTime = currentTime = (direction == QAbstractAnimation::Forward) ?
evaluated: (direction == QAbstractAnimation::Forward)
TRUEFALSE
yes
Evaluation Count:794
yes
Evaluation Count:118
118-794
928 0 : (loopCount == -1 ? q->duration() : q->totalDuration());
executed (the execution status of this line is deduced): 0 : (loopCount == -1 ? q->duration() : q->totalDuration());
-
929 }
executed: }
Execution Count:912
912
930 -
931 state = newState;
executed (the execution status of this line is deduced): state = newState;
-
932 QPointer<QAbstractAnimation> guard(q);
executed (the execution status of this line is deduced): QPointer<QAbstractAnimation> guard(q);
-
933 -
934 //(un)registration of the animation must always happen before calls to -
935 //virtual function (updateState) to ensure a correct state of the timer -
936 bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
evaluated: !group
TRUEFALSE
yes
Evaluation Count:992
yes
Evaluation Count:818
evaluated: group->state() == QAbstractAnimation::Stopped
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:781
37-992
937 if (oldState == QAbstractAnimation::Running) {
evaluated: oldState == QAbstractAnimation::Running
TRUEFALSE
yes
Evaluation Count:844
yes
Evaluation Count:966
844-966
938 if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
evaluated: newState == QAbstractAnimation::Paused
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:786
evaluated: hasRegisteredTimer
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:29
29-786
939 QAnimationTimer::ensureTimerUpdate();
executed: QAnimationTimer::ensureTimerUpdate();
Execution Count:29
29
940 //the animation, is not running any more -
941 QAnimationTimer::unregisterAnimation(q);
executed (the execution status of this line is deduced): QAnimationTimer::unregisterAnimation(q);
-
942 } else if (newState == QAbstractAnimation::Running) {
executed: }
Execution Count:844
evaluated: newState == QAbstractAnimation::Running
TRUEFALSE
yes
Evaluation Count:924
yes
Evaluation Count:42
42-924
943 QAnimationTimer::registerAnimation(q, isTopLevel);
executed (the execution status of this line is deduced): QAnimationTimer::registerAnimation(q, isTopLevel);
-
944 }
executed: }
Execution Count:924
924
945 -
946 q->updateState(newState, oldState);
executed (the execution status of this line is deduced): q->updateState(newState, oldState);
-
947 if (!guard || newState != state) //this is to be safe if updateState changes the state
partially evaluated: !guard
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1810
partially evaluated: newState != state
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1810
0-1810
948 return;
never executed: return;
0
949 -
950 // Notify state change -
951 emit q->stateChanged(newState, oldState);
executed (the execution status of this line is deduced): q->stateChanged(newState, oldState);
-
952 if (!guard || newState != state) //this is to be safe if updateState changes the state
partially evaluated: !guard
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1810
partially evaluated: newState != state
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1810
0-1810
953 return;
never executed: return;
0
954 -
955 switch (state) { -
956 case QAbstractAnimation::Paused: -
957 break;
executed: break;
Execution Count:58
58
958 case QAbstractAnimation::Running: -
959 { -
960 -
961 // this ensures that the value is updated now that the animation is running -
962 if (oldState == QAbstractAnimation::Stopped) {
evaluated: oldState == QAbstractAnimation::Stopped
TRUEFALSE
yes
Evaluation Count:912
yes
Evaluation Count:12
12-912
963 if (isTopLevel) {
evaluated: isTopLevel
TRUEFALSE
yes
Evaluation Count:500
yes
Evaluation Count:412
412-500
964 // currentTime needs to be updated if pauseTimer is active -
965 QAnimationTimer::ensureTimerUpdate();
executed (the execution status of this line is deduced): QAnimationTimer::ensureTimerUpdate();
-
966 q->setCurrentTime(totalCurrentTime);
executed (the execution status of this line is deduced): q->setCurrentTime(totalCurrentTime);
-
967 }
executed: }
Execution Count:500
500
968 }
executed: }
Execution Count:912
912
969 } -
970 break;
executed: break;
Execution Count:924
924
971 case QAbstractAnimation::Stopped: -
972 // Leave running state. -
973 int dura = q->duration();
executed (the execution status of this line is deduced): int dura = q->duration();
-
974 -
975 if (deleteWhenStopped)
evaluated: deleteWhenStopped
TRUEFALSE
yes
Evaluation Count:287
yes
Evaluation Count:541
287-541
976 q->deleteLater();
executed: q->deleteLater();
Execution Count:287
287
977 -
978 if (dura == -1 || loopCount < 0
evaluated: dura == -1
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:811
evaluated: loopCount < 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:802
9-811
979 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
evaluated: oldDirection == QAbstractAnimation::Forward
TRUEFALSE
yes
Evaluation Count:710
yes
Evaluation Count:92
evaluated: (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)
TRUEFALSE
yes
Evaluation Count:611
yes
Evaluation Count:99
92-710
980 || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
evaluated: oldDirection == QAbstractAnimation::Backward
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:99
evaluated: oldCurrentTime == 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:5
5-99
981 emit q->finished();
executed (the execution status of this line is deduced): q->finished();
-
982 }
executed: }
Execution Count:724
724
983 break;
executed: break;
Execution Count:828
828
984 } -
985}
executed: }
Execution Count:1810
1810
986 -
987/*! -
988 Constructs the QAbstractAnimation base class, and passes \a parent to -
989 QObject's constructor. -
990 -
991 \sa QVariantAnimation, QAnimationGroup -
992*/ -
993QAbstractAnimation::QAbstractAnimation(QObject *parent) -
994 : QObject(*new QAbstractAnimationPrivate, 0) -
995{ -
996 // Allow auto-add on reparent -
997 setParent(parent);
executed (the execution status of this line is deduced): setParent(parent);
-
998}
executed: }
Execution Count:27
27
999 -
1000/*! -
1001 \internal -
1002*/ -
1003QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent) -
1004 : QObject(dd, 0) -
1005{ -
1006 // Allow auto-add on reparent -
1007 setParent(parent);
executed (the execution status of this line is deduced): setParent(parent);
-
1008}
executed: }
Execution Count:1505
1505
1009 -
1010/*! -
1011 Stops the animation if it's running, then destroys the -
1012 QAbstractAnimation. If the animation is part of a QAnimationGroup, it is -
1013 automatically removed before it's destroyed. -
1014*/ -
1015QAbstractAnimation::~QAbstractAnimation() -
1016{ -
1017 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1018 //we can't call stop here. Otherwise we get pure virtual calls -
1019 if (d->state != Stopped) {
evaluated: d->state != Stopped
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:1317
84-1317
1020 QAbstractAnimation::State oldState = d->state;
executed (the execution status of this line is deduced): QAbstractAnimation::State oldState = d->state;
-
1021 d->state = Stopped;
executed (the execution status of this line is deduced): d->state = Stopped;
-
1022 emit stateChanged(oldState, d->state);
executed (the execution status of this line is deduced): stateChanged(oldState, d->state);
-
1023 if (oldState == QAbstractAnimation::Running)
evaluated: oldState == QAbstractAnimation::Running
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:4
4-80
1024 QAnimationTimer::unregisterAnimation(this);
executed: QAnimationTimer::unregisterAnimation(this);
Execution Count:80
80
1025 }
executed: }
Execution Count:84
84
1026}
executed: }
Execution Count:1401
1401
1027 -
1028/*! -
1029 \property QAbstractAnimation::state -
1030 \brief state of the animation. -
1031 -
1032 This property describes the current state of the animation. When the -
1033 animation state changes, QAbstractAnimation emits the stateChanged() -
1034 signal. -
1035*/ -
1036QAbstractAnimation::State QAbstractAnimation::state() const -
1037{ -
1038 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1039 return d->state;
executed: return d->state;
Execution Count:3659
3659
1040} -
1041 -
1042/*! -
1043 If this animation is part of a QAnimationGroup, this function returns a -
1044 pointer to the group; otherwise, it returns 0. -
1045 -
1046 \sa QAnimationGroup::addAnimation() -
1047*/ -
1048QAnimationGroup *QAbstractAnimation::group() const -
1049{ -
1050 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1051 return d->group;
executed: return d->group;
Execution Count:701
701
1052} -
1053 -
1054/*! -
1055 \enum QAbstractAnimation::State -
1056 -
1057 This enum describes the state of the animation. -
1058 -
1059 \value Stopped The animation is not running. This is the initial state -
1060 of QAbstractAnimation, and the state QAbstractAnimation reenters when finished. The current -
1061 time remain unchanged until either setCurrentTime() is -
1062 called, or the animation is started by calling start(). -
1063 -
1064 \value Paused The animation is paused (i.e., temporarily -
1065 suspended). Calling resume() will resume animation activity. -
1066 -
1067 \value Running The animation is running. While control is in the event -
1068 loop, QAbstractAnimation will update its current time at regular intervals, -
1069 calling updateCurrentTime() when appropriate. -
1070 -
1071 \sa state(), stateChanged() -
1072*/ -
1073 -
1074/*! -
1075 \enum QAbstractAnimation::Direction -
1076 -
1077 This enum describes the direction of the animation when in \l Running state. -
1078 -
1079 \value Forward The current time of the animation increases with time (i.e., -
1080 moves from 0 and towards the end / duration). -
1081 -
1082 \value Backward The current time of the animation decreases with time (i.e., -
1083 moves from the end / duration and towards 0). -
1084 -
1085 \sa direction -
1086*/ -
1087 -
1088/*! -
1089 \property QAbstractAnimation::direction -
1090 \brief the direction of the animation when it is in \l Running -
1091 state. -
1092 -
1093 This direction indicates whether the time moves from 0 towards the -
1094 animation duration, or from the value of the duration and towards 0 after -
1095 start() has been called. -
1096 -
1097 By default, this property is set to \l Forward. -
1098*/ -
1099QAbstractAnimation::Direction QAbstractAnimation::direction() const -
1100{ -
1101 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1102 return d->direction;
executed: return d->direction;
Execution Count:1563
1563
1103} -
1104void QAbstractAnimation::setDirection(Direction direction) -
1105{ -
1106 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1107 if (d->direction == direction)
evaluated: d->direction == direction
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:99
99-232
1108 return;
executed: return;
Execution Count:232
232
1109 -
1110 if (state() == Stopped) {
evaluated: state() == Stopped
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:10
10-89
1111 if (direction == Backward) {
evaluated: direction == Backward
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:2
2-87
1112 d->currentTime = duration();
executed (the execution status of this line is deduced): d->currentTime = duration();
-
1113 d->currentLoop = d->loopCount - 1;
executed (the execution status of this line is deduced): d->currentLoop = d->loopCount - 1;
-
1114 } else {
executed: }
Execution Count:87
87
1115 d->currentTime = 0;
executed (the execution status of this line is deduced): d->currentTime = 0;
-
1116 d->currentLoop = 0;
executed (the execution status of this line is deduced): d->currentLoop = 0;
-
1117 }
executed: }
Execution Count:2
2
1118 } -
1119 -
1120 // the commands order below is important: first we need to setCurrentTime with the old direction, -
1121 // then update the direction on this and all children and finally restart the pauseTimer if needed -
1122 if (d->hasRegisteredTimer)
evaluated: d->hasRegisteredTimer
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:89
10-89
1123 QAnimationTimer::ensureTimerUpdate();
executed: QAnimationTimer::ensureTimerUpdate();
Execution Count:10
10
1124 -
1125 d->direction = direction;
executed (the execution status of this line is deduced): d->direction = direction;
-
1126 updateDirection(direction);
executed (the execution status of this line is deduced): updateDirection(direction);
-
1127 -
1128 if (d->hasRegisteredTimer)
evaluated: d->hasRegisteredTimer
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:89
10-89
1129 // needed to update the timer interval in case of a pause animation -
1130 QAnimationTimer::updateAnimationTimer();
executed: QAnimationTimer::updateAnimationTimer();
Execution Count:10
10
1131 -
1132 emit directionChanged(direction);
executed (the execution status of this line is deduced): directionChanged(direction);
-
1133}
executed: }
Execution Count:99
99
1134 -
1135/*! -
1136 \property QAbstractAnimation::duration -
1137 \brief the duration of the animation. -
1138 -
1139 If the duration is -1, it means that the duration is undefined. -
1140 In this case, loopCount is ignored. -
1141*/ -
1142 -
1143/*! -
1144 \property QAbstractAnimation::loopCount -
1145 \brief the loop count of the animation -
1146 -
1147 This property describes the loop count of the animation as an integer. -
1148 By default this value is 1, indicating that the animation -
1149 should run once only, and then stop. By changing it you can let the -
1150 animation loop several times. With a value of 0, the animation will not -
1151 run at all, and with a value of -1, the animation will loop forever -
1152 until stopped. -
1153 It is not supported to have loop on an animation that has an undefined -
1154 duration. It will only run once. -
1155*/ -
1156int QAbstractAnimation::loopCount() const -
1157{ -
1158 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1159 return d->loopCount;
executed: return d->loopCount;
Execution Count:8157
8157
1160} -
1161void QAbstractAnimation::setLoopCount(int loopCount) -
1162{ -
1163 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1164 d->loopCount = loopCount;
executed (the execution status of this line is deduced): d->loopCount = loopCount;
-
1165}
executed: }
Execution Count:146
146
1166 -
1167/*! -
1168 \property QAbstractAnimation::currentLoop -
1169 \brief the current loop of the animation -
1170 -
1171 This property describes the current loop of the animation. By default, -
1172 the animation's loop count is 1, and so the current loop will -
1173 always be 0. If the loop count is 2 and the animation runs past its -
1174 duration, it will automatically rewind and restart at current time 0, and -
1175 current loop 1, and so on. -
1176 -
1177 When the current loop changes, QAbstractAnimation emits the -
1178 currentLoopChanged() signal. -
1179*/ -
1180int QAbstractAnimation::currentLoop() const -
1181{ -
1182 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1183 return d->currentLoop;
executed: return d->currentLoop;
Execution Count:138
138
1184} -
1185 -
1186/*! -
1187 \fn virtual int QAbstractAnimation::duration() const = 0 -
1188 -
1189 This pure virtual function returns the duration of the animation, and -
1190 defines for how long QAbstractAnimation should update the current -
1191 time. This duration is local, and does not include the loop count. -
1192 -
1193 A return value of -1 indicates that the animation has no defined duration; -
1194 the animation should run forever until stopped. This is useful for -
1195 animations that are not time driven, or where you cannot easily predict -
1196 its duration (e.g., event driven audio playback in a game). -
1197 -
1198 If the animation is a parallel QAnimationGroup, the duration will be the longest -
1199 duration of all its animations. If the animation is a sequential QAnimationGroup, -
1200 the duration will be the sum of the duration of all its animations. -
1201 \sa loopCount -
1202*/ -
1203 -
1204/*! -
1205 Returns the total and effective duration of the animation, including the -
1206 loop count. -
1207 -
1208 \sa duration(), currentTime -
1209*/ -
1210int QAbstractAnimation::totalDuration() const -
1211{ -
1212 int dura = duration();
executed (the execution status of this line is deduced): int dura = duration();
-
1213 if (dura <= 0)
evaluated: dura <= 0
TRUEFALSE
yes
Evaluation Count:1190
yes
Evaluation Count:7987
1190-7987
1214 return dura;
executed: return dura;
Execution Count:1190
1190
1215 int loopcount = loopCount();
executed (the execution status of this line is deduced): int loopcount = loopCount();
-
1216 if (loopcount < 0)
evaluated: loopcount < 0
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:7955
32-7955
1217 return -1;
executed: return -1;
Execution Count:32
32
1218 return dura * loopcount;
executed: return dura * loopcount;
Execution Count:7955
7955
1219} -
1220 -
1221/*! -
1222 Returns the current time inside the current loop. It can go from 0 to duration(). -
1223 -
1224 \sa duration(), currentTime -
1225*/ -
1226 -
1227int QAbstractAnimation::currentLoopTime() const -
1228{ -
1229 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1230 return d->currentTime;
executed: return d->currentTime;
Execution Count:482
482
1231} -
1232 -
1233/*! -
1234 \property QAbstractAnimation::currentTime -
1235 \brief the current time and progress of the animation -
1236 -
1237 This property describes the animation's current time. You can change the -
1238 current time by calling setCurrentTime, or you can call start() and let -
1239 the animation run, setting the current time automatically as the animation -
1240 progresses. -
1241 -
1242 The animation's current time starts at 0, and ends at totalDuration(). -
1243 -
1244 \sa loopCount, currentLoopTime() -
1245 */ -
1246int QAbstractAnimation::currentTime() const -
1247{ -
1248 Q_D(const QAbstractAnimation);
executed (the execution status of this line is deduced): const QAbstractAnimationPrivate * const d = d_func();
-
1249 return d->totalCurrentTime;
executed: return d->totalCurrentTime;
Execution Count:165
165
1250} -
1251void QAbstractAnimation::setCurrentTime(int msecs) -
1252{ -
1253 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1254 msecs = qMax(msecs, 0);
executed (the execution status of this line is deduced): msecs = qMax(msecs, 0);
-
1255 -
1256 // Calculate new time and loop. -
1257 int dura = duration();
executed (the execution status of this line is deduced): int dura = duration();
-
1258 int totalDura = dura <= 0 ? dura : ((d->loopCount < 0) ? -1 : dura * d->loopCount);
evaluated: dura <= 0
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:3204
739-3204
1259 if (totalDura != -1)
evaluated: totalDura != -1
TRUEFALSE
yes
Evaluation Count:3615
yes
Evaluation Count:328
328-3615
1260 msecs = qMin(totalDura, msecs);
executed: msecs = qMin(totalDura, msecs);
Execution Count:3615
3615
1261 d->totalCurrentTime = msecs;
executed (the execution status of this line is deduced): d->totalCurrentTime = msecs;
-
1262 -
1263 // Update new values. -
1264 int oldLoop = d->currentLoop;
executed (the execution status of this line is deduced): int oldLoop = d->currentLoop;
-
1265 d->currentLoop = ((dura <= 0) ? 0 : (msecs / dura));
evaluated: (dura <= 0)
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:3204
739-3204
1266 if (d->currentLoop == d->loopCount) {
evaluated: d->currentLoop == d->loopCount
TRUEFALSE
yes
Evaluation Count:356
yes
Evaluation Count:3587
356-3587
1267 //we're at the end -
1268 d->currentTime = qMax(0, dura);
executed (the execution status of this line is deduced): d->currentTime = qMax(0, dura);
-
1269 d->currentLoop = qMax(0, d->loopCount - 1);
executed (the execution status of this line is deduced): d->currentLoop = qMax(0, d->loopCount - 1);
-
1270 } else {
executed: }
Execution Count:356
356
1271 if (d->direction == Forward) {
evaluated: d->direction == Forward
TRUEFALSE
yes
Evaluation Count:3354
yes
Evaluation Count:233
233-3354
1272 d->currentTime = (dura <= 0) ? msecs : (msecs % dura);
evaluated: (dura <= 0)
TRUEFALSE
yes
Evaluation Count:709
yes
Evaluation Count:2645
709-2645
1273 } else {
executed: }
Execution Count:3354
3354
1274 d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
evaluated: (dura <= 0)
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:203
30-203
1275 if (d->currentTime == dura)
evaluated: d->currentTime == dura
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:187
46-187
1276 --d->currentLoop;
executed: --d->currentLoop;
Execution Count:46
46
1277 }
executed: }
Execution Count:233
233
1278 } -
1279 -
1280 updateCurrentTime(d->currentTime);
executed (the execution status of this line is deduced): updateCurrentTime(d->currentTime);
-
1281 if (d->currentLoop != oldLoop)
evaluated: d->currentLoop != oldLoop
TRUEFALSE
yes
Evaluation Count:237
yes
Evaluation Count:3706
237-3706
1282 emit currentLoopChanged(d->currentLoop);
executed: currentLoopChanged(d->currentLoop);
Execution Count:237
237
1283 -
1284 // All animations are responsible for stopping the animation when their -
1285 // own end state is reached; in this case the animation is time driven, -
1286 // and has reached the end. -
1287 if ((d->direction == Forward && d->totalCurrentTime == totalDura)
evaluated: d->direction == Forward
TRUEFALSE
yes
Evaluation Count:3634
yes
Evaluation Count:309
evaluated: d->totalCurrentTime == totalDura
TRUEFALSE
yes
Evaluation Count:696
yes
Evaluation Count:2938
309-3634
1288 || (d->direction == Backward && d->totalCurrentTime == 0)) {
evaluated: d->direction == Backward
TRUEFALSE
yes
Evaluation Count:309
yes
Evaluation Count:2938
evaluated: d->totalCurrentTime == 0
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:235
74-2938
1289 stop();
executed (the execution status of this line is deduced): stop();
-
1290 }
executed: }
Execution Count:770
770
1291}
executed: }
Execution Count:3943
3943
1292 -
1293/*! -
1294 Starts the animation. The \a policy argument says whether or not the -
1295 animation should be deleted when it's done. When the animation starts, the -
1296 stateChanged() signal is emitted, and state() returns Running. When control -
1297 reaches the event loop, the animation will run by itself, periodically -
1298 calling updateCurrentTime() as the animation progresses. -
1299 -
1300 If the animation is currently stopped or has already reached the end, -
1301 calling start() will rewind the animation and start again from the beginning. -
1302 When the animation reaches the end, the animation will either stop, or -
1303 if the loop level is more than 1, it will rewind and continue from the beginning. -
1304 -
1305 If the animation is already running, this function does nothing. -
1306 -
1307 \sa stop(), state() -
1308*/ -
1309void QAbstractAnimation::start(DeletionPolicy policy) -
1310{ -
1311 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1312 if (d->state == Running)
evaluated: d->state == Running
TRUEFALSE
yes
Evaluation Count:474
yes
Evaluation Count:920
474-920
1313 return;
executed: return;
Execution Count:474
474
1314 d->deleteWhenStopped = policy;
executed (the execution status of this line is deduced): d->deleteWhenStopped = policy;
-
1315 d->setState(Running);
executed (the execution status of this line is deduced): d->setState(Running);
-
1316}
executed: }
Execution Count:920
920
1317 -
1318/*! -
1319 Stops the animation. When the animation is stopped, it emits the stateChanged() -
1320 signal, and state() returns Stopped. The current time is not changed. -
1321 -
1322 If the animation stops by itself after reaching the end (i.e., -
1323 currentLoopTime() == duration() and currentLoop() > loopCount() - 1), the -
1324 finished() signal is emitted. -
1325 -
1326 \sa start(), state() -
1327 */ -
1328void QAbstractAnimation::stop() -
1329{ -
1330 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1331 -
1332 if (d->state == Stopped)
evaluated: d->state == Stopped
TRUEFALSE
yes
Evaluation Count:1528
yes
Evaluation Count:828
828-1528
1333 return;
executed: return;
Execution Count:1528
1528
1334 -
1335 d->setState(Stopped);
executed (the execution status of this line is deduced): d->setState(Stopped);
-
1336}
executed: }
Execution Count:828
828
1337 -
1338/*! -
1339 Pauses the animation. When the animation is paused, state() returns Paused. -
1340 The value of currentTime will remain unchanged until resume() or start() -
1341 is called. If you want to continue from the current time, call resume(). -
1342 -
1343 \sa start(), state(), resume() -
1344 */ -
1345void QAbstractAnimation::pause() -
1346{ -
1347 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1348 if (d->state == Stopped) {
evaluated: d->state == Stopped
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:59
2-59
1349 qWarning("QAbstractAnimation::pause: Cannot pause a stopped animation");
executed (the execution status of this line is deduced): QMessageLogger("animation/qabstractanimation.cpp", 1349, __PRETTY_FUNCTION__).warning("QAbstractAnimation::pause: Cannot pause a stopped animation");
-
1350 return;
executed: return;
Execution Count:2
2
1351 } -
1352 -
1353 d->setState(Paused);
executed (the execution status of this line is deduced): d->setState(Paused);
-
1354}
executed: }
Execution Count:59
59
1355 -
1356/*! -
1357 Resumes the animation after it was paused. When the animation is resumed, -
1358 it emits the resumed() and stateChanged() signals. The currenttime is not -
1359 changed. -
1360 -
1361 \sa start(), pause(), state() -
1362 */ -
1363void QAbstractAnimation::resume() -
1364{ -
1365 Q_D(QAbstractAnimation);
executed (the execution status of this line is deduced): QAbstractAnimationPrivate * const d = d_func();
-
1366 if (d->state != Paused) {
evaluated: d->state != Paused
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1367 qWarning("QAbstractAnimation::resume: "
executed (the execution status of this line is deduced): QMessageLogger("animation/qabstractanimation.cpp", 1367, __PRETTY_FUNCTION__).warning("QAbstractAnimation::resume: "
-
1368 "Cannot resume an animation that is not paused");
executed (the execution status of this line is deduced): "Cannot resume an animation that is not paused");
-
1369 return;
executed: return;
Execution Count:2
2
1370 } -
1371 -
1372 d->setState(Running);
executed (the execution status of this line is deduced): d->setState(Running);
-
1373}
executed: }
Execution Count:5
5
1374 -
1375/*! -
1376 If \a paused is true, the animation is paused. -
1377 If \a paused is false, the animation is resumed. -
1378 -
1379 \sa state(), pause(), resume() -
1380*/ -
1381void QAbstractAnimation::setPaused(bool paused) -
1382{ -
1383 if (paused)
never evaluated: paused
0
1384 pause();
never executed: pause();
0
1385 else -
1386 resume();
never executed: resume();
0
1387} -
1388 -
1389 -
1390/*! -
1391 \reimp -
1392*/ -
1393bool QAbstractAnimation::event(QEvent *event) -
1394{ -
1395 return QObject::event(event);
executed: return QObject::event(event);
Execution Count:1036
1036
1396} -
1397 -
1398/*! -
1399 \fn virtual void QAbstractAnimation::updateCurrentTime(int currentTime) = 0; -
1400 -
1401 This pure virtual function is called every time the animation's -
1402 \a currentTime changes. -
1403 -
1404 \sa updateState() -
1405*/ -
1406 -
1407/*! -
1408 This virtual function is called by QAbstractAnimation when the state -
1409 of the animation is changed from \a oldState to \a newState. -
1410 -
1411 \sa start(), stop(), pause(), resume() -
1412*/ -
1413void QAbstractAnimation::updateState(QAbstractAnimation::State newState, -
1414 QAbstractAnimation::State oldState) -
1415{ -
1416 Q_UNUSED(oldState);
executed (the execution status of this line is deduced): (void)oldState;;
-
1417 Q_UNUSED(newState);
executed (the execution status of this line is deduced): (void)newState;;
-
1418}
executed: }
Execution Count:305
305
1419 -
1420/*! -
1421 This virtual function is called by QAbstractAnimation when the direction -
1422 of the animation is changed. The \a direction argument is the new direction. -
1423 -
1424 \sa setDirection(), direction() -
1425*/ -
1426void QAbstractAnimation::updateDirection(QAbstractAnimation::Direction direction) -
1427{ -
1428 Q_UNUSED(direction);
executed (the execution status of this line is deduced): (void)direction;;
-
1429}
executed: }
Execution Count:78
78
1430 -
1431 -
1432QT_END_NAMESPACE -
1433 -
1434#include "moc_qabstractanimation.cpp" -
1435 -
1436#endif //QT_NO_ANIMATION -
1437 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial