OpenCoverage

qquickspringanimation.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickspringanimation.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10class QQuickSpringAnimationPrivate;-
11class __attribute__((visibility("default"))) QSpringAnimation : public QAbstractAnimationJob-
12{-
13 QSpringAnimation(const QSpringAnimation &) = delete; QSpringAnimation &operator=(const QSpringAnimation &) = delete;-
14public:-
15 QSpringAnimation(QQuickSpringAnimationPrivate * = nullptr);-
16-
17 ~QSpringAnimation();-
18 int duration() const override;-
19 void restart();-
20 void init();-
21-
22 qreal currentValue;-
23 qreal to;-
24 qreal velocity;-
25 int startTime;-
26 int dura;-
27 int lastTime;-
28 int stopTime;-
29 enum Mode {-
30 Track,-
31 Velocity,-
32 Spring-
33 };-
34 Mode mode;-
35 QQmlProperty target;-
36-
37 qreal velocityms;-
38 qreal maxVelocity;-
39 qreal mass;-
40 qreal spring;-
41 qreal damping;-
42 qreal epsilon;-
43 qreal modulus;-
44-
45 bool useMass : 1;-
46 bool haveModulus : 1;-
47 bool skipUpdate : 1;-
48 typedef QHash<QQmlProperty, QSpringAnimation*> ActiveAnimationHash;-
49 typedef ActiveAnimationHash::Iterator ActiveAnimationHashIt;-
50-
51 void clearTemplate() { animationTemplate = nullptr; }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
4
52-
53protected:-
54 void updateCurrentTime(int time) override;-
55 void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;-
56 void debugAnimation(QDebug d) const override;-
57-
58private:-
59 QQuickSpringAnimationPrivate *animationTemplate;-
60};-
61-
62class QQuickSpringAnimationPrivate : public QQuickPropertyAnimationPrivate-
63{-
64 inline QQuickSpringAnimation* q_func() { return static_cast<QQuickSpringAnimation *>(q_ptr); } inline const QQuickSpringAnimation* q_func() const { return static_cast<const QQuickSpringAnimation *>(q_ptr); } friend class QQuickSpringAnimation;-
65public:-
66 QQuickSpringAnimationPrivate()-
67 : QQuickPropertyAnimationPrivate()-
68 , velocityms(0)-
69 , maxVelocity(0)-
70 , mass(1.0)-
71 , spring(0.)-
72 , damping(0.)-
73 , epsilon(0.01)-
74 , modulus(0.0)-
75 , useMass(false)-
76 , haveModulus(false)-
77 , mode(QSpringAnimation::Track)-
78 { elapsed.start(); }
executed 56 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
56
79-
80 void updateMode();-
81 qreal velocityms;-
82 qreal maxVelocity;-
83 qreal mass;-
84 qreal spring;-
85 qreal damping;-
86 qreal epsilon;-
87 qreal modulus;-
88-
89 bool useMass : 1;-
90 bool haveModulus : 1;-
91 QSpringAnimation::Mode mode;-
92-
93 QSpringAnimation::ActiveAnimationHash activeAnimations;-
94 QElapsedTimer elapsed;-
95};-
96-
97QSpringAnimation::QSpringAnimation(QQuickSpringAnimationPrivate *priv)-
98 : QAbstractAnimationJob()-
99 , currentValue(0)-
100 , to(0)-
101 , velocity(0)-
102 , startTime(0)-
103 , dura(0)-
104 , lastTime(0)-
105 , stopTime(-1)-
106 , mode(Track)-
107 , velocityms(0)-
108 , maxVelocity(0)-
109 , mass(1.0)-
110 , spring(0.)-
111 , damping(0.)-
112 , epsilon(0.01)-
113 , modulus(0.0)-
114 , useMass(false)-
115 , haveModulus(false)-
116 , skipUpdate(false)-
117 , animationTemplate(priv)-
118{-
119}
executed 26 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
26
120-
121QSpringAnimation::~QSpringAnimation()-
122{-
123 if (animationTemplate
animationTemplateDescription
TRUEevaluated 20 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
) {
4-20
124 if (target.object()
target.object()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 18 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
) {
2-18
125 ActiveAnimationHashIt it = animationTemplate->activeAnimations.find(target);-
126 if (it != animationTemplate->activeAnimations.end()
it != animatio...imations.end()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEnever evaluated
&& it.value() == this
it.value() == thisDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEnever evaluated
)
0-2
127 animationTemplate->activeAnimations.erase(it);
executed 2 times by 1 test: animationTemplate->activeAnimations.erase(it);
Executed by:
  • tst_qquickspringanimation
2
128 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
else {
2
129-
130 for (ActiveAnimationHashIt it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end()
it != animatio...imations.end()Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
FALSEnever evaluated
; ++it) {
0-18
131 if (it.value() == this
it.value() == thisDescription
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
FALSEnever evaluated
) {
0-18
132 animationTemplate->activeAnimations.erase(it);-
133 break;
executed 18 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qquickbehaviors
18
134 }-
135 }
never executed: end of block
0
136 }
executed 18 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
18
137 }-
138}
executed 24 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
24
139-
140int QSpringAnimation::duration() const-
141{-
142 return
executed 606 times by 4 tests: return -1;
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
-1;
executed 606 times by 4 tests: return -1;
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
606
143}-
144-
145void QSpringAnimation::restart()-
146{-
147 if (isRunning()
isRunning()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEnever evaluated
|| (stopTime != -1
stopTime != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(animationTemp...stopTime) < 32Description
TRUEnever evaluated
FALSEnever evaluated
animationTemplate->elapsed.elapsed() - stopTime) < 32
(animationTemp...stopTime) < 32Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0-2
148 skipUpdate = true;-
149 init();-
150 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickbehaviors
else {
2
151 skipUpdate = false;-
152-
153 }
never executed: end of block
0
154}-
155-
156void QSpringAnimation::init()-
157{-
158 lastTime = startTime = 0;-
159 stopTime = -1;-
160}
executed 28 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
28
161-
162void QSpringAnimation::updateCurrentTime(int time)-
163{-
164 if (skipUpdate
skipUpdateDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 574 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
2-574
165 skipUpdate = false;-
166 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickbehaviors
2
167 }-
168-
169 if (mode == Track
mode == TrackDescription
TRUEnever evaluated
FALSEevaluated 574 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
0-574
170 stop();-
171 return;
never executed: return;
0
172 }-
173-
174 int elapsed = time - lastTime;-
175-
176 if (!elapsed
!elapsedDescription
TRUEevaluated 26 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 548 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
26-548
177 return;
executed 26 times by 4 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
26
178-
179 int count = elapsed / 16;-
180-
181 if (mode == Spring
mode == SpringDescription
TRUEevaluated 546 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
) {
2-546
182 if (elapsed < 16
elapsed < 16Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 541 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
5-541
183 return;
executed 5 times by 1 test: return;
Executed by:
  • tst_qquickbehaviors
5
184 lastTime = time - (elapsed - count * 16);-
185 }
executed 541 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
else {
541
186 lastTime = time;-
187 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimations
2
188-
189 qreal srcVal = to;-
190-
191 bool stopped = false;-
192-
193 if (haveModulus
haveModulusDescription
TRUEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 325 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
218-325
194 currentValue = fmod(currentValue, modulus);-
195 srcVal = fmod(srcVal, modulus);-
196 }
executed 218 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
218
197 if (mode == Spring
mode == SpringDescription
TRUEevaluated 541 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
) {
2-541
198-
199-
200 for (int i = 0; i < count
i < countDescription
TRUEevaluated 546 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 541 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
; ++i) {
541-546
201 qreal diff = srcVal - currentValue;-
202 if (haveModulus
haveModulusDescription
TRUEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 328 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
&& qAbs(diff) > modulus / 2
qAbs(diff) > modulus / 2Description
TRUEnever evaluated
FALSEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
) {
0-328
203 if (diff < 0
diff < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
204 diff += modulus;
never executed: diff += modulus;
0
205 else-
206 diff -= modulus;
never executed: diff -= modulus;
0
207 }-
208 if (useMass
useMassDescription
TRUEevaluated 310 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
)
236-310
209 velocity = velocity + (spring * diff - damping * velocity) / mass;
executed 310 times by 2 tests: velocity = velocity + (spring * diff - damping * velocity) / mass;
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
310
210 else-
211 velocity = velocity + spring * diff - damping * velocity;
executed 236 times by 1 test: velocity = velocity + spring * diff - damping * velocity;
Executed by:
  • tst_qquickspringanimation
236
212 if (maxVelocity > 0.
maxVelocity > 0.Description
TRUEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 328 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
218-328
213-
214 if (velocity > maxVelocity
velocity > maxVelocityDescription
TRUEevaluated 136 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
)
82-136
215 velocity = maxVelocity;
executed 136 times by 1 test: velocity = maxVelocity;
Executed by:
  • tst_qquickspringanimation
136
216 else if (velocity < -maxVelocity
velocity < -maxVelocityDescription
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
)
0-82
217 velocity = -maxVelocity;
never executed: velocity = -maxVelocity;
0
218 }
executed 218 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
218
219 currentValue += velocity * 16.0 / 1000.0;-
220 if (haveModulus
haveModulusDescription
TRUEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 328 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
218-328
221 currentValue = fmod(currentValue, modulus);-
222 if (currentValue < 0.0
currentValue < 0.0Description
TRUEnever evaluated
FALSEevaluated 218 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
)
0-218
223 currentValue += modulus;
never executed: currentValue += modulus;
0
224 }
executed 218 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
218
225 }
executed 546 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
546
226 if (qAbs(velocity) < epsilon
qAbs(velocity) < epsilonDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 533 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
&& qAbs(srcVal - currentValue) < epsilon
qAbs(srcVal - ...lue) < epsilonDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEnever evaluated
) {
0-533
227 velocity = 0.0;-
228 currentValue = srcVal;-
229 stopped = true;-
230 }
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
8
231 }
executed 541 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
else {
541
232 qreal moveBy = elapsed * velocityms;-
233 qreal diff = srcVal - currentValue;-
234 if (haveModulus
haveModulusDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
&& qAbs(diff) > modulus / 2
qAbs(diff) > modulus / 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-2
235 if (diff < 0
diff < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
236 diff += modulus;
never executed: diff += modulus;
0
237 else-
238 diff -= modulus;
never executed: diff -= modulus;
0
239 }-
240 if (diff > 0
diff > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
FALSEnever evaluated
) {
0-2
241 currentValue += moveBy;-
242 if (haveModulus
haveModulusDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
)
0-2
243 currentValue = std::fmod(currentValue, modulus);
never executed: currentValue = std::fmod(currentValue, modulus);
0
244 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimations
else {
2
245 currentValue -= moveBy;-
246 if (haveModulus
haveModulusDescription
TRUEnever evaluated
FALSEnever evaluated
&& currentValue < 0.0
currentValue < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
247 currentValue = std::fmod(currentValue, modulus) + modulus;
never executed: currentValue = std::fmod(currentValue, modulus) + modulus;
0
248 }
never executed: end of block
0
249 if (lastTime - startTime >= dura
lastTime - startTime >= duraDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
FALSEnever evaluated
) {
0-2
250 currentValue = to;-
251 stopped = true;-
252 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimations
2
253 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimations
2
254-
255 qreal old_to = to;-
256-
257 QQmlPropertyPrivate::write(target, currentValue,-
258 QQmlPropertyData::BypassInterceptor |-
259 QQmlPropertyData::DontRemoveBinding);-
260-
261 if (stopped
stoppedDescription
TRUEevaluated 10 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 533 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
&& old_to == to
old_to == toDescription
TRUEevaluated 10 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEnever evaluated
) {
0-533
262 if (animationTemplate
animationTemplateDescription
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
)
2-8
263 stopTime = animationTemplate->elapsed.elapsed();
executed 8 times by 3 tests: stopTime = animationTemplate->elapsed.elapsed();
Executed by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
8
264 stop();-
265 }
executed 10 times by 3 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
10
266}
executed 543 times by 3 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
543
267-
268void QSpringAnimation::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State )-
269{-
270 if (newState == QAbstractAnimationJob::Running
newState == QA...onJob::RunningDescription
TRUEevaluated 26 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 10 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
10-26
271 init();
executed 26 times by 4 tests: init();
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
26
272}
executed 36 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
36
273-
274void QSpringAnimation::debugAnimation(QDebug d) const-
275{-
276 d << "SpringAnimationJob(" << hex << (const void *) this << dec << ")" << "velocity:" << maxVelocity-
277 << "spring:" << spring << "damping:" << damping << "epsilon:" << epsilon << "modulus:" << modulus-
278 << "mass:" << mass << "target:" << target.object() << "property:" << target.name()-
279 << "to:" << to << "current velocity:" << velocity;-
280}
never executed: end of block
0
281-
282-
283void QQuickSpringAnimationPrivate::updateMode()-
284{-
285 if (spring == 0.
spring == 0.Description
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickspringanimation
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
&& maxVelocity == 0.
maxVelocity == 0.Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
)
4-54
286 mode = QSpringAnimation::Track;
executed 4 times by 1 test: mode = QSpringAnimation::Track;
Executed by:
  • tst_qquickspringanimation
4
287 else if (spring > 0.
spring > 0.Description
TRUEevaluated 54 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
)
4-54
288 mode = QSpringAnimation::Spring;
executed 54 times by 3 tests: mode = QSpringAnimation::Spring;
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
54
289 else {-
290 mode = QSpringAnimation::Velocity;-
291 for (QSpringAnimation::ActiveAnimationHashIt it = activeAnimations.begin(), end = activeAnimations.end(); it != end
it != endDescription
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
; ++it) {
0-4
292 QSpringAnimation *animation = *it;-
293 animation->startTime = animation->lastTime;-
294 qreal dist = qAbs(animation->currentValue - animation->to);-
295 if (haveModulus
haveModulusDescription
TRUEnever evaluated
FALSEnever evaluated
&& dist > modulus / 2
dist > modulus / 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
296 dist = modulus - fmod(dist, modulus);
never executed: dist = modulus - fmod(dist, modulus);
0
297 animation->dura = dist / velocityms;-
298 }
never executed: end of block
0
299 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
4
300}-
301QQuickSpringAnimation::QQuickSpringAnimation(QObject *parent)-
302: QQuickNumberAnimation(*(new QQuickSpringAnimationPrivate),parent)-
303{-
304}
executed 56 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
56
305-
306QQuickSpringAnimation::~QQuickSpringAnimation()-
307{-
308 QQuickSpringAnimationPrivate * const d = d_func();-
309 for (QSpringAnimation::ActiveAnimationHashIt it = d->activeAnimations.begin(), end = d->activeAnimations.end(); it != end
it != endDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
; ++it)
2-54
310 it.value()->clearTemplate();
executed 2 times by 1 test: it.value()->clearTemplate();
Executed by:
  • tst_qquickspringanimation
2
311}
executed 54 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
54
312qreal QQuickSpringAnimation::velocity() const-
313{-
314 const QQuickSpringAnimationPrivate * const d = d_func();-
315 return
executed 6 times by 1 test: return d->maxVelocity;
Executed by:
  • tst_qquickspringanimation
d->maxVelocity;
executed 6 times by 1 test: return d->maxVelocity;
Executed by:
  • tst_qquickspringanimation
6
316}-
317-
318void QQuickSpringAnimation::setVelocity(qreal velocity)-
319{-
320 QQuickSpringAnimationPrivate * const d = d_func();-
321 d->maxVelocity = velocity;-
322 d->velocityms = velocity / 1000.0;-
323 d->updateMode();-
324}
executed 8 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickspringanimation
8
325qreal QQuickSpringAnimation::spring() const-
326{-
327 const QQuickSpringAnimationPrivate * const d = d_func();-
328 return
executed 6 times by 1 test: return d->spring;
Executed by:
  • tst_qquickspringanimation
d->spring;
executed 6 times by 1 test: return d->spring;
Executed by:
  • tst_qquickspringanimation
6
329}-
330-
331void QQuickSpringAnimation::setSpring(qreal spring)-
332{-
333 QQuickSpringAnimationPrivate * const d = d_func();-
334 d->spring = spring;-
335 d->updateMode();-
336}
executed 50 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
50
337qreal QQuickSpringAnimation::damping() const-
338{-
339 const QQuickSpringAnimationPrivate * const d = d_func();-
340 return
executed 6 times by 1 test: return d->damping;
Executed by:
  • tst_qquickspringanimation
d->damping;
executed 6 times by 1 test: return d->damping;
Executed by:
  • tst_qquickspringanimation
6
341}-
342-
343void QQuickSpringAnimation::setDamping(qreal damping)-
344{-
345 QQuickSpringAnimationPrivate * const d = d_func();-
346 if (damping > 1.
damping > 1.Description
TRUEnever evaluated
FALSEevaluated 50 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
0-50
347 damping = 1.;
never executed: damping = 1.;
0
348-
349 d->damping = damping;-
350}
executed 50 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
50
351qreal QQuickSpringAnimation::epsilon() const-
352{-
353 const QQuickSpringAnimationPrivate * const d = d_func();-
354 return
executed 6 times by 1 test: return d->epsilon;
Executed by:
  • tst_qquickspringanimation
d->epsilon;
executed 6 times by 1 test: return d->epsilon;
Executed by:
  • tst_qquickspringanimation
6
355}-
356-
357void QQuickSpringAnimation::setEpsilon(qreal epsilon)-
358{-
359 QQuickSpringAnimationPrivate * const d = d_func();-
360 d->epsilon = epsilon;-
361}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
4
362qreal QQuickSpringAnimation::modulus() const-
363{-
364 const QQuickSpringAnimationPrivate * const d = d_func();-
365 return
executed 6 times by 1 test: return d->modulus;
Executed by:
  • tst_qquickspringanimation
d->modulus;
executed 6 times by 1 test: return d->modulus;
Executed by:
  • tst_qquickspringanimation
6
366}-
367-
368void QQuickSpringAnimation::setModulus(qreal modulus)-
369{-
370 QQuickSpringAnimationPrivate * const d = d_func();-
371 if (d->modulus != modulus
d->modulus != modulusDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEnever evaluated
) {
0-4
372 d->haveModulus = modulus != 0.0;-
373 d->modulus = modulus;-
374 d->updateMode();-
375 modulusChanged();-
376 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
4
377}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
4
378qreal QQuickSpringAnimation::mass() const-
379{-
380 const QQuickSpringAnimationPrivate * const d = d_func();-
381 return
executed 6 times by 1 test: return d->mass;
Executed by:
  • tst_qquickspringanimation
d->mass;
executed 6 times by 1 test: return d->mass;
Executed by:
  • tst_qquickspringanimation
6
382}-
383-
384void QQuickSpringAnimation::setMass(qreal mass)-
385{-
386 QQuickSpringAnimationPrivate * const d = d_func();-
387 if (d->mass != mass
d->mass != massDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_examples
&& mass > 0.0
mass > 0.0Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEnever evaluated
) {
0-32
388 d->useMass = mass != 1.0;-
389 d->mass = mass;-
390 massChanged();-
391 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquickspringanimation
6
392}
executed 38 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
38
393-
394QAbstractAnimationJob* QQuickSpringAnimation::transition(QQuickStateActions &actions,-
395 QQmlProperties &modified,-
396 TransitionDirection direction,-
397 QObject *defaultTarget)-
398{-
399 QQuickSpringAnimationPrivate * const d = d_func();-
400 (void)direction;;-
401-
402 QContinuingAnimationGroupJob *wrapperGroup = new QContinuingAnimationGroupJob();-
403-
404 QQuickStateActions dataActions = QQuickNumberAnimation::createTransitionActions(actions, modified, defaultTarget);-
405 if (!dataActions.isEmpty()
!dataActions.isEmpty()Description
TRUEevaluated 28 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEnever evaluated
) {
0-28
406 QSet<QAbstractAnimationJob*> anims;-
407 for (int i = 0; i < dataActions.size()
i < dataActions.size()Description
TRUEevaluated 28 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
FALSEevaluated 28 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
; ++i) {
28
408 QSpringAnimation *animation;-
409 bool needsRestart = false;-
410 const QQmlProperty &property = dataActions.at(i).property;-
411 if (d->activeAnimations.contains(property)
d->activeAnima...ains(property)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 26 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
2-26
412 animation = d->activeAnimations[property];-
413 needsRestart = true;-
414 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickbehaviors
else {
2
415 animation = new QSpringAnimation(d);-
416 d->activeAnimations.insert(property, animation);-
417 animation->target = property;-
418 }
executed 26 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
26
419 wrapperGroup->appendAnimation(initInstance(animation));-
420-
421 animation->to = dataActions.at(i).toValue.toReal();-
422 animation->startTime = 0;-
423 animation->velocityms = d->velocityms;-
424 animation->mass = d->mass;-
425 animation->spring = d->spring;-
426 animation->damping = d->damping;-
427 animation->epsilon = d->epsilon;-
428 animation->modulus = d->modulus;-
429 animation->useMass = d->useMass;-
430 animation->haveModulus = d->haveModulus;-
431 animation->mode = d->mode;-
432 animation->dura = -1;-
433 animation->maxVelocity = d->maxVelocity;-
434-
435 if (d->fromIsDefined
d->fromIsDefinedDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 24 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
4-24
436 animation->currentValue = dataActions.at(i).fromValue.toReal();
executed 4 times by 1 test: animation->currentValue = dataActions.at(i).fromValue.toReal();
Executed by:
  • tst_qquickspringanimation
4
437 else-
438 animation->currentValue = property.read().toReal();
executed 24 times by 4 tests: animation->currentValue = property.read().toReal();
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
24
439 if (animation->mode == QSpringAnimation::Velocity
animation->mod...tion::VelocityDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 24 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
4-24
440 qreal dist = qAbs(animation->currentValue - animation->to);-
441 if (d->haveModulus
d->haveModulusDescription
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
&& dist > d->modulus / 2
dist > d->modulus / 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0-4
442 dist = d->modulus - fmod(dist, d->modulus);
never executed: dist = d->modulus - fmod(dist, d->modulus);
0
443 animation->dura = dist / animation->velocityms;-
444 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
4
445-
446 if (needsRestart
needsRestartDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 26 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
)
2-26
447 animation->restart();
executed 2 times by 1 test: animation->restart();
Executed by:
  • tst_qquickbehaviors
2
448 anims.insert(animation);-
449 }
executed 28 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
28
450 const auto copy = d->activeAnimations;-
451 for (QSpringAnimation *anim : copy) {-
452 if (!anims.contains(anim)
!anims.contains(anim)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickspringanimation
FALSEevaluated 28 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
) {
2-28
453 anim->clearTemplate();-
454 d->activeAnimations.remove(anim->target);-
455 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickspringanimation
2
456 }
executed 30 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
30
457 }
executed 28 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
28
458 return
executed 28 times by 4 tests: return wrapperGroup;
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
wrapperGroup;
executed 28 times by 4 tests: return wrapperGroup;
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickspringanimation
28
459}-
460-
461-
462-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0