qparallelanimationgroup.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/animation/qparallelanimationgroup.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34/*!-
35 \class QParallelAnimationGroup-
36 \inmodule QtCore-
37 \brief The QParallelAnimationGroup class provides a parallel group of animations.-
38 \since 4.6-
39 \ingroup animation-
40-
41 QParallelAnimationGroup--a \l{QAnimationGroup}{container for-
42 animations}--starts all its animations when it is-
43 \l{QAbstractAnimation::start()}{started} itself, i.e., runs all-
44 animations in parallel. The animation group finishes when the-
45 longest lasting animation has finished.-
46-
47 You can treat QParallelAnimationGroup as any other QAbstractAnimation,-
48 e.g., pause, resume, or add it to other animation groups.-
49-
50 \code-
51 QParallelAnimationGroup *group = new QParallelAnimationGroup;-
52 group->addAnimation(anim1);-
53 group->addAnimation(anim2);-
54-
55 group->start();-
56 \endcode-
57-
58 In this example, \c anim1 and \c anim2 are two-
59 \l{QPropertyAnimation}s that have already been set up.-
60-
61 \sa QAnimationGroup, QPropertyAnimation, {The Animation Framework}-
62*/-
63-
64-
65#include "qparallelanimationgroup.h"-
66#include "qparallelanimationgroup_p.h"-
67//#define QANIMATION_DEBUG-
68-
69#ifndef QT_NO_ANIMATION-
70-
71QT_BEGIN_NAMESPACE-
72-
73typedef QList<QAbstractAnimation *>::ConstIterator AnimationListConstIt;-
74typedef QHash<QAbstractAnimation*, int>::Iterator AnimationTimeHashIt;-
75typedef QHash<QAbstractAnimation*, int>::ConstIterator AnimationTimeHashConstIt;-
76-
77/*!-
78 Constructs a QParallelAnimationGroup.-
79 \a parent is passed to QObject's constructor.-
80*/-
81QParallelAnimationGroup::QParallelAnimationGroup(QObject *parent)-
82 : QAnimationGroup(*new QParallelAnimationGroupPrivate, parent)-
83{-
84}
executed 81 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
81
85-
86/*!-
87 \internal-
88*/-
89QParallelAnimationGroup::QParallelAnimationGroup(QParallelAnimationGroupPrivate &dd,-
90 QObject *parent)-
91 : QAnimationGroup(dd, parent)-
92{-
93}
never executed: end of block
0
94-
95/*!-
96 Destroys the animation group. It will also destroy all its animations.-
97*/-
98QParallelAnimationGroup::~QParallelAnimationGroup()-
99{-
100}-
101-
102/*!-
103 \reimp-
104*/-
105int QParallelAnimationGroup::duration() const-
106{-
107 Q_D(const QParallelAnimationGroup);-
108 int ret = 0;-
109-
110 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 1359 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 505 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
505-1359
111 const int currentDuration = (*it)->totalDuration();-
112 if (currentDuration == -1)
currentDuration == -1Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
FALSEevaluated 1350 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
9-1350
113 return -1; // Undetermined length
executed 9 times by 2 tests: return -1;
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
9
114-
115 ret = qMax(ret, currentDuration);-
116 }
executed 1350 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
1350
117-
118 return ret;
executed 505 times by 5 tests: return ret;
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
505
119}-
120-
121/*!-
122 \reimp-
123*/-
124void QParallelAnimationGroup::updateCurrentTime(int currentTime)-
125{-
126 Q_D(QParallelAnimationGroup);-
127 if (d->animations.isEmpty())
d->animations.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 325 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
0-325
128 return;
never executed: return;
0
129-
130 if (d->currentLoop > d->lastLoop) {
d->currentLoop > d->lastLoopDescription
TRUEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEevaluated 280 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
45-280
131 // simulate completion of the loop-
132 int dura = duration();-
133 if (dura > 0) {
dura > 0Description
TRUEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEnever evaluated
0-45
134 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 136 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
45-136
135 QAbstractAnimation *animation = (*it);-
136 if (animation->state() != QAbstractAnimation::Stopped)
animation->sta...ation::StoppedDescription
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
52-84
137 animation->setCurrentTime(dura); // will stop
executed 52 times by 2 tests: animation->setCurrentTime(dura);
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
52
138 }
executed 136 times by 2 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
136
139 }
executed 45 times by 2 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
45
140 } else if (d->currentLoop < d->lastLoop) {
executed 45 times by 2 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
d->currentLoop < d->lastLoopDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 252 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
28-252
141 // simulate completion of the loop seeking backwards-
142 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 84 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
28-84
143 QAbstractAnimation *animation = *it;-
144 //we need to make sure the animation is in the right state-
145 //and then rewind it-
146 d->applyGroupState(animation);-
147 animation->setCurrentTime(0);-
148 animation->stop();-
149 }
executed 84 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
84
150 }
executed 28 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
28
151-
152#ifdef QANIMATION_DEBUG-
153 qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d",-
154 __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state());-
155#endif-
156 // finally move into the actual time of the current loop-
157 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 947 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 325 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
325-947
158 QAbstractAnimation *animation = *it;-
159 const int dura = animation->totalDuration();-
160 //if the loopcount is bigger we should always start all animations-
161 if (d->currentLoop > d->lastLoop
d->currentLoop > d->lastLoopDescription
TRUEevaluated 136 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEevaluated 811 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
136-811
162 //if we're at the end of the animation, we need to start it if it wasn't already started in this loop-
163 //this happens in Backward direction where not all animations are started at the same time-
164 || d->shouldAnimationStart(animation, d->lastCurrentTime > dura /*startIfAtEnd*/)) {
d->shouldAnima...tTime > dura )Description
TRUEevaluated 551 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 260 times by 4 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
260-551
165 d->applyGroupState(animation);-
166 }
executed 687 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
687
167-
168 if (animation->state() == state()) {
animation->state() == state()Description
TRUEevaluated 767 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 180 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
180-767
169 animation->setCurrentTime(currentTime);-
170 if (dura > 0 && currentTime > dura)
dura > 0Description
TRUEevaluated 655 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
currentTime > duraDescription
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
FALSEevaluated 622 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
33-655
171 animation->stop();
executed 33 times by 3 tests: animation->stop();
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
33
172 }
executed 767 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
767
173 }
executed 947 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
947
174 d->lastLoop = d->currentLoop;-
175 d->lastCurrentTime = currentTime;-
176}
executed 325 times by 5 tests: end of block
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
325
177-
178/*!-
179 \reimp-
180*/-
181void QParallelAnimationGroup::updateState(QAbstractAnimation::State newState,-
182 QAbstractAnimation::State oldState)-
183{-
184 Q_D(QParallelAnimationGroup);-
185 QAnimationGroup::updateState(newState, oldState);-
186-
187 switch (newState) {-
188 case Stopped:
executed 57 times by 3 tests: case Stopped:
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
57
189 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it)
it != cendDescription
TRUEevaluated 41 times by 3 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
FALSEevaluated 57 times by 3 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
41-57
190 (*it)->stop();
executed 41 times by 3 tests: (*it)->stop();
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
41
191 d->disconnectUncontrolledAnimations();-
192 break;
executed 57 times by 3 tests: break;
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
57
193 case Paused:
executed 4 times by 2 tests: case Paused:
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
4
194 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
4-6
195 if ((*it)->state() == Running)
(*it)->state() == RunningDescription
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
1-5
196 (*it)->pause();
executed 5 times by 2 tests: (*it)->pause();
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
5
197 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
6
198 break;
executed 4 times by 2 tests: break;
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
4
199 case Running:
executed 62 times by 4 tests: case Running:
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
62
200 d->connectUncontrolledAnimations();-
201 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 168 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 62 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
62-168
202 QAbstractAnimation *animation = *it;-
203 if (oldState == Stopped)
oldState == StoppedDescription
TRUEevaluated 164 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QSequentialAnimationGroup
4-164
204 animation->stop();
executed 164 times by 4 tests: animation->stop();
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
164
205 animation->setDirection(d->direction);-
206 if (d->shouldAnimationStart(animation, oldState == Stopped))
d->shouldAnima...te == Stopped)Description
TRUEevaluated 114 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 54 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
54-114
207 animation->start();
executed 114 times by 4 tests: animation->start();
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
114
208 }
executed 168 times by 4 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
168
209 break;
executed 62 times by 4 tests: break;
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
62
210 }-
211}
executed 123 times by 4 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
123
212-
213void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished()-
214{-
215 Q_Q(QParallelAnimationGroup);-
216-
217 QAbstractAnimation *animation = qobject_cast<QAbstractAnimation *>(q->sender());-
218 Q_ASSERT(animation);-
219-
220 int uncontrolledRunningCount = 0;-
221 if (animation->duration() == -1 || animation->loopCount() < 0) {
animation->duration() == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
animation->loopCount() < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEnever evaluated
0-1
222 for (AnimationTimeHashIt it = uncontrolledFinishTime.begin(), cend = uncontrolledFinishTime.end(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
2-4
223 if (it.key() == animation) {
it.key() == animationDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
2
224 *it = animation->currentTime();-
225 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
2
226 if (it.value() == -1)
it.value() == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
1-3
227 ++uncontrolledRunningCount;
executed 1 time by 1 test: ++uncontrolledRunningCount;
Executed by:
  • tst_QParallelAnimationGroup
1
228 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
4
229 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
2
230-
231 if (uncontrolledRunningCount > 0)
uncontrolledRunningCount > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
1
232 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QParallelAnimationGroup
1
233-
234 int maxDuration = 0;-
235 for (AnimationListConstIt it = animations.constBegin(), cend = animations.constEnd(); it != cend; ++it)
it != cendDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
1-3
236 maxDuration = qMax(maxDuration, (*it)->totalDuration());
executed 3 times by 1 test: maxDuration = qMax(maxDuration, (*it)->totalDuration());
Executed by:
  • tst_QParallelAnimationGroup
3
237-
238 if (currentTime >= maxDuration)
currentTime >= maxDurationDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEnever evaluated
0-1
239 q->stop();
executed 1 time by 1 test: q->stop();
Executed by:
  • tst_QParallelAnimationGroup
1
240}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
1
241-
242void QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations()-
243{-
244 for (AnimationTimeHashConstIt it = uncontrolledFinishTime.constBegin(), cend = uncontrolledFinishTime.constEnd(); it != cend; ++it)
it != cendDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 57 times by 3 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
3-57
245 disconnectUncontrolledAnimation(it.key());
executed 3 times by 1 test: disconnectUncontrolledAnimation(it.key());
Executed by:
  • tst_QParallelAnimationGroup
3
246-
247 uncontrolledFinishTime.clear();-
248}
executed 57 times by 3 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QStateMachine
57
249-
250void QParallelAnimationGroupPrivate::connectUncontrolledAnimations()-
251{-
252 for (AnimationListConstIt it = animations.constBegin(), cend = animations.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEevaluated 168 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 62 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
62-168
253 QAbstractAnimation *animation = *it;-
254 if (animation->duration() == -1 || animation->loopCount() < 0) {
animation->duration() == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 167 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
animation->loopCount() < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 164 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
1-167
255 uncontrolledFinishTime[animation] = -1;-
256 connectUncontrolledAnimation(animation);-
257 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
4
258 }
executed 168 times by 4 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
168
259}
executed 62 times by 4 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
62
260-
261bool QParallelAnimationGroupPrivate::shouldAnimationStart(QAbstractAnimation *animation, bool startIfAtEnd) const-
262{-
263 const int dura = animation->totalDuration();-
264 if (dura == -1)
dura == -1Description
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
FALSEevaluated 959 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
20-959
265 return !isUncontrolledAnimationFinished(animation);
executed 20 times by 2 tests: return !isUncontrolledAnimationFinished(animation);
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
20
266 if (startIfAtEnd)
startIfAtEndDescription
TRUEevaluated 331 times by 4 tests
Evaluated by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 628 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
331-628
267 return currentTime <= dura;
executed 331 times by 4 tests: return currentTime <= dura;
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
331
268 if (direction == QAbstractAnimation::Forward)
direction == Q...ation::ForwardDescription
TRUEevaluated 565 times by 5 tests
Evaluated by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
FALSEevaluated 63 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
63-565
269 return currentTime < dura;
executed 565 times by 5 tests: return currentTime < dura;
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
565
270 else //direction == QAbstractAnimation::Backward-
271 return currentTime && currentTime <= dura;
executed 63 times by 1 test: return currentTime && currentTime <= dura;
Executed by:
  • tst_QParallelAnimationGroup
currentTimeDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
currentTime <= duraDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
2-63
272}-
273-
274void QParallelAnimationGroupPrivate::applyGroupState(QAbstractAnimation *animation)-
275{-
276 switch (state)-
277 {-
278 case QAbstractAnimation::Running:
executed 634 times by 4 tests: case QAbstractAnimation::Running:
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
634
279 animation->start();-
280 break;
executed 634 times by 4 tests: break;
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
634
281 case QAbstractAnimation::Paused:
never executed: case QAbstractAnimation::Paused:
0
282 animation->pause();-
283 break;
never executed: break;
0
284 case QAbstractAnimation::Stopped:
executed 137 times by 2 tests: case QAbstractAnimation::Stopped:
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
137
285 default:
never executed: default:
0
286 break;
executed 137 times by 2 tests: break;
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
137
287 }-
288}-
289-
290-
291bool QParallelAnimationGroupPrivate::isUncontrolledAnimationFinished(QAbstractAnimation *anim) const-
292{-
293 return uncontrolledFinishTime.value(anim, -1) >= 0;
executed 20 times by 2 tests: return uncontrolledFinishTime.value(anim, -1) >= 0;
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
20
294}-
295-
296void QParallelAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *anim)-
297{-
298 QAnimationGroupPrivate::animationRemoved(index, anim);-
299 disconnectUncontrolledAnimation(anim);-
300 uncontrolledFinishTime.remove(anim);-
301}
executed 164 times by 2 tests: end of block
Executed by:
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
164
302-
303/*!-
304 \reimp-
305*/-
306void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction direction)-
307{-
308 Q_D(QParallelAnimationGroup);-
309 //we need to update the direction of the current animation-
310 if (state() != Stopped) {
state() != StoppedDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
0-19
311 for (AnimationListConstIt it = d->animations.constBegin(), cend = d->animations.constEnd(); it != cend; ++it)
it != cendDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 (*it)->setDirection(direction);
never executed: (*it)->setDirection(direction);
0
313 } else {
never executed: end of block
0
314 if (direction == Forward) {
direction == ForwardDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
0-19
315 d->lastLoop = 0;-
316 d->lastCurrentTime = 0;-
317 } else {
never executed: end of block
0
318 // Looping backwards with loopCount == -1 does not really work well...-
319 d->lastLoop = (d->loopCount == -1 ? 0 : d->loopCount - 1);
d->loopCount == -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QParallelAnimationGroup
3-16
320 d->lastCurrentTime = duration();-
321 }
executed 19 times by 1 test: end of block
Executed by:
  • tst_QParallelAnimationGroup
19
322 }-
323}-
324-
325/*!-
326 \reimp-
327*/-
328bool QParallelAnimationGroup::event(QEvent *event)-
329{-
330 return QAnimationGroup::event(event);
executed 520 times by 5 tests: return QAnimationGroup::event(event);
Executed by:
  • tst_QAnimationGroup
  • tst_QParallelAnimationGroup
  • tst_QPauseAnimation
  • tst_QSequentialAnimationGroup
  • tst_QStateMachine
520
331}-
332-
333QT_END_NAMESPACE-
334-
335#include "moc_qparallelanimationgroup.cpp"-
336-
337#endif //QT_NO_ANIMATION-
Source codeSwitch to Preprocessed file

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