animation/qparallelanimationgroup.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11QParallelAnimationGroup::QParallelAnimationGroup(QObject *parent) -
12 : QAnimationGroup(*new QParallelAnimationGroupPrivate, parent) -
13{ -
14}
executed: }
Execution Count:81
81
15 -
16 -
17 -
18 -
19QParallelAnimationGroup::QParallelAnimationGroup(QParallelAnimationGroupPrivate &dd, -
20 QObject *parent) -
21 : QAnimationGroup(dd, parent) -
22{ -
23}
never executed: }
0
24 -
25 -
26 -
27 -
28QParallelAnimationGroup::~QParallelAnimationGroup() -
29{ -
30} -
31 -
32 -
33 -
34 -
35int QParallelAnimationGroup::duration() const -
36{ -
37 const QParallelAnimationGroupPrivate * const d = d_func(); -
38 int ret = 0; -
39 -
40 for (int i = 0; i < d->animations.size(); ++i) {
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:1362
yes
Evaluation Count:505
505-1362
41 QAbstractAnimation *animation = d->animations.at(i); -
42 const int currentDuration = animation->totalDuration(); -
43 if (currentDuration == -1)
evaluated: currentDuration == -1
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1353
9-1353
44 return -1;
executed: return -1;
Execution Count:9
9
45 -
46 ret = qMax(ret, currentDuration); -
47 }
executed: }
Execution Count:1353
1353
48 -
49 return ret;
executed: return ret;
Execution Count:505
505
50} -
51 -
52 -
53 -
54 -
55void QParallelAnimationGroup::updateCurrentTime(int currentTime) -
56{ -
57 QParallelAnimationGroupPrivate * const d = d_func(); -
58 if (d->animations.isEmpty())
partially evaluated: d->animations.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:325
0-325
59 return;
never executed: return;
0
60 -
61 if (d->currentLoop > d->lastLoop) {
evaluated: d->currentLoop > d->lastLoop
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:280
45-280
62 -
63 int dura = duration(); -
64 if (dura > 0) {
partially evaluated: dura > 0
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
65 for (int i = 0; i < d->animations.size(); ++i) {
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:45
45-136
66 QAbstractAnimation *animation = d->animations.at(i); -
67 if (animation->state() != QAbstractAnimation::Stopped)
evaluated: animation->state() != QAbstractAnimation::Stopped
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:84
52-84
68 d->animations.at(i)->setCurrentTime(dura);
executed: d->animations.at(i)->setCurrentTime(dura);
Execution Count:52
52
69 }
executed: }
Execution Count:136
136
70 }
executed: }
Execution Count:45
45
71 } else if (d->currentLoop < d->lastLoop) {
evaluated: d->currentLoop < d->lastLoop
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:252
executed: }
Execution Count:45
28-252
72 -
73 for (int i = 0; i < d->animations.size(); ++i) {
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:28
28-84
74 QAbstractAnimation *animation = d->animations.at(i); -
75 -
76 -
77 d->applyGroupState(animation); -
78 animation->setCurrentTime(0); -
79 animation->stop(); -
80 }
executed: }
Execution Count:84
84
81 }
executed: }
Execution Count:28
28
82 -
83 -
84 -
85 -
86 -
87 -
88 for (int i = 0; i < d->animations.size(); ++i) {
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:950
yes
Evaluation Count:325
325-950
89 QAbstractAnimation *animation = d->animations.at(i); -
90 const int dura = animation->totalDuration(); -
91 -
92 if (d->currentLoop > d->lastLoop
evaluated: d->currentLoop > d->lastLoop
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:814
136-814
93 -
94 -
95 || d->shouldAnimationStart(animation, d->lastCurrentTime > dura )) {
evaluated: d->shouldAnimationStart(animation, d->lastCurrentTime > dura )
TRUEFALSE
yes
Evaluation Count:549
yes
Evaluation Count:265
265-549
96 d->applyGroupState(animation); -
97 }
executed: }
Execution Count:685
685
98 -
99 if (animation->state() == state()) {
evaluated: animation->state() == state()
TRUEFALSE
yes
Evaluation Count:765
yes
Evaluation Count:185
185-765
100 animation->setCurrentTime(currentTime); -
101 if (dura > 0 && currentTime > dura)
evaluated: dura > 0
TRUEFALSE
yes
Evaluation Count:653
yes
Evaluation Count:112
evaluated: currentTime > dura
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:621
32-653
102 animation->stop();
executed: animation->stop();
Execution Count:32
32
103 }
executed: }
Execution Count:765
765
104 }
executed: }
Execution Count:950
950
105 d->lastLoop = d->currentLoop; -
106 d->lastCurrentTime = currentTime; -
107}
executed: }
Execution Count:325
325
108 -
109 -
110 -
111 -
112void QParallelAnimationGroup::updateState(QAbstractAnimation::State newState, -
113 QAbstractAnimation::State oldState) -
114{ -
115 QParallelAnimationGroupPrivate * const d = d_func(); -
116 QAnimationGroup::updateState(newState, oldState); -
117 -
118 switch (newState) { -
119 case Stopped: -
120 for (int i = 0; i < d->animations.size(); ++i)
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:57
41-57
121 d->animations.at(i)->stop();
executed: d->animations.at(i)->stop();
Execution Count:41
41
122 d->disconnectUncontrolledAnimations(); -
123 break;
executed: break;
Execution Count:57
57
124 case Paused: -
125 for (int i = 0; i < d->animations.size(); ++i)
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
126 if (d->animations.at(i)->state() == Running)
evaluated: d->animations.at(i)->state() == Running
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
127 d->animations.at(i)->pause();
executed: d->animations.at(i)->pause();
Execution Count:5
5
128 break;
executed: break;
Execution Count:4
4
129 case Running: -
130 d->connectUncontrolledAnimations(); -
131 for (int i = 0; i < d->animations.size(); ++i) {
evaluated: i < d->animations.size()
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:62
62-168
132 QAbstractAnimation *animation = d->animations.at(i); -
133 if (oldState == Stopped)
evaluated: oldState == Stopped
TRUEFALSE
yes
Evaluation Count:164
yes
Evaluation Count:4
4-164
134 animation->stop();
executed: animation->stop();
Execution Count:164
164
135 animation->setDirection(d->direction); -
136 if (d->shouldAnimationStart(animation, oldState == Stopped))
evaluated: d->shouldAnimationStart(animation, oldState == Stopped)
TRUEFALSE
yes
Evaluation Count:114
yes
Evaluation Count:54
54-114
137 animation->start();
executed: animation->start();
Execution Count:114
114
138 }
executed: }
Execution Count:168
168
139 break;
executed: break;
Execution Count:62
62
140 } -
141}
executed: }
Execution Count:123
123
142 -
143void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() -
144{ -
145 QParallelAnimationGroup * const q = q_func(); -
146 -
147 QAbstractAnimation *animation = qobject_cast<QAbstractAnimation *>(q->sender()); -
148 qt_noop(); -
149 -
150 int uncontrolledRunningCount = 0; -
151 if (animation->duration() == -1 || animation->loopCount() < 0) {
evaluated: animation->duration() == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: animation->loopCount() < 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
152 QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); -
153 while (it != uncontrolledFinishTime.end()) {
evaluated: it != uncontrolledFinishTime.end()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
154 if (it.key() == animation) {
evaluated: it.key() == animation
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
155 *it = animation->currentTime(); -
156 }
executed: }
Execution Count:2
2
157 if (it.value() == -1)
evaluated: it.value() == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
158 ++uncontrolledRunningCount;
executed: ++uncontrolledRunningCount;
Execution Count:1
1
159 ++it; -
160 }
executed: }
Execution Count:4
4
161 }
executed: }
Execution Count:2
2
162 -
163 if (uncontrolledRunningCount > 0)
evaluated: uncontrolledRunningCount > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
164 return;
executed: return;
Execution Count:1
1
165 -
166 int maxDuration = 0; -
167 for (int i = 0; i < animations.size(); ++i)
evaluated: i < animations.size()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
168 maxDuration = qMax(maxDuration, animations.at(i)->totalDuration());
executed: maxDuration = qMax(maxDuration, animations.at(i)->totalDuration());
Execution Count:3
3
169 -
170 if (currentTime >= maxDuration)
partially evaluated: currentTime >= maxDuration
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
171 q->stop();
executed: q->stop();
Execution Count:1
1
172}
executed: }
Execution Count:1
1
173 -
174void QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations() -
175{ -
176 QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); -
177 while (it != uncontrolledFinishTime.end()) {
evaluated: it != uncontrolledFinishTime.end()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:57
3-57
178 disconnectUncontrolledAnimation(it.key()); -
179 ++it; -
180 }
executed: }
Execution Count:3
3
181 -
182 uncontrolledFinishTime.clear(); -
183}
executed: }
Execution Count:57
57
184 -
185void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() -
186{ -
187 for (int i = 0; i < animations.size(); ++i) {
evaluated: i < animations.size()
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:62
62-168
188 QAbstractAnimation *animation = animations.at(i); -
189 if (animation->duration() == -1 || animation->loopCount() < 0) {
evaluated: animation->duration() == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:167
evaluated: animation->loopCount() < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:164
1-167
190 uncontrolledFinishTime[animation] = -1; -
191 connectUncontrolledAnimation(animation); -
192 }
executed: }
Execution Count:4
4
193 }
executed: }
Execution Count:168
168
194}
executed: }
Execution Count:62
62
195 -
196bool QParallelAnimationGroupPrivate::shouldAnimationStart(QAbstractAnimation *animation, bool startIfAtEnd) const -
197{ -
198 const int dura = animation->totalDuration(); -
199 if (dura == -1)
evaluated: dura == -1
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:962
20-962
200 return !isUncontrolledAnimationFinished(animation);
executed: return !isUncontrolledAnimationFinished(animation);
Execution Count:20
20
201 if (startIfAtEnd)
evaluated: startIfAtEnd
TRUEFALSE
yes
Evaluation Count:335
yes
Evaluation Count:627
335-627
202 return currentTime <= dura;
executed: return currentTime <= dura;
Execution Count:335
335
203 if (direction == QAbstractAnimation::Forward)
evaluated: direction == QAbstractAnimation::Forward
TRUEFALSE
yes
Evaluation Count:564
yes
Evaluation Count:63
63-564
204 return currentTime < dura;
executed: return currentTime < dura;
Execution Count:564
564
205 else -
206 return currentTime && currentTime <= dura;
executed: return currentTime && currentTime <= dura;
Execution Count:63
63
207} -
208 -
209void QParallelAnimationGroupPrivate::applyGroupState(QAbstractAnimation *animation) -
210{ -
211 switch (state) -
212 { -
213 case QAbstractAnimation::Running: -
214 animation->start(); -
215 break;
executed: break;
Execution Count:632
632
216 case QAbstractAnimation::Paused: -
217 animation->pause(); -
218 break;
never executed: break;
0
219 case QAbstractAnimation::Stopped: -
220 default: -
221 break;
executed: break;
Execution Count:137
137
222 } -
223}
executed: }
Execution Count:769
769
224 -
225 -
226bool QParallelAnimationGroupPrivate::isUncontrolledAnimationFinished(QAbstractAnimation *anim) const -
227{ -
228 return uncontrolledFinishTime.value(anim, -1) >= 0;
executed: return uncontrolledFinishTime.value(anim, -1) >= 0;
Execution Count:20
20
229} -
230 -
231void QParallelAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *anim) -
232{ -
233 QAnimationGroupPrivate::animationRemoved(index, anim); -
234 disconnectUncontrolledAnimation(anim); -
235 uncontrolledFinishTime.remove(anim); -
236}
executed: }
Execution Count:164
164
237 -
238 -
239 -
240 -
241void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction direction) -
242{ -
243 QParallelAnimationGroupPrivate * const d = d_func(); -
244 -
245 if (state() != Stopped) {
partially evaluated: state() != Stopped
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
246 for (int i = 0; i < d->animations.size(); ++i) {
never evaluated: i < d->animations.size()
0
247 QAbstractAnimation *animation = d->animations.at(i); -
248 animation->setDirection(direction); -
249 }
never executed: }
0
250 } else {
never executed: }
0
251 if (direction == Forward) {
partially evaluated: direction == Forward
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
252 d->lastLoop = 0; -
253 d->lastCurrentTime = 0; -
254 } else {
never executed: }
0
255 -
256 d->lastLoop = (d->loopCount == -1 ? 0 : d->loopCount - 1);
evaluated: d->loopCount == -1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:16
3-16
257 d->lastCurrentTime = duration(); -
258 }
executed: }
Execution Count:19
19
259 } -
260} -
261 -
262 -
263 -
264 -
265bool QParallelAnimationGroup::event(QEvent *event) -
266{ -
267 return QAnimationGroup::event(event);
executed: return QAnimationGroup::event(event);
Execution Count:520
520
268} -
269 -
270 -
271 -
272 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial