Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickstate.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 QtQuick 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 | #include "qquickstate_p_p.h" | - | ||||||||||||||||||||||||
41 | #include "qquickstate_p.h" | - | ||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | #include "qquickstategroup_p.h" | - | ||||||||||||||||||||||||
44 | #include "qquickstatechangescript_p.h" | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); never executed: status = Yes; never executed: end of block executed 40 times by 20 tests: end of block Executed by:
executed 588 times by 20 tests: return status == Yes; Executed by:
| 0-588 | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | QQuickStateAction::QQuickStateAction() | - | ||||||||||||||||||||||||
55 | : restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(nullptr), event(nullptr), | - | ||||||||||||||||||||||||
56 | specifiedObject(nullptr) | - | ||||||||||||||||||||||||
57 | { | - | ||||||||||||||||||||||||
58 | } executed 22093 times by 28 tests: end of block Executed by:
| 22093 | ||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||
60 | QQuickStateAction::QQuickStateAction(QObject *target, const QString &propertyName, | - | ||||||||||||||||||||||||
61 | const QVariant &value) | - | ||||||||||||||||||||||||
62 | : restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), | - | ||||||||||||||||||||||||
63 | property(target, propertyName, qmlEngine(target)), toValue(value), | - | ||||||||||||||||||||||||
64 | fromBinding(nullptr), event(nullptr), | - | ||||||||||||||||||||||||
65 | specifiedObject(target), specifiedProperty(propertyName) | - | ||||||||||||||||||||||||
66 | { | - | ||||||||||||||||||||||||
67 | if (property.isValid())
| 0-21298 | ||||||||||||||||||||||||
68 | fromValue = property.read(); executed 21298 times by 8 tests: fromValue = property.read(); Executed by:
| 21298 | ||||||||||||||||||||||||
69 | } executed 21298 times by 8 tests: end of block Executed by:
| 21298 | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | QQuickStateAction::QQuickStateAction(QObject *target, const QQmlProperty &property, const QString &propertyName, const QVariant &value) | - | ||||||||||||||||||||||||
72 | : restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), | - | ||||||||||||||||||||||||
73 | property(property), toValue(value), | - | ||||||||||||||||||||||||
74 | fromBinding(nullptr), event(nullptr), | - | ||||||||||||||||||||||||
75 | specifiedObject(target), specifiedProperty(propertyName) | - | ||||||||||||||||||||||||
76 | { | - | ||||||||||||||||||||||||
77 | if (property.isValid())
| 6-480 | ||||||||||||||||||||||||
78 | fromValue = property.read(); executed 480 times by 10 tests: fromValue = property.read(); Executed by:
| 480 | ||||||||||||||||||||||||
79 | } executed 486 times by 10 tests: end of block Executed by:
| 486 | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | QQuickStateActionEvent::~QQuickStateActionEvent() | - | ||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||
84 | } | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | void QQuickStateActionEvent::execute() | - | ||||||||||||||||||||||||
87 | { | - | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | bool QQuickStateActionEvent::isReversable() | - | ||||||||||||||||||||||||
91 | { | - | ||||||||||||||||||||||||
92 | return false; executed 16 times by 2 tests: return false; Executed by:
| 16 | ||||||||||||||||||||||||
93 | } | - | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | void QQuickStateActionEvent::reverse() | - | ||||||||||||||||||||||||
96 | { | - | ||||||||||||||||||||||||
97 | } | - | ||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||
99 | bool QQuickStateActionEvent::changesBindings() | - | ||||||||||||||||||||||||
100 | { | - | ||||||||||||||||||||||||
101 | return false; executed 350 times by 5 tests: return false; Executed by:
| 350 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | void QQuickStateActionEvent::clearBindings() | - | ||||||||||||||||||||||||
105 | { | - | ||||||||||||||||||||||||
106 | } | - | ||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | bool QQuickStateActionEvent::mayOverride(QQuickStateActionEvent *other) | - | ||||||||||||||||||||||||
109 | { | - | ||||||||||||||||||||||||
110 | Q_UNUSED(other); | - | ||||||||||||||||||||||||
111 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
112 | } | - | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | QQuickStateOperation::QQuickStateOperation(QObjectPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||
115 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
116 | { | - | ||||||||||||||||||||||||
117 | } executed 624 times by 18 tests: end of block Executed by:
| 624 | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | /*! | - | ||||||||||||||||||||||||
120 | \qmltype State | - | ||||||||||||||||||||||||
121 | \instantiates QQuickState | - | ||||||||||||||||||||||||
122 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
123 | \ingroup qtquick-states | - | ||||||||||||||||||||||||
124 | \brief Defines configurations of objects and properties. | - | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | A \e state is a set of batched changes from the default configuration. | - | ||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | All items have a default state that defines the default configuration of objects | - | ||||||||||||||||||||||||
129 | and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to | - | ||||||||||||||||||||||||
130 | allow items to switch between different configurations. These configurations | - | ||||||||||||||||||||||||
131 | can, for example, be used to apply different sets of property values or execute | - | ||||||||||||||||||||||||
132 | different scripts. | - | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | The following example displays a single \l Rectangle. In the default state, the rectangle | - | ||||||||||||||||||||||||
135 | is colored black. In the "clicked" state, a PropertyChanges object changes the | - | ||||||||||||||||||||||||
136 | rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state | - | ||||||||||||||||||||||||
137 | between the default state and the "clicked" state, thus toggling the color of the | - | ||||||||||||||||||||||||
138 | rectangle between black and red. | - | ||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | \snippet qml/state.qml 0 | - | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | Notice the default state is referred to using an empty string (""). | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | States are commonly used together with \l{Animation and Transitions in Qt Quick}{Transitions} to provide | - | ||||||||||||||||||||||||
145 | animations when state changes occur. | - | ||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | \note Setting the state of an object from within another state of the same object is | - | ||||||||||||||||||||||||
148 | not allowed. | - | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | \sa {Qt Quick Examples - Animation#States}{States example}, {Qt Quick States}, | - | ||||||||||||||||||||||||
151 | {Animation and Transitions in Qt Quick}{Transitions}, {Qt QML} | - | ||||||||||||||||||||||||
152 | */ | - | ||||||||||||||||||||||||
153 | QQuickState::QQuickState(QObject *parent) | - | ||||||||||||||||||||||||
154 | : QObject(*(new QQuickStatePrivate), parent) | - | ||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||
156 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
157 | d->transitionManager.setState(this); | - | ||||||||||||||||||||||||
158 | } executed 1522 times by 20 tests: end of block Executed by:
| 1522 | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | QQuickState::~QQuickState() | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
163 | if (d->group)
| 244-1046 | ||||||||||||||||||||||||
164 | d->group->removeState(this); executed 244 times by 20 tests: d->group->removeState(this); Executed by:
| 244 | ||||||||||||||||||||||||
165 | } executed 1290 times by 20 tests: end of block Executed by:
| 1290 | ||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | /*! | - | ||||||||||||||||||||||||
168 | \qmlproperty string QtQuick::State::name | - | ||||||||||||||||||||||||
169 | This property holds the name of the state. | - | ||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||
171 | Each state should have a unique name within its item. | - | ||||||||||||||||||||||||
172 | */ | - | ||||||||||||||||||||||||
173 | QString QQuickState::name() const | - | ||||||||||||||||||||||||
174 | { | - | ||||||||||||||||||||||||
175 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
176 | return d->name; executed 1784 times by 19 tests: return d->name; Executed by:
| 1784 | ||||||||||||||||||||||||
177 | } | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | void QQuickState::setName(const QString &n) | - | ||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||
181 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
182 | d->name = n; | - | ||||||||||||||||||||||||
183 | d->named = true; | - | ||||||||||||||||||||||||
184 | } executed 1172 times by 19 tests: end of block Executed by:
| 1172 | ||||||||||||||||||||||||
185 | - | |||||||||||||||||||||||||
186 | bool QQuickState::isNamed() const | - | ||||||||||||||||||||||||
187 | { | - | ||||||||||||||||||||||||
188 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
189 | return d->named; executed 1796 times by 18 tests: return d->named; Executed by:
| 1796 | ||||||||||||||||||||||||
190 | } | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | bool QQuickState::isWhenKnown() const | - | ||||||||||||||||||||||||
193 | { | - | ||||||||||||||||||||||||
194 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
195 | return d->when != nullptr; executed 1224 times by 18 tests: return d->when != nullptr; Executed by:
| 1224 | ||||||||||||||||||||||||
196 | } | - | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | /*! | - | ||||||||||||||||||||||||
199 | \qmlproperty bool QtQuick::State::when | - | ||||||||||||||||||||||||
200 | This property holds when the state should be applied. | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | This should be set to an expression that evaluates to \c true when you want the state to | - | ||||||||||||||||||||||||
203 | be applied. For example, the following \l Rectangle changes in and out of the "hidden" | - | ||||||||||||||||||||||||
204 | state when the \l MouseArea is pressed: | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | \snippet qml/state-when.qml 0 | - | ||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||
208 | If multiple states in a group have \c when clauses that evaluate to \c true | - | ||||||||||||||||||||||||
209 | at the same time, the first matching state will be applied. For example, in | - | ||||||||||||||||||||||||
210 | the following snippet \c state1 will always be selected rather than | - | ||||||||||||||||||||||||
211 | \c state2 when sharedCondition becomes \c true. | - | ||||||||||||||||||||||||
212 | \qml | - | ||||||||||||||||||||||||
213 | Item { | - | ||||||||||||||||||||||||
214 | states: [ | - | ||||||||||||||||||||||||
215 | State { name: "state1"; when: sharedCondition }, | - | ||||||||||||||||||||||||
216 | State { name: "state2"; when: sharedCondition } | - | ||||||||||||||||||||||||
217 | ] | - | ||||||||||||||||||||||||
218 | // ... | - | ||||||||||||||||||||||||
219 | } | - | ||||||||||||||||||||||||
220 | \endqml | - | ||||||||||||||||||||||||
221 | */ | - | ||||||||||||||||||||||||
222 | QQmlBinding *QQuickState::when() const | - | ||||||||||||||||||||||||
223 | { | - | ||||||||||||||||||||||||
224 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
225 | return d->when.data(); executed 1260 times by 8 tests: return d->when.data(); Executed by:
| 1260 | ||||||||||||||||||||||||
226 | } | - | ||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | void QQuickState::setWhen(QQmlBinding *when) | - | ||||||||||||||||||||||||
229 | { | - | ||||||||||||||||||||||||
230 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
231 | d->when = when; | - | ||||||||||||||||||||||||
232 | if (d->group)
| 0-624 | ||||||||||||||||||||||||
233 | d->group->updateAutoState(); executed 624 times by 8 tests: d->group->updateAutoState(); Executed by:
| 624 | ||||||||||||||||||||||||
234 | } executed 624 times by 8 tests: end of block Executed by:
| 624 | ||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | /*! | - | ||||||||||||||||||||||||
237 | \qmlproperty string QtQuick::State::extend | - | ||||||||||||||||||||||||
238 | This property holds the state that this state extends. | - | ||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||
240 | When a state extends another state, it inherits all the changes of that state. | - | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | The state being extended is treated as the base state in regards to | - | ||||||||||||||||||||||||
243 | the changes specified by the extending state. | - | ||||||||||||||||||||||||
244 | */ | - | ||||||||||||||||||||||||
245 | QString QQuickState::extends() const | - | ||||||||||||||||||||||||
246 | { | - | ||||||||||||||||||||||||
247 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
248 | return d->extends; executed 4 times by 1 test: return d->extends; Executed by:
| 4 | ||||||||||||||||||||||||
249 | } | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | void QQuickState::setExtends(const QString &extends) | - | ||||||||||||||||||||||||
252 | { | - | ||||||||||||||||||||||||
253 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
254 | d->extends = extends; | - | ||||||||||||||||||||||||
255 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
256 | - | |||||||||||||||||||||||||
257 | /*! | - | ||||||||||||||||||||||||
258 | \qmlproperty list<Change> QtQuick::State::changes | - | ||||||||||||||||||||||||
259 | This property holds the changes to apply for this state | - | ||||||||||||||||||||||||
260 | \default | - | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | By default these changes are applied against the default state. If the state | - | ||||||||||||||||||||||||
263 | extends another state, then the changes are applied against the state being | - | ||||||||||||||||||||||||
264 | extended. | - | ||||||||||||||||||||||||
265 | */ | - | ||||||||||||||||||||||||
266 | QQmlListProperty<QQuickStateOperation> QQuickState::changes() | - | ||||||||||||||||||||||||
267 | { | - | ||||||||||||||||||||||||
268 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
269 | return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append, executed 370 times by 18 tests: return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append, QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at, QQuickStatePrivate::operations_clear); Executed by:
| 370 | ||||||||||||||||||||||||
270 | QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at, executed 370 times by 18 tests: return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append, QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at, QQuickStatePrivate::operations_clear); Executed by:
| 370 | ||||||||||||||||||||||||
271 | QQuickStatePrivate::operations_clear); executed 370 times by 18 tests: return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append, QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at, QQuickStatePrivate::operations_clear); Executed by:
| 370 | ||||||||||||||||||||||||
272 | } | - | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | int QQuickState::operationCount() const | - | ||||||||||||||||||||||||
275 | { | - | ||||||||||||||||||||||||
276 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
277 | return d->operations.count(); executed 6 times by 2 tests: return d->operations.count(); Executed by:
| 6 | ||||||||||||||||||||||||
278 | } | - | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | QQuickStateOperation *QQuickState::operationAt(int index) const | - | ||||||||||||||||||||||||
281 | { | - | ||||||||||||||||||||||||
282 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
283 | return d->operations.at(index); executed 18 times by 1 test: return d->operations.at(index); Executed by:
| 18 | ||||||||||||||||||||||||
284 | } | - | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | QQuickState &QQuickState::operator<<(QQuickStateOperation *op) | - | ||||||||||||||||||||||||
287 | { | - | ||||||||||||||||||||||||
288 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
289 | d->operations.append(QQuickStatePrivate::OperationGuard(op, &d->operations)); | - | ||||||||||||||||||||||||
290 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
291 | } | - | ||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | void QQuickStatePrivate::complete() | - | ||||||||||||||||||||||||
294 | { | - | ||||||||||||||||||||||||
295 | Q_Q(QQuickState); | - | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | for (int ii = 0; ii < reverting.count(); ++ii) {
| 162-574 | ||||||||||||||||||||||||
298 | for (int jj = 0; jj < revertList.count(); ++jj) {
| 0-164 | ||||||||||||||||||||||||
299 | const QQuickRevertAction &revert = reverting.at(ii); | - | ||||||||||||||||||||||||
300 | const QQuickSimpleAction &simple = revertList.at(jj); | - | ||||||||||||||||||||||||
301 | if ((revert.event && simple.event() == revert.event) ||
| 0-124 | ||||||||||||||||||||||||
302 | simple.property() == revert.property) {
| 2-122 | ||||||||||||||||||||||||
303 | revertList.removeAt(jj); | - | ||||||||||||||||||||||||
304 | break; executed 162 times by 12 tests: break; Executed by:
| 162 | ||||||||||||||||||||||||
305 | } | - | ||||||||||||||||||||||||
306 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
307 | } executed 162 times by 12 tests: end of block Executed by:
| 162 | ||||||||||||||||||||||||
308 | reverting.clear(); | - | ||||||||||||||||||||||||
309 | - | |||||||||||||||||||||||||
310 | if (group)
| 0-574 | ||||||||||||||||||||||||
311 | group->stateAboutToComplete(); executed 574 times by 19 tests: group->stateAboutToComplete(); Executed by:
| 574 | ||||||||||||||||||||||||
312 | emit q->completed(); | - | ||||||||||||||||||||||||
313 | } executed 574 times by 19 tests: end of block Executed by:
| 574 | ||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||
315 | // Generate a list of actions for this state. This includes coelescing state | - | ||||||||||||||||||||||||
316 | // actions that this state "extends" | - | ||||||||||||||||||||||||
317 | QQuickStateOperation::ActionList | - | ||||||||||||||||||||||||
318 | QQuickStatePrivate::generateActionList() const | - | ||||||||||||||||||||||||
319 | { | - | ||||||||||||||||||||||||
320 | QQuickStateOperation::ActionList applyList; | - | ||||||||||||||||||||||||
321 | if (inState)
| 0-602 | ||||||||||||||||||||||||
322 | return applyList; never executed: return applyList; | 0 | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | // Prevent "extends" recursion | - | ||||||||||||||||||||||||
325 | inState = true; | - | ||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | if (!extends.isEmpty()) {
| 14-588 | ||||||||||||||||||||||||
328 | QList<QQuickState *> states = group ? group->states() : QList<QQuickState *>();
| 0-14 | ||||||||||||||||||||||||
329 | for (int ii = 0; ii < states.count(); ++ii)
| 14-28 | ||||||||||||||||||||||||
330 | if (states.at(ii)->name() == extends) {
| 14 | ||||||||||||||||||||||||
331 | qmlExecuteDeferred(states.at(ii)); | - | ||||||||||||||||||||||||
332 | applyList = static_cast<QQuickStatePrivate*>(states.at(ii)->d_func())->generateActionList(); | - | ||||||||||||||||||||||||
333 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
334 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||
336 | for (QQuickStateOperation *op : operations) | - | ||||||||||||||||||||||||
337 | applyList << op->actions(); executed 710 times by 18 tests: applyList << op->actions(); Executed by:
| 710 | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | inState = false; | - | ||||||||||||||||||||||||
340 | return applyList; executed 602 times by 20 tests: return applyList; Executed by:
| 602 | ||||||||||||||||||||||||
341 | } | - | ||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | QQuickStateGroup *QQuickState::stateGroup() const | - | ||||||||||||||||||||||||
344 | { | - | ||||||||||||||||||||||||
345 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
346 | return d->group; executed 174 times by 3 tests: return d->group; Executed by:
| 174 | ||||||||||||||||||||||||
347 | } | - | ||||||||||||||||||||||||
348 | - | |||||||||||||||||||||||||
349 | void QQuickState::setStateGroup(QQuickStateGroup *group) | - | ||||||||||||||||||||||||
350 | { | - | ||||||||||||||||||||||||
351 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
352 | d->group = group; | - | ||||||||||||||||||||||||
353 | } executed 2556 times by 20 tests: end of block Executed by:
| 2556 | ||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | void QQuickState::cancel() | - | ||||||||||||||||||||||||
356 | { | - | ||||||||||||||||||||||||
357 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
358 | d->transitionManager.cancel(); | - | ||||||||||||||||||||||||
359 | } executed 1176 times by 20 tests: end of block Executed by:
| 1176 | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | void QQuickStateAction::deleteFromBinding() | - | ||||||||||||||||||||||||
362 | { | - | ||||||||||||||||||||||||
363 | if (fromBinding) {
| 4-6 | ||||||||||||||||||||||||
364 | QQmlPropertyPrivate::removeBinding(property); | - | ||||||||||||||||||||||||
365 | fromBinding = nullptr; | - | ||||||||||||||||||||||||
366 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
367 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
368 | - | |||||||||||||||||||||||||
369 | bool QQuickState::containsPropertyInRevertList(QObject *target, const QString &name) const | - | ||||||||||||||||||||||||
370 | { | - | ||||||||||||||||||||||||
371 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | if (isStateActive()) {
| 0-8 | ||||||||||||||||||||||||
374 | QListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | while (revertListIterator.hasNext()) {
| 4-6 | ||||||||||||||||||||||||
377 | const QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
378 | if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
| 0-6 | ||||||||||||||||||||||||
379 | return true; executed 4 times by 2 tests: return true; Executed by:
| 4 | ||||||||||||||||||||||||
380 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
381 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
382 | - | |||||||||||||||||||||||||
383 | return false; executed 4 times by 2 tests: return false; Executed by:
| 4 | ||||||||||||||||||||||||
384 | } | - | ||||||||||||||||||||||||
385 | - | |||||||||||||||||||||||||
386 | bool QQuickState::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue) | - | ||||||||||||||||||||||||
387 | { | - | ||||||||||||||||||||||||
388 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||
390 | if (isStateActive()) {
| 0-2 | ||||||||||||||||||||||||
391 | QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | while (revertListIterator.hasNext()) {
| 0-2 | ||||||||||||||||||||||||
394 | QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
395 | if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
| 0-2 | ||||||||||||||||||||||||
396 | simpleAction.setValue(revertValue); | - | ||||||||||||||||||||||||
397 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
398 | } | - | ||||||||||||||||||||||||
399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
400 | } never executed: end of block | 0 | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
403 | } | - | ||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||
405 | bool QQuickState::changeBindingInRevertList(QObject *target, const QString &name, QQmlAbstractBinding *binding) | - | ||||||||||||||||||||||||
406 | { | - | ||||||||||||||||||||||||
407 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | if (isStateActive()) {
| 0-2 | ||||||||||||||||||||||||
410 | QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | while (revertListIterator.hasNext()) {
| 0-2 | ||||||||||||||||||||||||
413 | QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
414 | if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
| 0-2 | ||||||||||||||||||||||||
415 | simpleAction.setBinding(binding); | - | ||||||||||||||||||||||||
416 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
417 | } | - | ||||||||||||||||||||||||
418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
419 | } never executed: end of block | 0 | ||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
422 | } | - | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | bool QQuickState::removeEntryFromRevertList(QObject *target, const QString &name) | - | ||||||||||||||||||||||||
425 | { | - | ||||||||||||||||||||||||
426 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | if (isStateActive()) {
| 4-6 | ||||||||||||||||||||||||
429 | QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | while (revertListIterator.hasNext()) {
| 0-6 | ||||||||||||||||||||||||
432 | QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
433 | if (simpleAction.property().object() == target && simpleAction.property().name() == name) {
| 0-6 | ||||||||||||||||||||||||
434 | QQmlPropertyPrivate::removeBinding(simpleAction.property()); | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | simpleAction.property().write(simpleAction.value()); | - | ||||||||||||||||||||||||
437 | if (simpleAction.binding())
| 2-4 | ||||||||||||||||||||||||
438 | QQmlPropertyPrivate::setBinding(simpleAction.binding()); executed 4 times by 2 tests: QQmlPropertyPrivate::setBinding(simpleAction.binding()); Executed by:
| 4 | ||||||||||||||||||||||||
439 | - | |||||||||||||||||||||||||
440 | revertListIterator.remove(); | - | ||||||||||||||||||||||||
441 | return true; executed 6 times by 2 tests: return true; Executed by:
| 6 | ||||||||||||||||||||||||
442 | } | - | ||||||||||||||||||||||||
443 | } never executed: end of block | 0 | ||||||||||||||||||||||||
444 | } never executed: end of block | 0 | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | return false; executed 4 times by 2 tests: return false; Executed by:
| 4 | ||||||||||||||||||||||||
447 | } | - | ||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | void QQuickState::addEntryToRevertList(const QQuickStateAction &action) | - | ||||||||||||||||||||||||
450 | { | - | ||||||||||||||||||||||||
451 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | QQuickSimpleAction simpleAction(action); | - | ||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | d->revertList.append(simpleAction); | - | ||||||||||||||||||||||||
456 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | void QQuickState::removeAllEntriesFromRevertList(QObject *target) | - | ||||||||||||||||||||||||
459 | { | - | ||||||||||||||||||||||||
460 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
461 | - | |||||||||||||||||||||||||
462 | if (isStateActive()) {
| 0 | ||||||||||||||||||||||||
463 | QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||
465 | while (revertListIterator.hasNext()) {
| 0 | ||||||||||||||||||||||||
466 | QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
467 | if (simpleAction.property().object() == target) {
| 0 | ||||||||||||||||||||||||
468 | QQmlPropertyPrivate::removeBinding(simpleAction.property()); | - | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | simpleAction.property().write(simpleAction.value()); | - | ||||||||||||||||||||||||
471 | if (simpleAction.binding())
| 0 | ||||||||||||||||||||||||
472 | QQmlPropertyPrivate::setBinding(simpleAction.binding()); never executed: QQmlPropertyPrivate::setBinding(simpleAction.binding()); | 0 | ||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | revertListIterator.remove(); | - | ||||||||||||||||||||||||
475 | } never executed: end of block | 0 | ||||||||||||||||||||||||
476 | } never executed: end of block | 0 | ||||||||||||||||||||||||
477 | } never executed: end of block | 0 | ||||||||||||||||||||||||
478 | } never executed: end of block | 0 | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | void QQuickState::addEntriesToRevertList(const QList<QQuickStateAction> &actionList) | - | ||||||||||||||||||||||||
481 | { | - | ||||||||||||||||||||||||
482 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
483 | if (isStateActive()) {
| 0-2 | ||||||||||||||||||||||||
484 | QList<QQuickSimpleAction> simpleActionList; | - | ||||||||||||||||||||||||
485 | simpleActionList.reserve(actionList.count()); | - | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | QListIterator<QQuickStateAction> actionListIterator(actionList); | - | ||||||||||||||||||||||||
488 | while(actionListIterator.hasNext()) {
| 0 | ||||||||||||||||||||||||
489 | const QQuickStateAction &action = actionListIterator.next(); | - | ||||||||||||||||||||||||
490 | QQuickSimpleAction simpleAction(action); | - | ||||||||||||||||||||||||
491 | action.property.write(action.toValue); | - | ||||||||||||||||||||||||
492 | if (action.toBinding)
| 0 | ||||||||||||||||||||||||
493 | QQmlPropertyPrivate::setBinding(action.toBinding.data()); never executed: QQmlPropertyPrivate::setBinding(action.toBinding.data()); | 0 | ||||||||||||||||||||||||
494 | - | |||||||||||||||||||||||||
495 | simpleActionList.append(simpleAction); | - | ||||||||||||||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||
498 | d->revertList.append(simpleActionList); | - | ||||||||||||||||||||||||
499 | } never executed: end of block | 0 | ||||||||||||||||||||||||
500 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | QVariant QQuickState::valueInRevertList(QObject *target, const QString &name) const | - | ||||||||||||||||||||||||
503 | { | - | ||||||||||||||||||||||||
504 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | if (isStateActive()) {
| 0 | ||||||||||||||||||||||||
507 | QListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
508 | - | |||||||||||||||||||||||||
509 | while (revertListIterator.hasNext()) {
| 0 | ||||||||||||||||||||||||
510 | const QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
511 | if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
| 0 | ||||||||||||||||||||||||
512 | return simpleAction.value(); never executed: return simpleAction.value(); | 0 | ||||||||||||||||||||||||
513 | } never executed: end of block | 0 | ||||||||||||||||||||||||
514 | } never executed: end of block | 0 | ||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
517 | } | - | ||||||||||||||||||||||||
518 | - | |||||||||||||||||||||||||
519 | QQmlAbstractBinding *QQuickState::bindingInRevertList(QObject *target, const QString &name) const | - | ||||||||||||||||||||||||
520 | { | - | ||||||||||||||||||||||||
521 | Q_D(const QQuickState); | - | ||||||||||||||||||||||||
522 | - | |||||||||||||||||||||||||
523 | if (isStateActive()) {
| 0-12 | ||||||||||||||||||||||||
524 | QListIterator<QQuickSimpleAction> revertListIterator(d->revertList); | - | ||||||||||||||||||||||||
525 | - | |||||||||||||||||||||||||
526 | while (revertListIterator.hasNext()) {
| 2-16 | ||||||||||||||||||||||||
527 | const QQuickSimpleAction &simpleAction = revertListIterator.next(); | - | ||||||||||||||||||||||||
528 | if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
| 0-16 | ||||||||||||||||||||||||
529 | return simpleAction.binding(); executed 10 times by 1 test: return simpleAction.binding(); Executed by:
| 10 | ||||||||||||||||||||||||
530 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
531 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | return nullptr; executed 2 times by 1 test: return nullptr; Executed by:
| 2 | ||||||||||||||||||||||||
534 | } | - | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | bool QQuickState::isStateActive() const | - | ||||||||||||||||||||||||
537 | { | - | ||||||||||||||||||||||||
538 | return stateGroup() && stateGroup()->state() == name(); executed 68 times by 3 tests: return stateGroup() && stateGroup()->state() == name(); Executed by:
| 68 | ||||||||||||||||||||||||
539 | } | - | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | void QQuickState::apply(QQuickTransition *trans, QQuickState *revert) | - | ||||||||||||||||||||||||
542 | { | - | ||||||||||||||||||||||||
543 | Q_D(QQuickState); | - | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | qmlExecuteDeferred(this); | - | ||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||
547 | cancel(); | - | ||||||||||||||||||||||||
548 | if (revert)
| 0-588 | ||||||||||||||||||||||||
549 | revert->cancel(); executed 588 times by 20 tests: revert->cancel(); Executed by:
| 588 | ||||||||||||||||||||||||
550 | d->revertList.clear(); | - | ||||||||||||||||||||||||
551 | d->reverting.clear(); | - | ||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||
553 | if (revert) {
| 0-588 | ||||||||||||||||||||||||
554 | QQuickStatePrivate *revertPrivate = | - | ||||||||||||||||||||||||
555 | static_cast<QQuickStatePrivate*>(revert->d_func()); | - | ||||||||||||||||||||||||
556 | d->revertList = revertPrivate->revertList; | - | ||||||||||||||||||||||||
557 | revertPrivate->revertList.clear(); | - | ||||||||||||||||||||||||
558 | } executed 588 times by 20 tests: end of block Executed by:
| 588 | ||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | // List of actions caused by this state | - | ||||||||||||||||||||||||
561 | QQuickStateOperation::ActionList applyList = d->generateActionList(); | - | ||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | // List of actions that need to be reverted to roll back (just) this state | - | ||||||||||||||||||||||||
564 | QQuickStatePrivate::SimpleActionList additionalReverts; | - | ||||||||||||||||||||||||
565 | // First add the reverse of all the applyList actions | - | ||||||||||||||||||||||||
566 | for (int ii = 0; ii < applyList.count(); ++ii) {
| 588-924 | ||||||||||||||||||||||||
567 | QQuickStateAction &action = applyList[ii]; | - | ||||||||||||||||||||||||
568 | - | |||||||||||||||||||||||||
569 | if (action.event) {
| 198-726 | ||||||||||||||||||||||||
570 | if (!action.event->isReversable())
| 8-190 | ||||||||||||||||||||||||
571 | continue; executed 8 times by 2 tests: continue; Executed by:
| 8 | ||||||||||||||||||||||||
572 | bool found = false; | - | ||||||||||||||||||||||||
573 | for (int jj = 0; jj < d->revertList.count(); ++jj) {
| 18-176 | ||||||||||||||||||||||||
574 | QQuickStateActionEvent *event = d->revertList.at(jj).event(); | - | ||||||||||||||||||||||||
575 | if (event && event->type() == action.event->type()) {
| 0-14 | ||||||||||||||||||||||||
576 | if (action.event->mayOverride(event)) {
| 0-14 | ||||||||||||||||||||||||
577 | found = true; | - | ||||||||||||||||||||||||
578 | - | |||||||||||||||||||||||||
579 | if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) {
| 0-10 | ||||||||||||||||||||||||
580 | action.event->copyOriginals(d->revertList.at(jj).event()); | - | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | QQuickSimpleAction r(action); | - | ||||||||||||||||||||||||
583 | additionalReverts << r; | - | ||||||||||||||||||||||||
584 | d->revertList.removeAt(jj); | - | ||||||||||||||||||||||||
585 | --jj; | - | ||||||||||||||||||||||||
586 | } else if (action.event->isRewindable()) //###why needed? executed 10 times by 2 tests: end of block Executed by:
| 0-10 | ||||||||||||||||||||||||
587 | action.event->saveCurrentValues(); executed 4 times by 1 test: action.event->saveCurrentValues(); Executed by:
| 4 | ||||||||||||||||||||||||
588 | - | |||||||||||||||||||||||||
589 | break; executed 14 times by 2 tests: break; Executed by:
| 14 | ||||||||||||||||||||||||
590 | } | - | ||||||||||||||||||||||||
591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
592 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
593 | if (!found) {
| 14-176 | ||||||||||||||||||||||||
594 | action.event->saveOriginals(); | - | ||||||||||||||||||||||||
595 | // Only need to revert the applyList action if the previous | - | ||||||||||||||||||||||||
596 | // state doesn't have a higher priority revert already | - | ||||||||||||||||||||||||
597 | QQuickSimpleAction r(action); | - | ||||||||||||||||||||||||
598 | additionalReverts << r; | - | ||||||||||||||||||||||||
599 | } executed 176 times by 6 tests: end of block Executed by:
| 176 | ||||||||||||||||||||||||
600 | } else { executed 190 times by 6 tests: end of block Executed by:
| 190 | ||||||||||||||||||||||||
601 | bool found = false; | - | ||||||||||||||||||||||||
602 | action.fromBinding = QQmlPropertyPrivate::binding(action.property); | - | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | for (int jj = 0; jj < d->revertList.count(); ++jj) {
| 44-692 | ||||||||||||||||||||||||
605 | if (d->revertList.at(jj).property() == action.property) {
| 10-34 | ||||||||||||||||||||||||
606 | found = true; | - | ||||||||||||||||||||||||
607 | if (d->revertList.at(jj).binding() != action.fromBinding.data()) {
| 6-28 | ||||||||||||||||||||||||
608 | action.deleteFromBinding(); | - | ||||||||||||||||||||||||
609 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
610 | break; executed 34 times by 1 test: break; Executed by:
| 34 | ||||||||||||||||||||||||
611 | } | - | ||||||||||||||||||||||||
612 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | if (!found) {
| 34-692 | ||||||||||||||||||||||||
615 | if (!action.restore) {
| 4-688 | ||||||||||||||||||||||||
616 | action.deleteFromBinding();; | - | ||||||||||||||||||||||||
617 | } else { executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
618 | // Only need to revert the applyList action if the previous | - | ||||||||||||||||||||||||
619 | // state doesn't have a higher priority revert already | - | ||||||||||||||||||||||||
620 | QQuickSimpleAction r(action); | - | ||||||||||||||||||||||||
621 | additionalReverts << r; | - | ||||||||||||||||||||||||
622 | } executed 688 times by 17 tests: end of block Executed by:
| 688 | ||||||||||||||||||||||||
623 | } | - | ||||||||||||||||||||||||
624 | } executed 726 times by 17 tests: end of block Executed by:
| 726 | ||||||||||||||||||||||||
625 | } | - | ||||||||||||||||||||||||
626 | - | |||||||||||||||||||||||||
627 | // Any reverts from a previous state that aren't carried forth | - | ||||||||||||||||||||||||
628 | // into this state need to be translated into apply actions | - | ||||||||||||||||||||||||
629 | for (int ii = 0; ii < d->revertList.count(); ++ii) {
| 194-588 | ||||||||||||||||||||||||
630 | bool found = false; | - | ||||||||||||||||||||||||
631 | if (d->revertList.at(ii).event()) {
| 44-150 | ||||||||||||||||||||||||
632 | QQuickStateActionEvent *event = d->revertList.at(ii).event(); | - | ||||||||||||||||||||||||
633 | if (!event->isReversable())
| 0-44 | ||||||||||||||||||||||||
634 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
635 | for (int jj = 0; !found && jj < applyList.count(); ++jj) {
| 4-56 | ||||||||||||||||||||||||
636 | const QQuickStateAction &action = applyList.at(jj); | - | ||||||||||||||||||||||||
637 | if (action.event && action.event->type() == event->type()) {
| 4-8 | ||||||||||||||||||||||||
638 | if (action.event->mayOverride(event))
| 0-4 | ||||||||||||||||||||||||
639 | found = true; executed 4 times by 1 test: found = true; Executed by:
| 4 | ||||||||||||||||||||||||
640 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
641 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||
642 | } else { executed 44 times by 3 tests: end of block Executed by:
| 44 | ||||||||||||||||||||||||
643 | for (int jj = 0; !found && jj < applyList.count(); ++jj) {
| 28-186 | ||||||||||||||||||||||||
644 | const QQuickStateAction &action = applyList.at(jj); | - | ||||||||||||||||||||||||
645 | if (action.property == d->revertList.at(ii).property())
| 28-36 | ||||||||||||||||||||||||
646 | found = true; executed 28 times by 1 test: found = true; Executed by:
| 28 | ||||||||||||||||||||||||
647 | } executed 64 times by 4 tests: end of block Executed by:
| 64 | ||||||||||||||||||||||||
648 | } executed 150 times by 11 tests: end of block Executed by:
| 150 | ||||||||||||||||||||||||
649 | if (!found) {
| 32-162 | ||||||||||||||||||||||||
650 | QVariant cur = d->revertList.at(ii).property().read(); | - | ||||||||||||||||||||||||
651 | QQmlPropertyPrivate::removeBinding(d->revertList.at(ii).property()); | - | ||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||
653 | QQuickStateAction a; | - | ||||||||||||||||||||||||
654 | a.property = d->revertList.at(ii).property(); | - | ||||||||||||||||||||||||
655 | a.fromValue = cur; | - | ||||||||||||||||||||||||
656 | a.toValue = d->revertList.at(ii).value(); | - | ||||||||||||||||||||||||
657 | a.toBinding = d->revertList.at(ii).binding(); | - | ||||||||||||||||||||||||
658 | a.specifiedObject = d->revertList.at(ii).specifiedObject(); | - | ||||||||||||||||||||||||
659 | a.specifiedProperty = d->revertList.at(ii).specifiedProperty(); | - | ||||||||||||||||||||||||
660 | a.event = d->revertList.at(ii).event(); | - | ||||||||||||||||||||||||
661 | a.reverseEvent = d->revertList.at(ii).reverseEvent(); | - | ||||||||||||||||||||||||
662 | if (a.event && a.event->isRewindable())
| 0-122 | ||||||||||||||||||||||||
663 | a.event->saveCurrentValues(); executed 40 times by 3 tests: a.event->saveCurrentValues(); Executed by:
| 40 | ||||||||||||||||||||||||
664 | applyList << a; | - | ||||||||||||||||||||||||
665 | // Store these special reverts in the reverting list | - | ||||||||||||||||||||||||
666 | if (a.event)
| 40-122 | ||||||||||||||||||||||||
667 | d->reverting << a.event; executed 40 times by 3 tests: d->reverting << a.event; Executed by:
| 40 | ||||||||||||||||||||||||
668 | else | - | ||||||||||||||||||||||||
669 | d->reverting << a.property; executed 122 times by 11 tests: d->reverting << a.property; Executed by:
| 122 | ||||||||||||||||||||||||
670 | } | - | ||||||||||||||||||||||||
671 | } executed 194 times by 12 tests: end of block Executed by:
| 194 | ||||||||||||||||||||||||
672 | // All the local reverts now become part of the ongoing revertList | - | ||||||||||||||||||||||||
673 | d->revertList << additionalReverts; | - | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
676 | // Output for debugging | - | ||||||||||||||||||||||||
677 | if (stateChangeDebug()) {
| 0-588 | ||||||||||||||||||||||||
678 | for (const QQuickStateAction &action : qAsConst(applyList)) { | - | ||||||||||||||||||||||||
679 | if (action.event)
| 0 | ||||||||||||||||||||||||
680 | qWarning() << " QQuickStateAction event:" << action.event->type(); never executed: QMessageLogger(__FILE__, 680, __PRETTY_FUNCTION__).warning() << " QQuickStateAction event:" << action.event->type(); | 0 | ||||||||||||||||||||||||
681 | else | - | ||||||||||||||||||||||||
682 | qWarning() << " QQuickStateAction:" << action.property.object() never executed: QMessageLogger(__FILE__, 682, __PRETTY_FUNCTION__).warning() << " QQuickStateAction:" << action.property.object() << action.property.name() << "From:" << action.fromValue << "To:" << action.toValue; | 0 | ||||||||||||||||||||||||
683 | << action.property.name() << "From:" << action.fromValue never executed: QMessageLogger(__FILE__, 682, __PRETTY_FUNCTION__).warning() << " QQuickStateAction:" << action.property.object() << action.property.name() << "From:" << action.fromValue << "To:" << action.toValue; | 0 | ||||||||||||||||||||||||
684 | << "To:" << action.toValue; never executed: QMessageLogger(__FILE__, 682, __PRETTY_FUNCTION__).warning() << " QQuickStateAction:" << action.property.object() << action.property.name() << "From:" << action.fromValue << "To:" << action.toValue; | 0 | ||||||||||||||||||||||||
685 | } | - | ||||||||||||||||||||||||
686 | } never executed: end of block | 0 | ||||||||||||||||||||||||
687 | #endif | - | ||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | d->transitionManager.transition(applyList, trans); | - | ||||||||||||||||||||||||
690 | } executed 588 times by 20 tests: end of block Executed by:
| 588 | ||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | QQuickStateOperation::ActionList QQuickStateOperation::actions() | - | ||||||||||||||||||||||||
693 | { | - | ||||||||||||||||||||||||
694 | return ActionList(); never executed: return ActionList(); | 0 | ||||||||||||||||||||||||
695 | } | - | ||||||||||||||||||||||||
696 | - | |||||||||||||||||||||||||
697 | QQuickState *QQuickStateOperation::state() const | - | ||||||||||||||||||||||||
698 | { | - | ||||||||||||||||||||||||
699 | Q_D(const QQuickStateOperation); | - | ||||||||||||||||||||||||
700 | return d->m_state; executed 60 times by 3 tests: return d->m_state; Executed by:
| 60 | ||||||||||||||||||||||||
701 | } | - | ||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | void QQuickStateOperation::setState(QQuickState *state) | - | ||||||||||||||||||||||||
704 | { | - | ||||||||||||||||||||||||
705 | Q_D(QQuickStateOperation); | - | ||||||||||||||||||||||||
706 | d->m_state = state; | - | ||||||||||||||||||||||||
707 | } executed 622 times by 18 tests: end of block Executed by:
| 622 | ||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||
711 | #include "moc_qquickstate_p.cpp" | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |