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

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