Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquicktransition.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | class ParallelAnimationWrapper : public QParallelAnimationGroupJob | - | ||||||||||||
10 | { | - | ||||||||||||
11 | public: | - | ||||||||||||
12 | ParallelAnimationWrapper() : QParallelAnimationGroupJob() {} executed 10628 times by 7 tests: end of block Executed by:
| 10628 | ||||||||||||
13 | QQuickTransitionManager *manager; | - | ||||||||||||
14 | - | |||||||||||||
15 | protected: | - | ||||||||||||
16 | void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; | - | ||||||||||||
17 | }; | - | ||||||||||||
18 | - | |||||||||||||
19 | class QQuickTransitionPrivate : public QObjectPrivate | - | ||||||||||||
20 | { | - | ||||||||||||
21 | inline QQuickTransition* q_func() { return static_cast<QQuickTransition *>(q_ptr); } inline const QQuickTransition* q_func() const { return static_cast<const QQuickTransition *>(q_ptr); } friend class QQuickTransition; | - | ||||||||||||
22 | public: | - | ||||||||||||
23 | QQuickTransitionPrivate() | - | ||||||||||||
24 | : fromState(QLatin1String("*")), toState(QLatin1String("*")) | - | ||||||||||||
25 | , runningInstanceCount(0), state(QAbstractAnimationJob::Stopped) | - | ||||||||||||
26 | , reversed(false), reversible(false), enabled(true) | - | ||||||||||||
27 | { | - | ||||||||||||
28 | } executed 2270 times by 9 tests: end of block Executed by:
| 2270 | ||||||||||||
29 | - | |||||||||||||
30 | static QQuickTransitionPrivate *get(QQuickTransition *q) { return executed 19700 times by 7 tests: q->d_func();return q->d_func(); Executed by:
executed 19700 times by 7 tests: }return q->d_func(); Executed by:
| 19700 | ||||||||||||
31 | void animationStateChanged(QAbstractAnimationJob::State newState); | - | ||||||||||||
32 | - | |||||||||||||
33 | QString fromState; | - | ||||||||||||
34 | QString toState; | - | ||||||||||||
35 | quint32 runningInstanceCount; | - | ||||||||||||
36 | QAbstractAnimationJob::State state; | - | ||||||||||||
37 | bool reversed; | - | ||||||||||||
38 | bool reversible; | - | ||||||||||||
39 | bool enabled; | - | ||||||||||||
40 | protected: | - | ||||||||||||
41 | - | |||||||||||||
42 | static void append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a); | - | ||||||||||||
43 | static int animation_count(QQmlListProperty<QQuickAbstractAnimation> *list); | - | ||||||||||||
44 | static QQuickAbstractAnimation* animation_at(QQmlListProperty<QQuickAbstractAnimation> *list, int pos); | - | ||||||||||||
45 | static void clear_animations(QQmlListProperty<QQuickAbstractAnimation> *list); | - | ||||||||||||
46 | QList<QQuickAbstractAnimation *> animations; | - | ||||||||||||
47 | }; | - | ||||||||||||
48 | - | |||||||||||||
49 | void QQuickTransitionPrivate::append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a) | - | ||||||||||||
50 | { | - | ||||||||||||
51 | QQuickTransition *q = static_cast<QQuickTransition *>(list->object); | - | ||||||||||||
52 | q->d_func()->animations.append(a); | - | ||||||||||||
53 | a->setDisableUserControl(); | - | ||||||||||||
54 | } executed 1158 times by 8 tests: end of block Executed by:
| 1158 | ||||||||||||
55 | - | |||||||||||||
56 | int QQuickTransitionPrivate::animation_count(QQmlListProperty<QQuickAbstractAnimation> *list) | - | ||||||||||||
57 | { | - | ||||||||||||
58 | QQuickTransition *q = static_cast<QQuickTransition *>(list->object); | - | ||||||||||||
59 | return never executed: q->d_func()->animations.count();return q->d_func()->animations.count(); never executed: return q->d_func()->animations.count(); | 0 | ||||||||||||
60 | } | - | ||||||||||||
61 | - | |||||||||||||
62 | QQuickAbstractAnimation* QQuickTransitionPrivate::animation_at(QQmlListProperty<QQuickAbstractAnimation> *list, int pos) | - | ||||||||||||
63 | { | - | ||||||||||||
64 | QQuickTransition *q = static_cast<QQuickTransition *>(list->object); | - | ||||||||||||
65 | return never executed: q->d_func()->animations.at(pos);return q->d_func()->animations.at(pos); never executed: return q->d_func()->animations.at(pos); | 0 | ||||||||||||
66 | } | - | ||||||||||||
67 | - | |||||||||||||
68 | void QQuickTransitionPrivate::clear_animations(QQmlListProperty<QQuickAbstractAnimation> *list) | - | ||||||||||||
69 | { | - | ||||||||||||
70 | QQuickTransition *q = static_cast<QQuickTransition *>(list->object); | - | ||||||||||||
71 | while (q->d_func()->animations.count()
| 0 | ||||||||||||
72 | QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0); | - | ||||||||||||
73 | q->d_func()->animations.removeAll(firstAnim); | - | ||||||||||||
74 | } never executed: end of block | 0 | ||||||||||||
75 | } never executed: end of block | 0 | ||||||||||||
76 | - | |||||||||||||
77 | void QQuickTransitionInstance::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State) | - | ||||||||||||
78 | { | - | ||||||||||||
79 | if (!m_transition
| 0-19700 | ||||||||||||
80 | return; never executed: return; | 0 | ||||||||||||
81 | - | |||||||||||||
82 | QQuickTransitionPrivate *transition = QQuickTransitionPrivate::get(m_transition); | - | ||||||||||||
83 | transition->animationStateChanged(newState); | - | ||||||||||||
84 | } executed 19700 times by 7 tests: end of block Executed by:
| 19700 | ||||||||||||
85 | - | |||||||||||||
86 | void QQuickTransitionPrivate::animationStateChanged(QAbstractAnimationJob::State newState) | - | ||||||||||||
87 | { | - | ||||||||||||
88 | QQuickTransition * const q = q_func(); | - | ||||||||||||
89 | - | |||||||||||||
90 | if (newState == QAbstractAnimationJob::Running
| 9072-10628 | ||||||||||||
91 | runningInstanceCount++; | - | ||||||||||||
92 | if (runningInstanceCount == 1
| 1330-9298 | ||||||||||||
93 | q->runningChanged(); executed 1330 times by 7 tests: q->runningChanged(); Executed by:
| 1330 | ||||||||||||
94 | } executed 10628 times by 7 tests: else if (newState == QAbstractAnimationJob::Stoppedend of block Executed by:
| 0-10628 | ||||||||||||
95 | runningInstanceCount--; | - | ||||||||||||
96 | if (runningInstanceCount == 0
| 1132-7940 | ||||||||||||
97 | q->runningChanged(); executed 1132 times by 5 tests: q->runningChanged(); Executed by:
| 1132 | ||||||||||||
98 | } executed 9072 times by 5 tests: end of block Executed by:
| 9072 | ||||||||||||
99 | } executed 19700 times by 7 tests: end of block Executed by:
| 19700 | ||||||||||||
100 | - | |||||||||||||
101 | void ParallelAnimationWrapper::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) | - | ||||||||||||
102 | { | - | ||||||||||||
103 | QParallelAnimationGroupJob::updateState(newState, oldState); | - | ||||||||||||
104 | if (newState == Stopped
| 6-10628 | ||||||||||||
105 | || (direction() == QAbstractAnimationJob::Forward
| 2-9150 | ||||||||||||
106 | || (direction() == QAbstractAnimationJob::Backward
| 0-268 | ||||||||||||
107 | { | - | ||||||||||||
108 | manager->complete(); | - | ||||||||||||
109 | } executed 8890 times by 5 tests: end of block Executed by:
| 8890 | ||||||||||||
110 | } executed 19786 times by 7 tests: end of block Executed by:
| 19786 | ||||||||||||
111 | - | |||||||||||||
112 | QQuickTransitionInstance::QQuickTransitionInstance(QQuickTransition *transition, QAbstractAnimationJob *anim) | - | ||||||||||||
113 | : m_transition(transition) | - | ||||||||||||
114 | , m_anim(anim) | - | ||||||||||||
115 | { | - | ||||||||||||
116 | anim->addAnimationChangeListener(this, QAbstractAnimationJob::StateChange); | - | ||||||||||||
117 | } executed 10628 times by 7 tests: end of block Executed by:
| 10628 | ||||||||||||
118 | - | |||||||||||||
119 | QQuickTransitionInstance::~QQuickTransitionInstance() | - | ||||||||||||
120 | { | - | ||||||||||||
121 | removeStateChangeListener(); | - | ||||||||||||
122 | delete m_anim; | - | ||||||||||||
123 | } executed 10590 times by 7 tests: end of block Executed by:
| 10590 | ||||||||||||
124 | - | |||||||||||||
125 | void QQuickTransitionInstance::start() | - | ||||||||||||
126 | { | - | ||||||||||||
127 | if (m_anim
| 0-10628 | ||||||||||||
128 | m_anim->start(); executed 10628 times by 7 tests: m_anim->start(); Executed by:
| 10628 | ||||||||||||
129 | } executed 10628 times by 7 tests: end of block Executed by:
| 10628 | ||||||||||||
130 | - | |||||||||||||
131 | void QQuickTransitionInstance::stop() | - | ||||||||||||
132 | { | - | ||||||||||||
133 | if (m_anim
| 0-276 | ||||||||||||
134 | m_anim->stop(); executed 276 times by 4 tests: m_anim->stop(); Executed by:
| 276 | ||||||||||||
135 | } executed 276 times by 4 tests: end of block Executed by:
| 276 | ||||||||||||
136 | - | |||||||||||||
137 | bool QQuickTransitionInstance::isRunning() const | - | ||||||||||||
138 | { | - | ||||||||||||
139 | return executed 9898 times by 5 tests: m_anim && m_anim->state() == QAbstractAnimationJob::Running;return m_anim && m_anim->state() == QAbstractAnimationJob::Running; Executed by:
executed 9898 times by 5 tests: return m_anim && m_anim->state() == QAbstractAnimationJob::Running; Executed by:
| 9898 | ||||||||||||
140 | } | - | ||||||||||||
141 | - | |||||||||||||
142 | QQuickTransition::QQuickTransition(QObject *parent) | - | ||||||||||||
143 | : QObject(*(new QQuickTransitionPrivate), parent) | - | ||||||||||||
144 | { | - | ||||||||||||
145 | } executed 2270 times by 9 tests: end of block Executed by:
| 2270 | ||||||||||||
146 | - | |||||||||||||
147 | QQuickTransition::~QQuickTransition() | - | ||||||||||||
148 | { | - | ||||||||||||
149 | } | - | ||||||||||||
150 | - | |||||||||||||
151 | void QQuickTransition::setReversed(bool r) | - | ||||||||||||
152 | { | - | ||||||||||||
153 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
154 | d->reversed = r; | - | ||||||||||||
155 | } executed 72 times by 3 tests: end of block Executed by:
| 72 | ||||||||||||
156 | - | |||||||||||||
157 | QQuickTransitionInstance *QQuickTransition::prepare(QQuickStateOperation::ActionList &actions, | - | ||||||||||||
158 | QList<QQmlProperty> &after, | - | ||||||||||||
159 | QQuickTransitionManager *manager, | - | ||||||||||||
160 | QObject *defaultTarget) | - | ||||||||||||
161 | { | - | ||||||||||||
162 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
163 | - | |||||||||||||
164 | qmlExecuteDeferred(this); | - | ||||||||||||
165 | - | |||||||||||||
166 | ParallelAnimationWrapper *group = new ParallelAnimationWrapper(); | - | ||||||||||||
167 | group->manager = manager; | - | ||||||||||||
168 | - | |||||||||||||
169 | QQuickAbstractAnimation::TransitionDirection direction = d->reversed
| 2-10626 | ||||||||||||
170 | int start = d->reversed
| 2-10626 | ||||||||||||
171 | int end = d->reversed
| 2-10626 | ||||||||||||
172 | - | |||||||||||||
173 | QAbstractAnimationJob *anim = nullptr; | - | ||||||||||||
174 | for (int i = start; i != end
| 10628-10638 | ||||||||||||
175 | anim = d->animations.at(i)->transition(actions, after, direction, defaultTarget); | - | ||||||||||||
176 | if (anim
| 0-10638 | ||||||||||||
177 | if (d->animations.at(i)->threadingModel() == QQuickAbstractAnimation::RenderThread
| 0-10638 | ||||||||||||
178 | anim = new QQuickAnimatorProxyJob(anim, d->animations.at(i)); never executed: anim = new QQuickAnimatorProxyJob(anim, d->animations.at(i)); | 0 | ||||||||||||
179 | d->reversed ? group->prependAnimation(anim) : group->appendAnimation(anim); | - | ||||||||||||
180 | } executed 10638 times by 7 tests: end of block Executed by:
| 10638 | ||||||||||||
181 | d->reversed ? --i : ++i; | - | ||||||||||||
182 | } executed 10638 times by 7 tests: end of block Executed by:
| 10638 | ||||||||||||
183 | - | |||||||||||||
184 | group->setDirection(d->reversed ? QAbstractAnimationJob::Backward : QAbstractAnimationJob::Forward); | - | ||||||||||||
185 | - | |||||||||||||
186 | QQuickTransitionInstance *wrapper = new QQuickTransitionInstance(this, group); | - | ||||||||||||
187 | return executed 10628 times by 7 tests: wrapper;return wrapper; Executed by:
executed 10628 times by 7 tests: return wrapper; Executed by:
| 10628 | ||||||||||||
188 | } | - | ||||||||||||
189 | QString QQuickTransition::fromState() const | - | ||||||||||||
190 | { | - | ||||||||||||
191 | const QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
192 | return executed 96 times by 4 tests: d->fromState;return d->fromState; Executed by:
executed 96 times by 4 tests: return d->fromState; Executed by:
| 96 | ||||||||||||
193 | } | - | ||||||||||||
194 | - | |||||||||||||
195 | void QQuickTransition::setFromState(const QString &f) | - | ||||||||||||
196 | { | - | ||||||||||||
197 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
198 | if (f == d->fromState
| 6-22 | ||||||||||||
199 | return; executed 6 times by 2 tests: return; Executed by:
| 6 | ||||||||||||
200 | - | |||||||||||||
201 | d->fromState = f; | - | ||||||||||||
202 | fromChanged(); | - | ||||||||||||
203 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||
204 | bool QQuickTransition::reversible() const | - | ||||||||||||
205 | { | - | ||||||||||||
206 | const QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
207 | return executed 84 times by 4 tests: d->reversible;return d->reversible; Executed by:
executed 84 times by 4 tests: return d->reversible; Executed by:
| 84 | ||||||||||||
208 | } | - | ||||||||||||
209 | - | |||||||||||||
210 | void QQuickTransition::setReversible(bool r) | - | ||||||||||||
211 | { | - | ||||||||||||
212 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
213 | if (r == d->reversible
| 0-6 | ||||||||||||
214 | return; never executed: return; | 0 | ||||||||||||
215 | - | |||||||||||||
216 | d->reversible = r; | - | ||||||||||||
217 | reversibleChanged(); | - | ||||||||||||
218 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||
219 | - | |||||||||||||
220 | QString QQuickTransition::toState() const | - | ||||||||||||
221 | { | - | ||||||||||||
222 | const QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
223 | return executed 96 times by 4 tests: d->toState;return d->toState; Executed by:
executed 96 times by 4 tests: return d->toState; Executed by:
| 96 | ||||||||||||
224 | } | - | ||||||||||||
225 | - | |||||||||||||
226 | void QQuickTransition::setToState(const QString &t) | - | ||||||||||||
227 | { | - | ||||||||||||
228 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
229 | if (t == d->toState
| 2-40 | ||||||||||||
230 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||
231 | - | |||||||||||||
232 | d->toState = t; | - | ||||||||||||
233 | toChanged(); | - | ||||||||||||
234 | } executed 40 times by 3 tests: end of block Executed by:
| 40 | ||||||||||||
235 | bool QQuickTransition::enabled() const | - | ||||||||||||
236 | { | - | ||||||||||||
237 | const QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
238 | return executed 28380 times by 8 tests: d->enabled;return d->enabled; Executed by:
executed 28380 times by 8 tests: return d->enabled; Executed by:
| 28380 | ||||||||||||
239 | } | - | ||||||||||||
240 | - | |||||||||||||
241 | void QQuickTransition::setEnabled(bool enabled) | - | ||||||||||||
242 | { | - | ||||||||||||
243 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
244 | if (d->enabled == enabled
| 394-460 | ||||||||||||
245 | return; executed 394 times by 4 tests: return; Executed by:
| 394 | ||||||||||||
246 | d->enabled = enabled; | - | ||||||||||||
247 | enabledChanged(); | - | ||||||||||||
248 | } executed 460 times by 4 tests: end of block Executed by:
| 460 | ||||||||||||
249 | bool QQuickTransition::running() const | - | ||||||||||||
250 | { | - | ||||||||||||
251 | const QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
252 | return executed 20 times by 3 tests: d->runningInstanceCount;return d->runningInstanceCount; Executed by:
executed 20 times by 3 tests: return d->runningInstanceCount; Executed by:
| 20 | ||||||||||||
253 | } | - | ||||||||||||
254 | QQmlListProperty<QQuickAbstractAnimation> QQuickTransition::animations() | - | ||||||||||||
255 | { | - | ||||||||||||
256 | QQuickTransitionPrivate * const d = d_func(); | - | ||||||||||||
257 | return executed 1152 times by 8 tests: QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation,return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation, QQuickTransitionPrivate::animation_count, QQuickTransitionPrivate::animation_at, QQuickTransitionPrivate::clear_animations); Executed by:
executed 1152 times by 8 tests: return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation, QQuickTransitionPrivate::animation_count, QQuickTransitionPrivate::animation_at, QQuickTransitionPrivate::clear_animations); Executed by:
| 1152 | ||||||||||||
258 | QQuickTransitionPrivate::animation_count, executed 1152 times by 8 tests: return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation, QQuickTransitionPrivate::animation_count, QQuickTransitionPrivate::animation_at, QQuickTransitionPrivate::clear_animations); Executed by:
| 1152 | ||||||||||||
259 | QQuickTransitionPrivate::animation_at, executed 1152 times by 8 tests: return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation, QQuickTransitionPrivate::animation_count, QQuickTransitionPrivate::animation_at, QQuickTransitionPrivate::clear_animations); Executed by:
| 1152 | ||||||||||||
260 | QQuickTransitionPrivate::clear_animations); executed 1152 times by 8 tests: return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation, QQuickTransitionPrivate::animation_count, QQuickTransitionPrivate::animation_at, QQuickTransitionPrivate::clear_animations); Executed by:
| 1152 | ||||||||||||
261 | } | - | ||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
Switch to Source code | Preprocessed file |