Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickstateoperations.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 "qquickstateoperations_p.h" | - | ||||||||||||||||||
41 | #include "qquickitem_p.h" | - | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | #include <private/qquickstate_p_p.h> | - | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||
46 | #include <QtCore/qmath.h> | - | ||||||||||||||||||
47 | - | |||||||||||||||||||
48 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | class QQuickParentChangePrivate : public QQuickStateOperationPrivate | - | ||||||||||||||||||
51 | { | - | ||||||||||||||||||
52 | Q_DECLARE_PUBLIC(QQuickParentChange) | - | ||||||||||||||||||
53 | public: | - | ||||||||||||||||||
54 | QQuickParentChangePrivate() : target(nullptr), parent(nullptr), origParent(nullptr), origStackBefore(nullptr), | - | ||||||||||||||||||
55 | rewindParent(nullptr), rewindStackBefore(nullptr) {} executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | QQuickItem *target; | - | ||||||||||||||||||
58 | QPointer<QQuickItem> parent; | - | ||||||||||||||||||
59 | QPointer<QQuickItem> origParent; | - | ||||||||||||||||||
60 | QPointer<QQuickItem> origStackBefore; | - | ||||||||||||||||||
61 | QQuickItem *rewindParent; | - | ||||||||||||||||||
62 | QQuickItem *rewindStackBefore; | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | QQmlNullableValue<QQmlScriptString> xString; | - | ||||||||||||||||||
65 | QQmlNullableValue<QQmlScriptString> yString; | - | ||||||||||||||||||
66 | QQmlNullableValue<QQmlScriptString> widthString; | - | ||||||||||||||||||
67 | QQmlNullableValue<QQmlScriptString> heightString; | - | ||||||||||||||||||
68 | QQmlNullableValue<QQmlScriptString> scaleString; | - | ||||||||||||||||||
69 | QQmlNullableValue<QQmlScriptString> rotationString; | - | ||||||||||||||||||
70 | - | |||||||||||||||||||
71 | void doChange(QQuickItem *targetParent, QQuickItem *stackBefore = nullptr); | - | ||||||||||||||||||
72 | }; | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *stackBefore) | - | ||||||||||||||||||
75 | { | - | ||||||||||||||||||
76 | if (targetParent && target && target->parentItem()) {
| 0-136 | ||||||||||||||||||
77 | Q_Q(QQuickParentChange); | - | ||||||||||||||||||
78 | bool ok; | - | ||||||||||||||||||
79 | const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); | - | ||||||||||||||||||
80 | if (transform.type() >= QTransform::TxShear || !ok) {
| 0-102 | ||||||||||||||||||
81 | qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under complex transform"); | - | ||||||||||||||||||
82 | ok = false; | - | ||||||||||||||||||
83 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | qreal scale = 1; | - | ||||||||||||||||||
86 | qreal rotation = 0; | - | ||||||||||||||||||
87 | bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
| 2-94 | ||||||||||||||||||
88 | if (ok && !isRotate) {
| 2-102 | ||||||||||||||||||
89 | if (transform.m11() == transform.m22())
| 2-88 | ||||||||||||||||||
90 | scale = transform.m11(); executed 88 times by 3 tests: scale = transform.m11(); Executed by:
| 88 | ||||||||||||||||||
91 | else { | - | ||||||||||||||||||
92 | qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale"); | - | ||||||||||||||||||
93 | ok = false; | - | ||||||||||||||||||
94 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
95 | } else if (ok && isRotate) {
| 0-12 | ||||||||||||||||||
96 | if (transform.m11() == transform.m22())
| 0-12 | ||||||||||||||||||
97 | scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); executed 12 times by 2 tests: scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); Executed by:
| 12 | ||||||||||||||||||
98 | else { | - | ||||||||||||||||||
99 | qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale"); | - | ||||||||||||||||||
100 | ok = false; | - | ||||||||||||||||||
101 | } never executed: end of block | 0 | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | if (scale != 0)
| 0-12 | ||||||||||||||||||
104 | rotation = qRadiansToDegrees(qAtan2(transform.m12() / scale, transform.m11() / scale)); executed 12 times by 2 tests: rotation = qRadiansToDegrees(qAtan2(transform.m12() / scale, transform.m11() / scale)); Executed by:
| 12 | ||||||||||||||||||
105 | else { | - | ||||||||||||||||||
106 | qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under scale of 0"); | - | ||||||||||||||||||
107 | ok = false; | - | ||||||||||||||||||
108 | } never executed: end of block | 0 | ||||||||||||||||||
109 | } | - | ||||||||||||||||||
110 | - | |||||||||||||||||||
111 | const QPointF &point = transform.map(QPointF(target->x(),target->y())); | - | ||||||||||||||||||
112 | qreal x = point.x(); | - | ||||||||||||||||||
113 | qreal y = point.y(); | - | ||||||||||||||||||
114 | - | |||||||||||||||||||
115 | // setParentItem will update the transformOriginPoint if needed | - | ||||||||||||||||||
116 | target->setParentItem(targetParent); | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | if (ok && target->transformOrigin() != QQuickItem::TopLeft) {
| 0-100 | ||||||||||||||||||
119 | qreal tempxt = target->transformOriginPoint().x(); | - | ||||||||||||||||||
120 | qreal tempyt = target->transformOriginPoint().y(); | - | ||||||||||||||||||
121 | QTransform t; | - | ||||||||||||||||||
122 | t.translate(-tempxt, -tempyt); | - | ||||||||||||||||||
123 | t.rotate(rotation); | - | ||||||||||||||||||
124 | t.scale(scale, scale); | - | ||||||||||||||||||
125 | t.translate(tempxt, tempyt); | - | ||||||||||||||||||
126 | const QPointF &offset = t.map(QPointF(0,0)); | - | ||||||||||||||||||
127 | x += offset.x(); | - | ||||||||||||||||||
128 | y += offset.y(); | - | ||||||||||||||||||
129 | } executed 100 times by 4 tests: end of block Executed by:
| 100 | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | if (ok) {
| 4-100 | ||||||||||||||||||
132 | //qDebug() << x << y << rotation << scale; | - | ||||||||||||||||||
133 | target->setPosition(QPointF(x, y)); | - | ||||||||||||||||||
134 | target->setRotation(target->rotation() + rotation); | - | ||||||||||||||||||
135 | target->setScale(target->scale() * scale); | - | ||||||||||||||||||
136 | } executed 100 times by 4 tests: end of block Executed by:
| 100 | ||||||||||||||||||
137 | } else if (target) { executed 104 times by 4 tests: end of block Executed by:
| 0-104 | ||||||||||||||||||
138 | target->setParentItem(targetParent); | - | ||||||||||||||||||
139 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | //restore the original stack position. | - | ||||||||||||||||||
142 | //### if stackBefore has also been reparented this won't work | - | ||||||||||||||||||
143 | if (target && stackBefore)
| 0-136 | ||||||||||||||||||
144 | target->stackBefore(stackBefore); never executed: target->stackBefore(stackBefore); | 0 | ||||||||||||||||||
145 | } executed 136 times by 5 tests: end of block Executed by:
| 136 | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | /*! | - | ||||||||||||||||||
148 | \qmltype ParentChange | - | ||||||||||||||||||
149 | \instantiates QQuickParentChange | - | ||||||||||||||||||
150 | \inqmlmodule QtQuick | - | ||||||||||||||||||
151 | \ingroup qtquick-states | - | ||||||||||||||||||
152 | \brief Specifies how to reparent an Item in a state change. | - | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | ParentChange reparents an item while preserving its visual appearance (position, size, | - | ||||||||||||||||||
155 | rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale | - | ||||||||||||||||||
156 | the item to its final intended appearance. | - | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | ParentChange can only preserve visual appearance if no complex transforms are involved. | - | ||||||||||||||||||
159 | More specifically, it will not work if the transform property has been set for any | - | ||||||||||||||||||
160 | items involved in the reparenting (i.e. items in the common ancestor tree | - | ||||||||||||||||||
161 | for the original and new parent). | - | ||||||||||||||||||
162 | - | |||||||||||||||||||
163 | The example below displays a large red rectangle and a small blue rectangle, side by side. | - | ||||||||||||||||||
164 | When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is | - | ||||||||||||||||||
165 | positioned at (10, 10) within the red rectangle, as specified in the ParentChange. | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | \snippet qml/parentchange.qml 0 | - | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | \image parentchange.png | - | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | You can specify at which point in a transition you want a ParentChange to occur by | - | ||||||||||||||||||
172 | using a ParentAnimation. | - | ||||||||||||||||||
173 | - | |||||||||||||||||||
174 | Note that unlike PropertyChanges, ParentChange expects an Item-based target; it will not work with | - | ||||||||||||||||||
175 | arbitrary objects (for example, you couldn't use it to reparent a Timer). | - | ||||||||||||||||||
176 | */ | - | ||||||||||||||||||
177 | - | |||||||||||||||||||
178 | QQuickParentChange::QQuickParentChange(QObject *parent) | - | ||||||||||||||||||
179 | : QQuickStateOperation(*(new QQuickParentChangePrivate), parent) | - | ||||||||||||||||||
180 | { | - | ||||||||||||||||||
181 | } executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
182 | - | |||||||||||||||||||
183 | QQuickParentChange::~QQuickParentChange() | - | ||||||||||||||||||
184 | { | - | ||||||||||||||||||
185 | } | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | /*! | - | ||||||||||||||||||
188 | \qmlproperty real QtQuick::ParentChange::x | - | ||||||||||||||||||
189 | \qmlproperty real QtQuick::ParentChange::y | - | ||||||||||||||||||
190 | \qmlproperty real QtQuick::ParentChange::width | - | ||||||||||||||||||
191 | \qmlproperty real QtQuick::ParentChange::height | - | ||||||||||||||||||
192 | \qmlproperty real QtQuick::ParentChange::scale | - | ||||||||||||||||||
193 | \qmlproperty real QtQuick::ParentChange::rotation | - | ||||||||||||||||||
194 | These properties hold the new position, size, scale, and rotation | - | ||||||||||||||||||
195 | for the item in this state. | - | ||||||||||||||||||
196 | */ | - | ||||||||||||||||||
197 | QQmlScriptString QQuickParentChange::x() const | - | ||||||||||||||||||
198 | { | - | ||||||||||||||||||
199 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
200 | return d->xString.value; never executed: return d->xString.value; | 0 | ||||||||||||||||||
201 | } | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | void QQuickParentChange::setX(QQmlScriptString x) | - | ||||||||||||||||||
204 | { | - | ||||||||||||||||||
205 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
206 | d->xString = x; | - | ||||||||||||||||||
207 | } executed 90 times by 4 tests: end of block Executed by:
| 90 | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | bool QQuickParentChange::xIsSet() const | - | ||||||||||||||||||
210 | { | - | ||||||||||||||||||
211 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
212 | return d->xString.isValid(); executed 2 times by 1 test: return d->xString.isValid(); Executed by:
| 2 | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | QQmlScriptString QQuickParentChange::y() const | - | ||||||||||||||||||
216 | { | - | ||||||||||||||||||
217 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
218 | return d->yString.value; never executed: return d->yString.value; | 0 | ||||||||||||||||||
219 | } | - | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | void QQuickParentChange::setY(QQmlScriptString y) | - | ||||||||||||||||||
222 | { | - | ||||||||||||||||||
223 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
224 | d->yString = y; | - | ||||||||||||||||||
225 | } executed 90 times by 4 tests: end of block Executed by:
| 90 | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | bool QQuickParentChange::yIsSet() const | - | ||||||||||||||||||
228 | { | - | ||||||||||||||||||
229 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
230 | return d->yString.isValid(); executed 2 times by 1 test: return d->yString.isValid(); Executed by:
| 2 | ||||||||||||||||||
231 | } | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | QQmlScriptString QQuickParentChange::width() const | - | ||||||||||||||||||
234 | { | - | ||||||||||||||||||
235 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
236 | return d->widthString.value; never executed: return d->widthString.value; | 0 | ||||||||||||||||||
237 | } | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | void QQuickParentChange::setWidth(QQmlScriptString width) | - | ||||||||||||||||||
240 | { | - | ||||||||||||||||||
241 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
242 | d->widthString = width; | - | ||||||||||||||||||
243 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
244 | - | |||||||||||||||||||
245 | bool QQuickParentChange::widthIsSet() const | - | ||||||||||||||||||
246 | { | - | ||||||||||||||||||
247 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
248 | return d->widthString.isValid(); executed 2 times by 1 test: return d->widthString.isValid(); Executed by:
| 2 | ||||||||||||||||||
249 | } | - | ||||||||||||||||||
250 | - | |||||||||||||||||||
251 | QQmlScriptString QQuickParentChange::height() const | - | ||||||||||||||||||
252 | { | - | ||||||||||||||||||
253 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
254 | return d->heightString.value; never executed: return d->heightString.value; | 0 | ||||||||||||||||||
255 | } | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | void QQuickParentChange::setHeight(QQmlScriptString height) | - | ||||||||||||||||||
258 | { | - | ||||||||||||||||||
259 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
260 | d->heightString = height; | - | ||||||||||||||||||
261 | } never executed: end of block | 0 | ||||||||||||||||||
262 | - | |||||||||||||||||||
263 | bool QQuickParentChange::heightIsSet() const | - | ||||||||||||||||||
264 | { | - | ||||||||||||||||||
265 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
266 | return d->heightString.isValid(); executed 2 times by 1 test: return d->heightString.isValid(); Executed by:
| 2 | ||||||||||||||||||
267 | } | - | ||||||||||||||||||
268 | - | |||||||||||||||||||
269 | QQmlScriptString QQuickParentChange::scale() const | - | ||||||||||||||||||
270 | { | - | ||||||||||||||||||
271 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
272 | return d->scaleString.value; never executed: return d->scaleString.value; | 0 | ||||||||||||||||||
273 | } | - | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | void QQuickParentChange::setScale(QQmlScriptString scale) | - | ||||||||||||||||||
276 | { | - | ||||||||||||||||||
277 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
278 | d->scaleString = scale; | - | ||||||||||||||||||
279 | } never executed: end of block | 0 | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | bool QQuickParentChange::scaleIsSet() const | - | ||||||||||||||||||
282 | { | - | ||||||||||||||||||
283 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
284 | return d->scaleString.isValid(); executed 2 times by 1 test: return d->scaleString.isValid(); Executed by:
| 2 | ||||||||||||||||||
285 | } | - | ||||||||||||||||||
286 | - | |||||||||||||||||||
287 | QQmlScriptString QQuickParentChange::rotation() const | - | ||||||||||||||||||
288 | { | - | ||||||||||||||||||
289 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
290 | return d->rotationString.value; never executed: return d->rotationString.value; | 0 | ||||||||||||||||||
291 | } | - | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | void QQuickParentChange::setRotation(QQmlScriptString rotation) | - | ||||||||||||||||||
294 | { | - | ||||||||||||||||||
295 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
296 | d->rotationString = rotation; | - | ||||||||||||||||||
297 | } never executed: end of block | 0 | ||||||||||||||||||
298 | - | |||||||||||||||||||
299 | bool QQuickParentChange::rotationIsSet() const | - | ||||||||||||||||||
300 | { | - | ||||||||||||||||||
301 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
302 | return d->rotationString.isValid(); executed 2 times by 1 test: return d->rotationString.isValid(); Executed by:
| 2 | ||||||||||||||||||
303 | } | - | ||||||||||||||||||
304 | - | |||||||||||||||||||
305 | QQuickItem *QQuickParentChange::originalParent() const | - | ||||||||||||||||||
306 | { | - | ||||||||||||||||||
307 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
308 | return d->origParent; never executed: return d->origParent; | 0 | ||||||||||||||||||
309 | } | - | ||||||||||||||||||
310 | - | |||||||||||||||||||
311 | /*! | - | ||||||||||||||||||
312 | \qmlproperty Item QtQuick::ParentChange::target | - | ||||||||||||||||||
313 | This property holds the item to be reparented | - | ||||||||||||||||||
314 | */ | - | ||||||||||||||||||
315 | QQuickItem *QQuickParentChange::object() const | - | ||||||||||||||||||
316 | { | - | ||||||||||||||||||
317 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
318 | return d->target; executed 6 times by 1 test: return d->target; Executed by:
| 6 | ||||||||||||||||||
319 | } | - | ||||||||||||||||||
320 | - | |||||||||||||||||||
321 | void QQuickParentChange::setObject(QQuickItem *target) | - | ||||||||||||||||||
322 | { | - | ||||||||||||||||||
323 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
324 | d->target = target; | - | ||||||||||||||||||
325 | } executed 126 times by 5 tests: end of block Executed by:
| 126 | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | /*! | - | ||||||||||||||||||
328 | \qmlproperty Item QtQuick::ParentChange::parent | - | ||||||||||||||||||
329 | This property holds the new parent for the item in this state. | - | ||||||||||||||||||
330 | */ | - | ||||||||||||||||||
331 | QQuickItem *QQuickParentChange::parent() const | - | ||||||||||||||||||
332 | { | - | ||||||||||||||||||
333 | Q_D(const QQuickParentChange); | - | ||||||||||||||||||
334 | return d->parent; executed 4 times by 2 tests: return d->parent; Executed by:
| 4 | ||||||||||||||||||
335 | } | - | ||||||||||||||||||
336 | - | |||||||||||||||||||
337 | void QQuickParentChange::setParent(QQuickItem *parent) | - | ||||||||||||||||||
338 | { | - | ||||||||||||||||||
339 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
340 | d->parent = parent; | - | ||||||||||||||||||
341 | } executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
342 | - | |||||||||||||||||||
343 | QQuickStateOperation::ActionList QQuickParentChange::actions() | - | ||||||||||||||||||
344 | { | - | ||||||||||||||||||
345 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
346 | if (!d->target || !d->parent)
| 0-124 | ||||||||||||||||||
347 | return ActionList(); never executed: return ActionList(); | 0 | ||||||||||||||||||
348 | - | |||||||||||||||||||
349 | ActionList actions; | - | ||||||||||||||||||
350 | - | |||||||||||||||||||
351 | QQuickStateAction a; | - | ||||||||||||||||||
352 | a.event = this; | - | ||||||||||||||||||
353 | actions << a; | - | ||||||||||||||||||
354 | - | |||||||||||||||||||
355 | if (d->xString.isValid()) {
| 32-92 | ||||||||||||||||||
356 | bool ok = false; | - | ||||||||||||||||||
357 | qreal x = d->xString.value.numberLiteral(&ok); | - | ||||||||||||||||||
358 | if (ok) {
| 0-92 | ||||||||||||||||||
359 | QQuickStateAction xa(d->target, QLatin1String("x"), x); | - | ||||||||||||||||||
360 | actions << xa; | - | ||||||||||||||||||
361 | } else { executed 92 times by 4 tests: end of block Executed by:
| 92 | ||||||||||||||||||
362 | QQmlProperty property(d->target, QLatin1String("x")); | - | ||||||||||||||||||
363 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->xString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
364 | newBinding->setTarget(property); | - | ||||||||||||||||||
365 | QQuickStateAction xa; | - | ||||||||||||||||||
366 | xa.property = property; | - | ||||||||||||||||||
367 | xa.toBinding = newBinding; | - | ||||||||||||||||||
368 | xa.fromValue = xa.property.read(); | - | ||||||||||||||||||
369 | xa.deletableToBinding = true; | - | ||||||||||||||||||
370 | actions << xa; | - | ||||||||||||||||||
371 | } never executed: end of block | 0 | ||||||||||||||||||
372 | } | - | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | if (d->yString.isValid()) {
| 32-92 | ||||||||||||||||||
375 | bool ok = false; | - | ||||||||||||||||||
376 | qreal y = d->yString.value.numberLiteral(&ok); | - | ||||||||||||||||||
377 | if (ok) {
| 0-92 | ||||||||||||||||||
378 | QQuickStateAction ya(d->target, QLatin1String("y"), y); | - | ||||||||||||||||||
379 | actions << ya; | - | ||||||||||||||||||
380 | } else { executed 92 times by 4 tests: end of block Executed by:
| 92 | ||||||||||||||||||
381 | QQmlProperty property(d->target, QLatin1String("y")); | - | ||||||||||||||||||
382 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->yString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
383 | newBinding->setTarget(property); | - | ||||||||||||||||||
384 | QQuickStateAction ya; | - | ||||||||||||||||||
385 | ya.property = property; | - | ||||||||||||||||||
386 | ya.toBinding = newBinding; | - | ||||||||||||||||||
387 | ya.fromValue = ya.property.read(); | - | ||||||||||||||||||
388 | ya.deletableToBinding = true; | - | ||||||||||||||||||
389 | actions << ya; | - | ||||||||||||||||||
390 | } never executed: end of block | 0 | ||||||||||||||||||
391 | } | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | if (d->scaleString.isValid()) {
| 0-124 | ||||||||||||||||||
394 | bool ok = false; | - | ||||||||||||||||||
395 | qreal scale = d->scaleString.value.numberLiteral(&ok); | - | ||||||||||||||||||
396 | if (ok) {
| 0 | ||||||||||||||||||
397 | QQuickStateAction sa(d->target, QLatin1String("scale"), scale); | - | ||||||||||||||||||
398 | actions << sa; | - | ||||||||||||||||||
399 | } else { never executed: end of block | 0 | ||||||||||||||||||
400 | QQmlProperty property(d->target, QLatin1String("scale")); | - | ||||||||||||||||||
401 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->scaleString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
402 | newBinding->setTarget(property); | - | ||||||||||||||||||
403 | QQuickStateAction sa; | - | ||||||||||||||||||
404 | sa.property = property; | - | ||||||||||||||||||
405 | sa.toBinding = newBinding; | - | ||||||||||||||||||
406 | sa.fromValue = sa.property.read(); | - | ||||||||||||||||||
407 | sa.deletableToBinding = true; | - | ||||||||||||||||||
408 | actions << sa; | - | ||||||||||||||||||
409 | } never executed: end of block | 0 | ||||||||||||||||||
410 | } | - | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | if (d->rotationString.isValid()) {
| 0-124 | ||||||||||||||||||
413 | bool ok = false; | - | ||||||||||||||||||
414 | qreal rotation = d->rotationString.value.numberLiteral(&ok); | - | ||||||||||||||||||
415 | if (ok) {
| 0 | ||||||||||||||||||
416 | QQuickStateAction ra(d->target, QLatin1String("rotation"), rotation); | - | ||||||||||||||||||
417 | actions << ra; | - | ||||||||||||||||||
418 | } else { never executed: end of block | 0 | ||||||||||||||||||
419 | QQmlProperty property(d->target, QLatin1String("rotation")); | - | ||||||||||||||||||
420 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->rotationString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
421 | newBinding->setTarget(property); | - | ||||||||||||||||||
422 | QQuickStateAction ra; | - | ||||||||||||||||||
423 | ra.property = property; | - | ||||||||||||||||||
424 | ra.toBinding = newBinding; | - | ||||||||||||||||||
425 | ra.fromValue = ra.property.read(); | - | ||||||||||||||||||
426 | ra.deletableToBinding = true; | - | ||||||||||||||||||
427 | actions << ra; | - | ||||||||||||||||||
428 | } never executed: end of block | 0 | ||||||||||||||||||
429 | } | - | ||||||||||||||||||
430 | - | |||||||||||||||||||
431 | if (d->widthString.isValid()) {
| 2-122 | ||||||||||||||||||
432 | bool ok = false; | - | ||||||||||||||||||
433 | qreal width = d->widthString.value.numberLiteral(&ok); | - | ||||||||||||||||||
434 | if (ok) {
| 0-2 | ||||||||||||||||||
435 | QQuickStateAction wa(d->target, QLatin1String("width"), width); | - | ||||||||||||||||||
436 | actions << wa; | - | ||||||||||||||||||
437 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
438 | QQmlProperty property(d->target, QLatin1String("width")); | - | ||||||||||||||||||
439 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->widthString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
440 | newBinding->setTarget(property); | - | ||||||||||||||||||
441 | QQuickStateAction wa; | - | ||||||||||||||||||
442 | wa.property = property; | - | ||||||||||||||||||
443 | wa.toBinding = newBinding; | - | ||||||||||||||||||
444 | wa.fromValue = wa.property.read(); | - | ||||||||||||||||||
445 | wa.deletableToBinding = true; | - | ||||||||||||||||||
446 | actions << wa; | - | ||||||||||||||||||
447 | } never executed: end of block | 0 | ||||||||||||||||||
448 | } | - | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | if (d->heightString.isValid()) {
| 0-124 | ||||||||||||||||||
451 | bool ok = false; | - | ||||||||||||||||||
452 | qreal height = d->heightString.value.numberLiteral(&ok); | - | ||||||||||||||||||
453 | if (ok) {
| 0 | ||||||||||||||||||
454 | QQuickStateAction ha(d->target, QLatin1String("height"), height); | - | ||||||||||||||||||
455 | actions << ha; | - | ||||||||||||||||||
456 | } else { never executed: end of block | 0 | ||||||||||||||||||
457 | QQmlProperty property(d->target, QLatin1String("height")); | - | ||||||||||||||||||
458 | QQmlBinding *newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, d->heightString.value, d->target, qmlContext(this)); | - | ||||||||||||||||||
459 | newBinding->setTarget(property); | - | ||||||||||||||||||
460 | QQuickStateAction ha; | - | ||||||||||||||||||
461 | ha.property = property; | - | ||||||||||||||||||
462 | ha.toBinding = newBinding; | - | ||||||||||||||||||
463 | ha.fromValue = ha.property.read(); | - | ||||||||||||||||||
464 | ha.deletableToBinding = true; | - | ||||||||||||||||||
465 | actions << ha; | - | ||||||||||||||||||
466 | } never executed: end of block | 0 | ||||||||||||||||||
467 | } | - | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | return actions; executed 124 times by 5 tests: return actions; Executed by:
| 124 | ||||||||||||||||||
470 | } | - | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | void QQuickParentChange::saveOriginals() | - | ||||||||||||||||||
473 | { | - | ||||||||||||||||||
474 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
475 | saveCurrentValues(); | - | ||||||||||||||||||
476 | d->origParent = d->rewindParent; | - | ||||||||||||||||||
477 | d->origStackBefore = d->rewindStackBefore; | - | ||||||||||||||||||
478 | } executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
479 | - | |||||||||||||||||||
480 | /*void QQuickParentChange::copyOriginals(QQuickStateActionEvent *other) | - | ||||||||||||||||||
481 | { | - | ||||||||||||||||||
482 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
483 | QQuickParentChange *pc = static_cast<QQuickParentChange*>(other); | - | ||||||||||||||||||
484 | - | |||||||||||||||||||
485 | d->origParent = pc->d_func()->rewindParent; | - | ||||||||||||||||||
486 | d->origStackBefore = pc->d_func()->rewindStackBefore; | - | ||||||||||||||||||
487 | - | |||||||||||||||||||
488 | saveCurrentValues(); | - | ||||||||||||||||||
489 | }*/ | - | ||||||||||||||||||
490 | - | |||||||||||||||||||
491 | void QQuickParentChange::execute() | - | ||||||||||||||||||
492 | { | - | ||||||||||||||||||
493 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
494 | d->doChange(d->parent); | - | ||||||||||||||||||
495 | } executed 126 times by 5 tests: end of block Executed by:
| 126 | ||||||||||||||||||
496 | - | |||||||||||||||||||
497 | bool QQuickParentChange::isReversable() | - | ||||||||||||||||||
498 | { | - | ||||||||||||||||||
499 | return true; executed 276 times by 5 tests: return true; Executed by:
| 276 | ||||||||||||||||||
500 | } | - | ||||||||||||||||||
501 | - | |||||||||||||||||||
502 | void QQuickParentChange::reverse() | - | ||||||||||||||||||
503 | { | - | ||||||||||||||||||
504 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
505 | d->doChange(d->origParent, d->origStackBefore); | - | ||||||||||||||||||
506 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | QQuickStateActionEvent::EventType QQuickParentChange::type() const | - | ||||||||||||||||||
509 | { | - | ||||||||||||||||||
510 | return ParentChange; executed 6 times by 2 tests: return ParentChange; Executed by:
| 6 | ||||||||||||||||||
511 | } | - | ||||||||||||||||||
512 | - | |||||||||||||||||||
513 | bool QQuickParentChange::mayOverride(QQuickStateActionEvent*other) | - | ||||||||||||||||||
514 | { | - | ||||||||||||||||||
515 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
516 | if (other->type() != ParentChange)
| 0 | ||||||||||||||||||
517 | return false; never executed: return false; | 0 | ||||||||||||||||||
518 | if (QQuickParentChange *otherPC = static_cast<QQuickParentChange*>(other))
| 0 | ||||||||||||||||||
519 | return (d->target == otherPC->object()); never executed: return (d->target == otherPC->object()); | 0 | ||||||||||||||||||
520 | return false; never executed: return false; | 0 | ||||||||||||||||||
521 | } | - | ||||||||||||||||||
522 | - | |||||||||||||||||||
523 | void QQuickParentChange::saveCurrentValues() | - | ||||||||||||||||||
524 | { | - | ||||||||||||||||||
525 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
526 | if (!d->target) {
| 0-134 | ||||||||||||||||||
527 | d->rewindParent = nullptr; | - | ||||||||||||||||||
528 | d->rewindStackBefore = nullptr; | - | ||||||||||||||||||
529 | return; never executed: return; | 0 | ||||||||||||||||||
530 | } | - | ||||||||||||||||||
531 | - | |||||||||||||||||||
532 | d->rewindParent = d->target->parentItem(); | - | ||||||||||||||||||
533 | d->rewindStackBefore = nullptr; | - | ||||||||||||||||||
534 | - | |||||||||||||||||||
535 | if (!d->rewindParent)
| 32-102 | ||||||||||||||||||
536 | return; executed 32 times by 2 tests: return; Executed by:
| 32 | ||||||||||||||||||
537 | - | |||||||||||||||||||
538 | QList<QQuickItem *> children = d->rewindParent->childItems(); | - | ||||||||||||||||||
539 | for (int ii = 0; ii < children.count() - 1; ++ii) {
| 94-156 | ||||||||||||||||||
540 | if (children.at(ii) == d->target) {
| 8-148 | ||||||||||||||||||
541 | d->rewindStackBefore = children.at(ii + 1); | - | ||||||||||||||||||
542 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||
543 | } | - | ||||||||||||||||||
544 | } executed 148 times by 2 tests: end of block Executed by:
| 148 | ||||||||||||||||||
545 | } executed 102 times by 4 tests: end of block Executed by:
| 102 | ||||||||||||||||||
546 | - | |||||||||||||||||||
547 | void QQuickParentChange::rewind() | - | ||||||||||||||||||
548 | { | - | ||||||||||||||||||
549 | Q_D(QQuickParentChange); | - | ||||||||||||||||||
550 | d->doChange(d->rewindParent, d->rewindStackBefore); | - | ||||||||||||||||||
551 | } never executed: end of block | 0 | ||||||||||||||||||
552 | - | |||||||||||||||||||
553 | /*! | - | ||||||||||||||||||
554 | \qmltype AnchorChanges | - | ||||||||||||||||||
555 | \instantiates QQuickAnchorChanges | - | ||||||||||||||||||
556 | \inqmlmodule QtQuick | - | ||||||||||||||||||
557 | \ingroup qtquick-states | - | ||||||||||||||||||
558 | \brief Specifies how to change the anchors of an item in a state. | - | ||||||||||||||||||
559 | - | |||||||||||||||||||
560 | The AnchorChanges type is used to modify the anchors of an item in a \l State. | - | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | AnchorChanges cannot be used to modify the margins on an item. For this, use | - | ||||||||||||||||||
563 | PropertyChanges intead. | - | ||||||||||||||||||
564 | - | |||||||||||||||||||
565 | In the following example we change the top and bottom anchors of an item | - | ||||||||||||||||||
566 | using AnchorChanges, and the top and bottom anchor margins using | - | ||||||||||||||||||
567 | PropertyChanges: | - | ||||||||||||||||||
568 | - | |||||||||||||||||||
569 | \snippet qml/anchorchanges.qml 0 | - | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | \image anchorchanges.png | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | AnchorChanges can be animated using AnchorAnimation. | - | ||||||||||||||||||
574 | \qml | - | ||||||||||||||||||
575 | //animate our anchor changes | - | ||||||||||||||||||
576 | Transition { | - | ||||||||||||||||||
577 | AnchorAnimation {} | - | ||||||||||||||||||
578 | } | - | ||||||||||||||||||
579 | \endqml | - | ||||||||||||||||||
580 | - | |||||||||||||||||||
581 | Changes to anchor margins can be animated using NumberAnimation. | - | ||||||||||||||||||
582 | - | |||||||||||||||||||
583 | For more information on anchors see \l {anchor-layout}{Anchor Layouts}. | - | ||||||||||||||||||
584 | */ | - | ||||||||||||||||||
585 | - | |||||||||||||||||||
586 | class QQuickAnchorSetPrivate : public QObjectPrivate | - | ||||||||||||||||||
587 | { | - | ||||||||||||||||||
588 | Q_DECLARE_PUBLIC(QQuickAnchorSet) | - | ||||||||||||||||||
589 | public: | - | ||||||||||||||||||
590 | QQuickAnchorSetPrivate() | - | ||||||||||||||||||
591 | : usedAnchors(nullptr), resetAnchors(nullptr) | - | ||||||||||||||||||
592 | { | - | ||||||||||||||||||
593 | } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||
594 | - | |||||||||||||||||||
595 | QQuickAnchors::Anchors usedAnchors; | - | ||||||||||||||||||
596 | QQuickAnchors::Anchors resetAnchors; | - | ||||||||||||||||||
597 | - | |||||||||||||||||||
598 | QQmlScriptString leftScript; | - | ||||||||||||||||||
599 | QQmlScriptString rightScript; | - | ||||||||||||||||||
600 | QQmlScriptString topScript; | - | ||||||||||||||||||
601 | QQmlScriptString bottomScript; | - | ||||||||||||||||||
602 | QQmlScriptString hCenterScript; | - | ||||||||||||||||||
603 | QQmlScriptString vCenterScript; | - | ||||||||||||||||||
604 | QQmlScriptString baselineScript; | - | ||||||||||||||||||
605 | }; | - | ||||||||||||||||||
606 | - | |||||||||||||||||||
607 | QQuickAnchorSet::QQuickAnchorSet(QObject *parent) | - | ||||||||||||||||||
608 | : QObject(*new QQuickAnchorSetPrivate, parent) | - | ||||||||||||||||||
609 | { | - | ||||||||||||||||||
610 | } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||
611 | - | |||||||||||||||||||
612 | QQuickAnchorSet::~QQuickAnchorSet() | - | ||||||||||||||||||
613 | { | - | ||||||||||||||||||
614 | } | - | ||||||||||||||||||
615 | - | |||||||||||||||||||
616 | QQmlScriptString QQuickAnchorSet::top() const | - | ||||||||||||||||||
617 | { | - | ||||||||||||||||||
618 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
619 | return d->topScript; executed 2 times by 1 test: return d->topScript; Executed by:
| 2 | ||||||||||||||||||
620 | } | - | ||||||||||||||||||
621 | - | |||||||||||||||||||
622 | void QQuickAnchorSet::setTop(const QQmlScriptString &edge) | - | ||||||||||||||||||
623 | { | - | ||||||||||||||||||
624 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
625 | d->usedAnchors |= QQuickAnchors::TopAnchor; | - | ||||||||||||||||||
626 | d->topScript = edge; | - | ||||||||||||||||||
627 | if (edge.isUndefinedLiteral())
| 4-10 | ||||||||||||||||||
628 | resetTop(); executed 4 times by 1 test: resetTop(); Executed by:
| 4 | ||||||||||||||||||
629 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | void QQuickAnchorSet::resetTop() | - | ||||||||||||||||||
632 | { | - | ||||||||||||||||||
633 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
634 | d->usedAnchors &= ~QQuickAnchors::TopAnchor; | - | ||||||||||||||||||
635 | d->resetAnchors |= QQuickAnchors::TopAnchor; | - | ||||||||||||||||||
636 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
637 | - | |||||||||||||||||||
638 | QQmlScriptString QQuickAnchorSet::bottom() const | - | ||||||||||||||||||
639 | { | - | ||||||||||||||||||
640 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
641 | return d->bottomScript; executed 2 times by 1 test: return d->bottomScript; Executed by:
| 2 | ||||||||||||||||||
642 | } | - | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | void QQuickAnchorSet::setBottom(const QQmlScriptString &edge) | - | ||||||||||||||||||
645 | { | - | ||||||||||||||||||
646 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
647 | d->usedAnchors |= QQuickAnchors::BottomAnchor; | - | ||||||||||||||||||
648 | d->bottomScript = edge; | - | ||||||||||||||||||
649 | if (edge.isUndefinedLiteral())
| 0-10 | ||||||||||||||||||
650 | resetBottom(); never executed: resetBottom(); | 0 | ||||||||||||||||||
651 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
652 | - | |||||||||||||||||||
653 | void QQuickAnchorSet::resetBottom() | - | ||||||||||||||||||
654 | { | - | ||||||||||||||||||
655 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
656 | d->usedAnchors &= ~QQuickAnchors::BottomAnchor; | - | ||||||||||||||||||
657 | d->resetAnchors |= QQuickAnchors::BottomAnchor; | - | ||||||||||||||||||
658 | } never executed: end of block | 0 | ||||||||||||||||||
659 | - | |||||||||||||||||||
660 | QQmlScriptString QQuickAnchorSet::verticalCenter() const | - | ||||||||||||||||||
661 | { | - | ||||||||||||||||||
662 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
663 | return d->vCenterScript; executed 2 times by 1 test: return d->vCenterScript; Executed by:
| 2 | ||||||||||||||||||
664 | } | - | ||||||||||||||||||
665 | - | |||||||||||||||||||
666 | void QQuickAnchorSet::setVerticalCenter(const QQmlScriptString &edge) | - | ||||||||||||||||||
667 | { | - | ||||||||||||||||||
668 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
669 | d->usedAnchors |= QQuickAnchors::VCenterAnchor; | - | ||||||||||||||||||
670 | d->vCenterScript = edge; | - | ||||||||||||||||||
671 | if (edge.isUndefinedLiteral())
| 4-6 | ||||||||||||||||||
672 | resetVerticalCenter(); executed 4 times by 1 test: resetVerticalCenter(); Executed by:
| 4 | ||||||||||||||||||
673 | } executed 10 times by 3 tests: end of block Executed by:
| 10 | ||||||||||||||||||
674 | - | |||||||||||||||||||
675 | void QQuickAnchorSet::resetVerticalCenter() | - | ||||||||||||||||||
676 | { | - | ||||||||||||||||||
677 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
678 | d->usedAnchors &= ~QQuickAnchors::VCenterAnchor; | - | ||||||||||||||||||
679 | d->resetAnchors |= QQuickAnchors::VCenterAnchor; | - | ||||||||||||||||||
680 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
681 | - | |||||||||||||||||||
682 | QQmlScriptString QQuickAnchorSet::baseline() const | - | ||||||||||||||||||
683 | { | - | ||||||||||||||||||
684 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
685 | return d->baselineScript; executed 2 times by 1 test: return d->baselineScript; Executed by:
| 2 | ||||||||||||||||||
686 | } | - | ||||||||||||||||||
687 | - | |||||||||||||||||||
688 | void QQuickAnchorSet::setBaseline(const QQmlScriptString &edge) | - | ||||||||||||||||||
689 | { | - | ||||||||||||||||||
690 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
691 | d->usedAnchors |= QQuickAnchors::BaselineAnchor; | - | ||||||||||||||||||
692 | d->baselineScript = edge; | - | ||||||||||||||||||
693 | if (edge.isUndefinedLiteral())
| 0-2 | ||||||||||||||||||
694 | resetBaseline(); never executed: resetBaseline(); | 0 | ||||||||||||||||||
695 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
696 | - | |||||||||||||||||||
697 | void QQuickAnchorSet::resetBaseline() | - | ||||||||||||||||||
698 | { | - | ||||||||||||||||||
699 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
700 | d->usedAnchors &= ~QQuickAnchors::BaselineAnchor; | - | ||||||||||||||||||
701 | d->resetAnchors |= QQuickAnchors::BaselineAnchor; | - | ||||||||||||||||||
702 | } never executed: end of block | 0 | ||||||||||||||||||
703 | - | |||||||||||||||||||
704 | QQmlScriptString QQuickAnchorSet::left() const | - | ||||||||||||||||||
705 | { | - | ||||||||||||||||||
706 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
707 | return d->leftScript; executed 4 times by 1 test: return d->leftScript; Executed by:
| 4 | ||||||||||||||||||
708 | } | - | ||||||||||||||||||
709 | - | |||||||||||||||||||
710 | void QQuickAnchorSet::setLeft(const QQmlScriptString &edge) | - | ||||||||||||||||||
711 | { | - | ||||||||||||||||||
712 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
713 | d->usedAnchors |= QQuickAnchors::LeftAnchor; | - | ||||||||||||||||||
714 | d->leftScript = edge; | - | ||||||||||||||||||
715 | if (edge.isUndefinedLiteral())
| 12 | ||||||||||||||||||
716 | resetLeft(); executed 12 times by 2 tests: resetLeft(); Executed by:
| 12 | ||||||||||||||||||
717 | } executed 24 times by 3 tests: end of block Executed by:
| 24 | ||||||||||||||||||
718 | - | |||||||||||||||||||
719 | void QQuickAnchorSet::resetLeft() | - | ||||||||||||||||||
720 | { | - | ||||||||||||||||||
721 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
722 | d->usedAnchors &= ~QQuickAnchors::LeftAnchor; | - | ||||||||||||||||||
723 | d->resetAnchors |= QQuickAnchors::LeftAnchor; | - | ||||||||||||||||||
724 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||
725 | - | |||||||||||||||||||
726 | QQmlScriptString QQuickAnchorSet::right() const | - | ||||||||||||||||||
727 | { | - | ||||||||||||||||||
728 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
729 | return d->rightScript; executed 2 times by 1 test: return d->rightScript; Executed by:
| 2 | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | - | |||||||||||||||||||
732 | void QQuickAnchorSet::setRight(const QQmlScriptString &edge) | - | ||||||||||||||||||
733 | { | - | ||||||||||||||||||
734 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
735 | d->usedAnchors |= QQuickAnchors::RightAnchor; | - | ||||||||||||||||||
736 | d->rightScript = edge; | - | ||||||||||||||||||
737 | if (edge.isUndefinedLiteral())
| 2-20 | ||||||||||||||||||
738 | resetRight(); executed 2 times by 1 test: resetRight(); Executed by:
| 2 | ||||||||||||||||||
739 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||
740 | - | |||||||||||||||||||
741 | void QQuickAnchorSet::resetRight() | - | ||||||||||||||||||
742 | { | - | ||||||||||||||||||
743 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
744 | d->usedAnchors &= ~QQuickAnchors::RightAnchor; | - | ||||||||||||||||||
745 | d->resetAnchors |= QQuickAnchors::RightAnchor; | - | ||||||||||||||||||
746 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
747 | - | |||||||||||||||||||
748 | QQmlScriptString QQuickAnchorSet::horizontalCenter() const | - | ||||||||||||||||||
749 | { | - | ||||||||||||||||||
750 | Q_D(const QQuickAnchorSet); | - | ||||||||||||||||||
751 | return d->hCenterScript; executed 2 times by 1 test: return d->hCenterScript; Executed by:
| 2 | ||||||||||||||||||
752 | } | - | ||||||||||||||||||
753 | - | |||||||||||||||||||
754 | void QQuickAnchorSet::setHorizontalCenter(const QQmlScriptString &edge) | - | ||||||||||||||||||
755 | { | - | ||||||||||||||||||
756 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
757 | d->usedAnchors |= QQuickAnchors::HCenterAnchor; | - | ||||||||||||||||||
758 | d->hCenterScript = edge; | - | ||||||||||||||||||
759 | if (edge.isUndefinedLiteral())
| 4-8 | ||||||||||||||||||
760 | resetHorizontalCenter(); executed 8 times by 2 tests: resetHorizontalCenter(); Executed by:
| 8 | ||||||||||||||||||
761 | } executed 12 times by 3 tests: end of block Executed by:
| 12 | ||||||||||||||||||
762 | - | |||||||||||||||||||
763 | void QQuickAnchorSet::resetHorizontalCenter() | - | ||||||||||||||||||
764 | { | - | ||||||||||||||||||
765 | Q_D(QQuickAnchorSet); | - | ||||||||||||||||||
766 | d->usedAnchors &= ~QQuickAnchors::HCenterAnchor; | - | ||||||||||||||||||
767 | d->resetAnchors |= QQuickAnchors::HCenterAnchor; | - | ||||||||||||||||||
768 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
769 | - | |||||||||||||||||||
770 | class QQuickAnchorChangesPrivate : public QQuickStateOperationPrivate | - | ||||||||||||||||||
771 | { | - | ||||||||||||||||||
772 | public: | - | ||||||||||||||||||
773 | QQuickAnchorChangesPrivate() | - | ||||||||||||||||||
774 | : target(nullptr), anchorSet(new QQuickAnchorSet) | - | ||||||||||||||||||
775 | { | - | ||||||||||||||||||
776 | - | |||||||||||||||||||
777 | } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||
778 | ~QQuickAnchorChangesPrivate() { delete anchorSet; } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||
779 | - | |||||||||||||||||||
780 | QQuickItem *target; | - | ||||||||||||||||||
781 | QQuickAnchorSet *anchorSet; | - | ||||||||||||||||||
782 | - | |||||||||||||||||||
783 | QExplicitlySharedDataPointer<QQmlBinding> leftBinding; | - | ||||||||||||||||||
784 | QExplicitlySharedDataPointer<QQmlBinding> rightBinding; | - | ||||||||||||||||||
785 | QExplicitlySharedDataPointer<QQmlBinding> hCenterBinding; | - | ||||||||||||||||||
786 | QExplicitlySharedDataPointer<QQmlBinding> topBinding; | - | ||||||||||||||||||
787 | QExplicitlySharedDataPointer<QQmlBinding> bottomBinding; | - | ||||||||||||||||||
788 | QExplicitlySharedDataPointer<QQmlBinding> vCenterBinding; | - | ||||||||||||||||||
789 | QExplicitlySharedDataPointer<QQmlBinding> baselineBinding; | - | ||||||||||||||||||
790 | - | |||||||||||||||||||
791 | QQmlAbstractBinding::Ptr origLeftBinding; | - | ||||||||||||||||||
792 | QQmlAbstractBinding::Ptr origRightBinding; | - | ||||||||||||||||||
793 | QQmlAbstractBinding::Ptr origHCenterBinding; | - | ||||||||||||||||||
794 | QQmlAbstractBinding::Ptr origTopBinding; | - | ||||||||||||||||||
795 | QQmlAbstractBinding::Ptr origBottomBinding; | - | ||||||||||||||||||
796 | QQmlAbstractBinding::Ptr origVCenterBinding; | - | ||||||||||||||||||
797 | QQmlAbstractBinding::Ptr origBaselineBinding; | - | ||||||||||||||||||
798 | - | |||||||||||||||||||
799 | QQuickAnchorLine rewindLeft; | - | ||||||||||||||||||
800 | QQuickAnchorLine rewindRight; | - | ||||||||||||||||||
801 | QQuickAnchorLine rewindHCenter; | - | ||||||||||||||||||
802 | QQuickAnchorLine rewindTop; | - | ||||||||||||||||||
803 | QQuickAnchorLine rewindBottom; | - | ||||||||||||||||||
804 | QQuickAnchorLine rewindVCenter; | - | ||||||||||||||||||
805 | QQuickAnchorLine rewindBaseline; | - | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | qreal fromX; | - | ||||||||||||||||||
808 | qreal fromY; | - | ||||||||||||||||||
809 | qreal fromWidth; | - | ||||||||||||||||||
810 | qreal fromHeight; | - | ||||||||||||||||||
811 | - | |||||||||||||||||||
812 | qreal toX; | - | ||||||||||||||||||
813 | qreal toY; | - | ||||||||||||||||||
814 | qreal toWidth; | - | ||||||||||||||||||
815 | qreal toHeight; | - | ||||||||||||||||||
816 | - | |||||||||||||||||||
817 | qreal rewindX; | - | ||||||||||||||||||
818 | qreal rewindY; | - | ||||||||||||||||||
819 | qreal rewindWidth; | - | ||||||||||||||||||
820 | qreal rewindHeight; | - | ||||||||||||||||||
821 | - | |||||||||||||||||||
822 | bool applyOrigLeft; | - | ||||||||||||||||||
823 | bool applyOrigRight; | - | ||||||||||||||||||
824 | bool applyOrigHCenter; | - | ||||||||||||||||||
825 | bool applyOrigTop; | - | ||||||||||||||||||
826 | bool applyOrigBottom; | - | ||||||||||||||||||
827 | bool applyOrigVCenter; | - | ||||||||||||||||||
828 | bool applyOrigBaseline; | - | ||||||||||||||||||
829 | - | |||||||||||||||||||
830 | QQmlNullableValue<qreal> origWidth; | - | ||||||||||||||||||
831 | QQmlNullableValue<qreal> origHeight; | - | ||||||||||||||||||
832 | qreal origX; | - | ||||||||||||||||||
833 | qreal origY; | - | ||||||||||||||||||
834 | - | |||||||||||||||||||
835 | QQmlProperty leftProp; | - | ||||||||||||||||||
836 | QQmlProperty rightProp; | - | ||||||||||||||||||
837 | QQmlProperty hCenterProp; | - | ||||||||||||||||||
838 | QQmlProperty topProp; | - | ||||||||||||||||||
839 | QQmlProperty bottomProp; | - | ||||||||||||||||||
840 | QQmlProperty vCenterProp; | - | ||||||||||||||||||
841 | QQmlProperty baselineProp; | - | ||||||||||||||||||
842 | }; | - | ||||||||||||||||||
843 | - | |||||||||||||||||||
844 | QQuickAnchorChanges::QQuickAnchorChanges(QObject *parent) | - | ||||||||||||||||||
845 | : QQuickStateOperation(*(new QQuickAnchorChangesPrivate), parent) | - | ||||||||||||||||||
846 | { | - | ||||||||||||||||||
847 | } executed 36 times by 5 tests: end of block Executed by:
| 36 | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | QQuickAnchorChanges::~QQuickAnchorChanges() | - | ||||||||||||||||||
850 | { | - | ||||||||||||||||||
851 | } | - | ||||||||||||||||||
852 | - | |||||||||||||||||||
853 | QQuickAnchorChanges::ActionList QQuickAnchorChanges::actions() | - | ||||||||||||||||||
854 | { | - | ||||||||||||||||||
855 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
856 | //### ASSERT these are all 0? | - | ||||||||||||||||||
857 | d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding | - | ||||||||||||||||||
858 | = d->bottomBinding = d->vCenterBinding = d->baselineBinding = nullptr; | - | ||||||||||||||||||
859 | - | |||||||||||||||||||
860 | d->leftProp = QQmlProperty(d->target, QLatin1String("anchors.left")); | - | ||||||||||||||||||
861 | d->rightProp = QQmlProperty(d->target, QLatin1String("anchors.right")); | - | ||||||||||||||||||
862 | d->hCenterProp = QQmlProperty(d->target, QLatin1String("anchors.horizontalCenter")); | - | ||||||||||||||||||
863 | d->topProp = QQmlProperty(d->target, QLatin1String("anchors.top")); | - | ||||||||||||||||||
864 | d->bottomProp = QQmlProperty(d->target, QLatin1String("anchors.bottom")); | - | ||||||||||||||||||
865 | d->vCenterProp = QQmlProperty(d->target, QLatin1String("anchors.verticalCenter")); | - | ||||||||||||||||||
866 | d->baselineProp = QQmlProperty(d->target, QLatin1String("anchors.baseline")); | - | ||||||||||||||||||
867 | - | |||||||||||||||||||
868 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::LeftAnchor) {
| 14-26 | ||||||||||||||||||
869 | d->leftBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->leftProp)->core, d->anchorSet->d_func()->leftScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
870 | d->leftBinding->setTarget(d->leftProp); | - | ||||||||||||||||||
871 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
872 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::RightAnchor) {
| 18-22 | ||||||||||||||||||
873 | d->rightBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->rightProp)->core, d->anchorSet->d_func()->rightScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
874 | d->rightBinding->setTarget(d->rightProp); | - | ||||||||||||||||||
875 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||
876 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::HCenterAnchor) {
| 4-36 | ||||||||||||||||||
877 | d->hCenterBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->hCenterProp)->core, d->anchorSet->d_func()->hCenterScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
878 | d->hCenterBinding->setTarget(d->hCenterProp); | - | ||||||||||||||||||
879 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
880 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::TopAnchor) {
| 14-26 | ||||||||||||||||||
881 | d->topBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->topProp)->core, d->anchorSet->d_func()->topScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
882 | d->topBinding->setTarget(d->topProp); | - | ||||||||||||||||||
883 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||
884 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::BottomAnchor) {
| 14-26 | ||||||||||||||||||
885 | d->bottomBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->bottomProp)->core, d->anchorSet->d_func()->bottomScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
886 | d->bottomBinding->setTarget(d->bottomProp); | - | ||||||||||||||||||
887 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||
888 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::VCenterAnchor) {
| 6-34 | ||||||||||||||||||
889 | d->vCenterBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->vCenterProp)->core, d->anchorSet->d_func()->vCenterScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
890 | d->vCenterBinding->setTarget(d->vCenterProp); | - | ||||||||||||||||||
891 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
892 | if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::BaselineAnchor) {
| 2-38 | ||||||||||||||||||
893 | d->baselineBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(d->baselineProp)->core, d->anchorSet->d_func()->baselineScript, d->target, qmlContext(this)); | - | ||||||||||||||||||
894 | d->baselineBinding->setTarget(d->baselineProp); | - | ||||||||||||||||||
895 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | QQuickStateAction a; | - | ||||||||||||||||||
898 | a.event = this; | - | ||||||||||||||||||
899 | return ActionList() << a; executed 40 times by 5 tests: return ActionList() << a; Executed by:
| 40 | ||||||||||||||||||
900 | } | - | ||||||||||||||||||
901 | - | |||||||||||||||||||
902 | QQuickAnchorSet *QQuickAnchorChanges::anchors() const | - | ||||||||||||||||||
903 | { | - | ||||||||||||||||||
904 | Q_D(const QQuickAnchorChanges); | - | ||||||||||||||||||
905 | return d->anchorSet; executed 52 times by 5 tests: return d->anchorSet; Executed by:
| 52 | ||||||||||||||||||
906 | } | - | ||||||||||||||||||
907 | - | |||||||||||||||||||
908 | /*! | - | ||||||||||||||||||
909 | \qmlproperty Item QtQuick::AnchorChanges::target | - | ||||||||||||||||||
910 | This property holds the \l Item for which the anchor changes will be applied. | - | ||||||||||||||||||
911 | */ | - | ||||||||||||||||||
912 | QQuickItem *QQuickAnchorChanges::object() const | - | ||||||||||||||||||
913 | { | - | ||||||||||||||||||
914 | Q_D(const QQuickAnchorChanges); | - | ||||||||||||||||||
915 | return d->target; executed 80 times by 2 tests: return d->target; Executed by:
| 80 | ||||||||||||||||||
916 | } | - | ||||||||||||||||||
917 | - | |||||||||||||||||||
918 | void QQuickAnchorChanges::setObject(QQuickItem *target) | - | ||||||||||||||||||
919 | { | - | ||||||||||||||||||
920 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
921 | d->target = target; | - | ||||||||||||||||||
922 | } executed 34 times by 5 tests: end of block Executed by:
| 34 | ||||||||||||||||||
923 | - | |||||||||||||||||||
924 | /*! | - | ||||||||||||||||||
925 | \qmlpropertygroup QtQuick::AnchorChanges::anchors | - | ||||||||||||||||||
926 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.left | - | ||||||||||||||||||
927 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.right | - | ||||||||||||||||||
928 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.horizontalCenter | - | ||||||||||||||||||
929 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.top | - | ||||||||||||||||||
930 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.bottom | - | ||||||||||||||||||
931 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.verticalCenter | - | ||||||||||||||||||
932 | \qmlproperty AnchorLine QtQuick::AnchorChanges::anchors.baseline | - | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | These properties change the respective anchors of the item. | - | ||||||||||||||||||
935 | - | |||||||||||||||||||
936 | To reset an anchor you can assign \c undefined: | - | ||||||||||||||||||
937 | \qml | - | ||||||||||||||||||
938 | AnchorChanges { | - | ||||||||||||||||||
939 | target: myItem | - | ||||||||||||||||||
940 | anchors.left: undefined //remove myItem's left anchor | - | ||||||||||||||||||
941 | anchors.right: otherItem.right | - | ||||||||||||||||||
942 | } | - | ||||||||||||||||||
943 | \endqml | - | ||||||||||||||||||
944 | */ | - | ||||||||||||||||||
945 | - | |||||||||||||||||||
946 | void QQuickAnchorChanges::execute() | - | ||||||||||||||||||
947 | { | - | ||||||||||||||||||
948 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
949 | if (!d->target)
| 2-44 | ||||||||||||||||||
950 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
951 | - | |||||||||||||||||||
952 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
953 | //incorporate any needed "reverts" | - | ||||||||||||||||||
954 | if (d->applyOrigLeft) {
| 8-36 | ||||||||||||||||||
955 | if (!d->origLeftBinding)
| 0-8 | ||||||||||||||||||
956 | targetPrivate->anchors()->resetLeft(); never executed: targetPrivate->anchors()->resetLeft(); | 0 | ||||||||||||||||||
957 | QQmlPropertyPrivate::setBinding(d->leftProp, d->origLeftBinding.data()); | - | ||||||||||||||||||
958 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
959 | if (d->applyOrigRight) {
| 8-36 | ||||||||||||||||||
960 | if (!d->origRightBinding)
| 0-8 | ||||||||||||||||||
961 | targetPrivate->anchors()->resetRight(); never executed: targetPrivate->anchors()->resetRight(); | 0 | ||||||||||||||||||
962 | QQmlPropertyPrivate::setBinding(d->rightProp, d->origRightBinding.data()); | - | ||||||||||||||||||
963 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
964 | if (d->applyOrigHCenter) {
| 0-44 | ||||||||||||||||||
965 | if (!d->origHCenterBinding)
| 0 | ||||||||||||||||||
966 | targetPrivate->anchors()->resetHorizontalCenter(); never executed: targetPrivate->anchors()->resetHorizontalCenter(); | 0 | ||||||||||||||||||
967 | QQmlPropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding.data()); | - | ||||||||||||||||||
968 | } never executed: end of block | 0 | ||||||||||||||||||
969 | if (d->applyOrigTop) {
| 8-36 | ||||||||||||||||||
970 | if (!d->origTopBinding)
| 0-8 | ||||||||||||||||||
971 | targetPrivate->anchors()->resetTop(); never executed: targetPrivate->anchors()->resetTop(); | 0 | ||||||||||||||||||
972 | QQmlPropertyPrivate::setBinding(d->topProp, d->origTopBinding.data()); | - | ||||||||||||||||||
973 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
974 | if (d->applyOrigBottom) {
| 8-36 | ||||||||||||||||||
975 | if (!d->origBottomBinding)
| 0-8 | ||||||||||||||||||
976 | targetPrivate->anchors()->resetBottom(); never executed: targetPrivate->anchors()->resetBottom(); | 0 | ||||||||||||||||||
977 | QQmlPropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding.data()); | - | ||||||||||||||||||
978 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
979 | if (d->applyOrigVCenter) {
| 0-44 | ||||||||||||||||||
980 | if (!d->origVCenterBinding)
| 0 | ||||||||||||||||||
981 | targetPrivate->anchors()->resetVerticalCenter(); never executed: targetPrivate->anchors()->resetVerticalCenter(); | 0 | ||||||||||||||||||
982 | QQmlPropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding.data()); | - | ||||||||||||||||||
983 | } never executed: end of block | 0 | ||||||||||||||||||
984 | if (d->applyOrigBaseline) {
| 0-44 | ||||||||||||||||||
985 | if (!d->origBaselineBinding)
| 0 | ||||||||||||||||||
986 | targetPrivate->anchors()->resetBaseline(); never executed: targetPrivate->anchors()->resetBaseline(); | 0 | ||||||||||||||||||
987 | QQmlPropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding.data()); | - | ||||||||||||||||||
988 | } never executed: end of block | 0 | ||||||||||||||||||
989 | - | |||||||||||||||||||
990 | //reset any anchors that have been specified as "undefined" | - | ||||||||||||||||||
991 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::LeftAnchor) {
| 18-26 | ||||||||||||||||||
992 | targetPrivate->anchors()->resetLeft(); | - | ||||||||||||||||||
993 | QQmlPropertyPrivate::removeBinding(d->leftProp); | - | ||||||||||||||||||
994 | } executed 18 times by 2 tests: end of block Executed by:
| 18 | ||||||||||||||||||
995 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::RightAnchor) {
| 8-36 | ||||||||||||||||||
996 | targetPrivate->anchors()->resetRight(); | - | ||||||||||||||||||
997 | QQmlPropertyPrivate::removeBinding(d->rightProp); | - | ||||||||||||||||||
998 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
999 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::HCenterAnchor) {
| 8-36 | ||||||||||||||||||
1000 | targetPrivate->anchors()->resetHorizontalCenter(); | - | ||||||||||||||||||
1001 | QQmlPropertyPrivate::removeBinding(d->hCenterProp); | - | ||||||||||||||||||
1002 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
1003 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::TopAnchor) {
| 4-40 | ||||||||||||||||||
1004 | targetPrivate->anchors()->resetTop(); | - | ||||||||||||||||||
1005 | QQmlPropertyPrivate::removeBinding(d->topProp); | - | ||||||||||||||||||
1006 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
1007 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::BottomAnchor) {
| 0-44 | ||||||||||||||||||
1008 | targetPrivate->anchors()->resetBottom(); | - | ||||||||||||||||||
1009 | QQmlPropertyPrivate::removeBinding(d->bottomProp); | - | ||||||||||||||||||
1010 | } never executed: end of block | 0 | ||||||||||||||||||
1011 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::VCenterAnchor) {
| 4-40 | ||||||||||||||||||
1012 | targetPrivate->anchors()->resetVerticalCenter(); | - | ||||||||||||||||||
1013 | QQmlPropertyPrivate::removeBinding(d->vCenterProp); | - | ||||||||||||||||||
1014 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
1015 | if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::BaselineAnchor) {
| 0-44 | ||||||||||||||||||
1016 | targetPrivate->anchors()->resetBaseline(); | - | ||||||||||||||||||
1017 | QQmlPropertyPrivate::removeBinding(d->baselineProp); | - | ||||||||||||||||||
1018 | } never executed: end of block | 0 | ||||||||||||||||||
1019 | - | |||||||||||||||||||
1020 | //set any anchors that have been specified | - | ||||||||||||||||||
1021 | if (d->leftBinding)
| 16-28 | ||||||||||||||||||
1022 | QQmlPropertyPrivate::setBinding(d->leftBinding.data()); executed 16 times by 3 tests: QQmlPropertyPrivate::setBinding(d->leftBinding.data()); Executed by:
| 16 | ||||||||||||||||||
1023 | if (d->rightBinding)
| 20-24 | ||||||||||||||||||
1024 | QQmlPropertyPrivate::setBinding(d->rightBinding.data()); executed 24 times by 3 tests: QQmlPropertyPrivate::setBinding(d->rightBinding.data()); Executed by:
| 24 | ||||||||||||||||||
1025 | if (d->hCenterBinding)
| 4-40 | ||||||||||||||||||
1026 | QQmlPropertyPrivate::setBinding(d->hCenterBinding.data()); executed 4 times by 1 test: QQmlPropertyPrivate::setBinding(d->hCenterBinding.data()); Executed by:
| 4 | ||||||||||||||||||
1027 | if (d->topBinding)
| 18-26 | ||||||||||||||||||
1028 | QQmlPropertyPrivate::setBinding(d->topBinding.data()); executed 18 times by 2 tests: QQmlPropertyPrivate::setBinding(d->topBinding.data()); Executed by:
| 18 | ||||||||||||||||||
1029 | if (d->bottomBinding)
| 20-24 | ||||||||||||||||||
1030 | QQmlPropertyPrivate::setBinding(d->bottomBinding.data()); executed 20 times by 2 tests: QQmlPropertyPrivate::setBinding(d->bottomBinding.data()); Executed by:
| 20 | ||||||||||||||||||
1031 | if (d->vCenterBinding)
| 6-38 | ||||||||||||||||||
1032 | QQmlPropertyPrivate::setBinding(d->vCenterBinding.data()); executed 6 times by 2 tests: QQmlPropertyPrivate::setBinding(d->vCenterBinding.data()); Executed by:
| 6 | ||||||||||||||||||
1033 | if (d->baselineBinding)
| 2-42 | ||||||||||||||||||
1034 | QQmlPropertyPrivate::setBinding(d->baselineBinding.data()); executed 2 times by 1 test: QQmlPropertyPrivate::setBinding(d->baselineBinding.data()); Executed by:
| 2 | ||||||||||||||||||
1035 | } executed 44 times by 5 tests: end of block Executed by:
| 44 | ||||||||||||||||||
1036 | - | |||||||||||||||||||
1037 | bool QQuickAnchorChanges::isReversable() | - | ||||||||||||||||||
1038 | { | - | ||||||||||||||||||
1039 | return true; executed 104 times by 5 tests: return true; Executed by:
| 104 | ||||||||||||||||||
1040 | } | - | ||||||||||||||||||
1041 | - | |||||||||||||||||||
1042 | void QQuickAnchorChanges::reverse() | - | ||||||||||||||||||
1043 | { | - | ||||||||||||||||||
1044 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1045 | if (!d->target)
| 0-24 | ||||||||||||||||||
1046 | return; never executed: return; | 0 | ||||||||||||||||||
1047 | - | |||||||||||||||||||
1048 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
1049 | //reset any anchors set by the state | - | ||||||||||||||||||
1050 | if (d->leftBinding) {
| 10-14 | ||||||||||||||||||
1051 | targetPrivate->anchors()->resetLeft(); | - | ||||||||||||||||||
1052 | QQmlPropertyPrivate::removeBinding(d->leftBinding.data()); | - | ||||||||||||||||||
1053 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1054 | if (d->rightBinding) {
| 4-20 | ||||||||||||||||||
1055 | targetPrivate->anchors()->resetRight(); | - | ||||||||||||||||||
1056 | QQmlPropertyPrivate::removeBinding(d->rightBinding.data()); | - | ||||||||||||||||||
1057 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||||||||||||||
1058 | if (d->hCenterBinding) {
| 0-24 | ||||||||||||||||||
1059 | targetPrivate->anchors()->resetHorizontalCenter(); | - | ||||||||||||||||||
1060 | QQmlPropertyPrivate::removeBinding(d->hCenterBinding.data()); | - | ||||||||||||||||||
1061 | } never executed: end of block | 0 | ||||||||||||||||||
1062 | if (d->topBinding) {
| 8-16 | ||||||||||||||||||
1063 | targetPrivate->anchors()->resetTop(); | - | ||||||||||||||||||
1064 | QQmlPropertyPrivate::removeBinding(d->topBinding.data()); | - | ||||||||||||||||||
1065 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
1066 | if (d->bottomBinding) {
| 10-14 | ||||||||||||||||||
1067 | targetPrivate->anchors()->resetBottom(); | - | ||||||||||||||||||
1068 | QQmlPropertyPrivate::removeBinding(d->bottomBinding.data()); | - | ||||||||||||||||||
1069 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1070 | if (d->vCenterBinding) {
| 0-24 | ||||||||||||||||||
1071 | targetPrivate->anchors()->resetVerticalCenter(); | - | ||||||||||||||||||
1072 | QQmlPropertyPrivate::removeBinding(d->vCenterBinding.data()); | - | ||||||||||||||||||
1073 | } never executed: end of block | 0 | ||||||||||||||||||
1074 | if (d->baselineBinding) {
| 0-24 | ||||||||||||||||||
1075 | targetPrivate->anchors()->resetBaseline(); | - | ||||||||||||||||||
1076 | QQmlPropertyPrivate::removeBinding(d->baselineBinding.data()); | - | ||||||||||||||||||
1077 | } never executed: end of block | 0 | ||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | //restore previous anchors | - | ||||||||||||||||||
1080 | if (d->origLeftBinding)
| 6-18 | ||||||||||||||||||
1081 | QQmlPropertyPrivate::setBinding(d->leftProp, d->origLeftBinding.data()); executed 18 times by 2 tests: QQmlPropertyPrivate::setBinding(d->leftProp, d->origLeftBinding.data()); Executed by:
| 18 | ||||||||||||||||||
1082 | if (d->origRightBinding)
| 8-16 | ||||||||||||||||||
1083 | QQmlPropertyPrivate::setBinding(d->rightProp, d->origRightBinding.data()); executed 8 times by 2 tests: QQmlPropertyPrivate::setBinding(d->rightProp, d->origRightBinding.data()); Executed by:
| 8 | ||||||||||||||||||
1084 | if (d->origHCenterBinding)
| 4-20 | ||||||||||||||||||
1085 | QQmlPropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding.data()); executed 4 times by 1 test: QQmlPropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding.data()); Executed by:
| 4 | ||||||||||||||||||
1086 | if (d->origTopBinding)
| 8-16 | ||||||||||||||||||
1087 | QQmlPropertyPrivate::setBinding(d->topProp, d->origTopBinding.data()); executed 8 times by 2 tests: QQmlPropertyPrivate::setBinding(d->topProp, d->origTopBinding.data()); Executed by:
| 8 | ||||||||||||||||||
1088 | if (d->origBottomBinding)
| 10-14 | ||||||||||||||||||
1089 | QQmlPropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding.data()); executed 10 times by 2 tests: QQmlPropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding.data()); Executed by:
| 10 | ||||||||||||||||||
1090 | if (d->origVCenterBinding)
| 4-20 | ||||||||||||||||||
1091 | QQmlPropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding.data()); executed 4 times by 1 test: QQmlPropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding.data()); Executed by:
| 4 | ||||||||||||||||||
1092 | if (d->origBaselineBinding)
| 0-24 | ||||||||||||||||||
1093 | QQmlPropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding.data()); never executed: QQmlPropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding.data()); | 0 | ||||||||||||||||||
1094 | - | |||||||||||||||||||
1095 | //restore any absolute geometry changed by the state's anchors | - | ||||||||||||||||||
1096 | QQuickAnchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QQuickAnchors::Vertical_Mask; | - | ||||||||||||||||||
1097 | QQuickAnchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QQuickAnchors::Vertical_Mask; | - | ||||||||||||||||||
1098 | QQuickAnchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QQuickAnchors::Horizontal_Mask; | - | ||||||||||||||||||
1099 | QQuickAnchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QQuickAnchors::Horizontal_Mask; | - | ||||||||||||||||||
1100 | - | |||||||||||||||||||
1101 | bool stateSetWidth = (stateHAnchors && | - | ||||||||||||||||||
1102 | stateHAnchors != QQuickAnchors::LeftAnchor &&
| 0-20 | ||||||||||||||||||
1103 | stateHAnchors != QQuickAnchors::RightAnchor &&
| 10 | ||||||||||||||||||
1104 | stateHAnchors != QQuickAnchors::HCenterAnchor);
| 0-10 | ||||||||||||||||||
1105 | bool origSetWidth = (origHAnchors && | - | ||||||||||||||||||
1106 | origHAnchors != QQuickAnchors::LeftAnchor &&
| 10-12 | ||||||||||||||||||
1107 | origHAnchors != QQuickAnchors::RightAnchor &&
| 0-12 | ||||||||||||||||||
1108 | origHAnchors != QQuickAnchors::HCenterAnchor);
| 4-8 | ||||||||||||||||||
1109 | if (d->origWidth.isValid() && stateSetWidth && !origSetWidth)
| 2-22 | ||||||||||||||||||
1110 | d->target->setWidth(d->origWidth.value); executed 2 times by 1 test: d->target->setWidth(d->origWidth.value); Executed by:
| 2 | ||||||||||||||||||
1111 | - | |||||||||||||||||||
1112 | bool stateSetHeight = (stateVAnchors && | - | ||||||||||||||||||
1113 | stateVAnchors != QQuickAnchors::TopAnchor &&
| 0-10 | ||||||||||||||||||
1114 | stateVAnchors != QQuickAnchors::BottomAnchor &&
| 2-8 | ||||||||||||||||||
1115 | stateVAnchors != QQuickAnchors::VCenterAnchor &&
| 0-8 | ||||||||||||||||||
1116 | stateVAnchors != QQuickAnchors::BaselineAnchor);
| 0-8 | ||||||||||||||||||
1117 | bool origSetHeight = (origVAnchors && | - | ||||||||||||||||||
1118 | origVAnchors != QQuickAnchors::TopAnchor &&
| 0-14 | ||||||||||||||||||
1119 | origVAnchors != QQuickAnchors::BottomAnchor &&
| 2-12 | ||||||||||||||||||
1120 | origVAnchors != QQuickAnchors::VCenterAnchor &&
| 4-8 | ||||||||||||||||||
1121 | origVAnchors != QQuickAnchors::BaselineAnchor);
| 0-8 | ||||||||||||||||||
1122 | if (d->origHeight.isValid() && stateSetHeight && !origSetHeight)
| 0-22 | ||||||||||||||||||
1123 | d->target->setHeight(d->origHeight.value); never executed: d->target->setHeight(d->origHeight.value); | 0 | ||||||||||||||||||
1124 | - | |||||||||||||||||||
1125 | if (stateHAnchors && !origHAnchors)
| 2-18 | ||||||||||||||||||
1126 | d->target->setX(d->origX); executed 2 times by 1 test: d->target->setX(d->origX); Executed by:
| 2 | ||||||||||||||||||
1127 | - | |||||||||||||||||||
1128 | if (stateVAnchors && !origVAnchors)
| 2-8 | ||||||||||||||||||
1129 | d->target->setY(d->origY); executed 2 times by 1 test: d->target->setY(d->origY); Executed by:
| 2 | ||||||||||||||||||
1130 | } executed 24 times by 3 tests: end of block Executed by:
| 24 | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | QQuickStateActionEvent::EventType QQuickAnchorChanges::type() const | - | ||||||||||||||||||
1133 | { | - | ||||||||||||||||||
1134 | return AnchorChanges; executed 26 times by 3 tests: return AnchorChanges; Executed by:
| 26 | ||||||||||||||||||
1135 | } | - | ||||||||||||||||||
1136 | - | |||||||||||||||||||
1137 | QList<QQuickStateAction> QQuickAnchorChanges::additionalActions() const | - | ||||||||||||||||||
1138 | { | - | ||||||||||||||||||
1139 | Q_D(const QQuickAnchorChanges); | - | ||||||||||||||||||
1140 | QList<QQuickStateAction> extra; | - | ||||||||||||||||||
1141 | - | |||||||||||||||||||
1142 | QQuickAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; | - | ||||||||||||||||||
1143 | bool hChange = combined & QQuickAnchors::Horizontal_Mask; | - | ||||||||||||||||||
1144 | bool vChange = combined & QQuickAnchors::Vertical_Mask; | - | ||||||||||||||||||
1145 | - | |||||||||||||||||||
1146 | if (d->target) {
| 0-10 | ||||||||||||||||||
1147 | QQuickStateAction a; | - | ||||||||||||||||||
1148 | if (hChange && d->fromX != d->toX) {
| 0-10 | ||||||||||||||||||
1149 | a.property = QQmlProperty(d->target, QLatin1String("x")); | - | ||||||||||||||||||
1150 | a.toValue = d->toX; | - | ||||||||||||||||||
1151 | extra << a; | - | ||||||||||||||||||
1152 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
1153 | if (vChange && d->fromY != d->toY) {
| 0-8 | ||||||||||||||||||
1154 | a.property = QQmlProperty(d->target, QLatin1String("y")); | - | ||||||||||||||||||
1155 | a.toValue = d->toY; | - | ||||||||||||||||||
1156 | extra << a; | - | ||||||||||||||||||
1157 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
1158 | if (hChange && d->fromWidth != d->toWidth) {
| 0-10 | ||||||||||||||||||
1159 | a.property = QQmlProperty(d->target, QLatin1String("width")); | - | ||||||||||||||||||
1160 | a.toValue = d->toWidth; | - | ||||||||||||||||||
1161 | extra << a; | - | ||||||||||||||||||
1162 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
1163 | if (vChange && d->fromHeight != d->toHeight) {
| 0-8 | ||||||||||||||||||
1164 | a.property = QQmlProperty(d->target, QLatin1String("height")); | - | ||||||||||||||||||
1165 | a.toValue = d->toHeight; | - | ||||||||||||||||||
1166 | extra << a; | - | ||||||||||||||||||
1167 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
1168 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1169 | - | |||||||||||||||||||
1170 | return extra; executed 10 times by 2 tests: return extra; Executed by:
| 10 | ||||||||||||||||||
1171 | } | - | ||||||||||||||||||
1172 | - | |||||||||||||||||||
1173 | bool QQuickAnchorChanges::changesBindings() | - | ||||||||||||||||||
1174 | { | - | ||||||||||||||||||
1175 | return true; executed 124 times by 5 tests: return true; Executed by:
| 124 | ||||||||||||||||||
1176 | } | - | ||||||||||||||||||
1177 | - | |||||||||||||||||||
1178 | void QQuickAnchorChanges::saveOriginals() | - | ||||||||||||||||||
1179 | { | - | ||||||||||||||||||
1180 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1181 | if (!d->target)
| 2-34 | ||||||||||||||||||
1182 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
1183 | - | |||||||||||||||||||
1184 | d->origLeftBinding = QQmlPropertyPrivate::binding(d->leftProp); | - | ||||||||||||||||||
1185 | d->origRightBinding = QQmlPropertyPrivate::binding(d->rightProp); | - | ||||||||||||||||||
1186 | d->origHCenterBinding = QQmlPropertyPrivate::binding(d->hCenterProp); | - | ||||||||||||||||||
1187 | d->origTopBinding = QQmlPropertyPrivate::binding(d->topProp); | - | ||||||||||||||||||
1188 | d->origBottomBinding = QQmlPropertyPrivate::binding(d->bottomProp); | - | ||||||||||||||||||
1189 | d->origVCenterBinding = QQmlPropertyPrivate::binding(d->vCenterProp); | - | ||||||||||||||||||
1190 | d->origBaselineBinding = QQmlPropertyPrivate::binding(d->baselineProp); | - | ||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
1193 | if (targetPrivate->widthValid)
| 6-28 | ||||||||||||||||||
1194 | d->origWidth = d->target->width(); executed 28 times by 5 tests: d->origWidth = d->target->width(); Executed by:
| 28 | ||||||||||||||||||
1195 | if (targetPrivate->heightValid)
| 6-28 | ||||||||||||||||||
1196 | d->origHeight = d->target->height(); executed 28 times by 5 tests: d->origHeight = d->target->height(); Executed by:
| 28 | ||||||||||||||||||
1197 | d->origX = d->target->x(); | - | ||||||||||||||||||
1198 | d->origY = d->target->y(); | - | ||||||||||||||||||
1199 | - | |||||||||||||||||||
1200 | d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop | - | ||||||||||||||||||
1201 | = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false; | - | ||||||||||||||||||
1202 | - | |||||||||||||||||||
1203 | saveCurrentValues(); | - | ||||||||||||||||||
1204 | } executed 34 times by 5 tests: end of block Executed by:
| 34 | ||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | void QQuickAnchorChanges::copyOriginals(QQuickStateActionEvent *other) | - | ||||||||||||||||||
1207 | { | - | ||||||||||||||||||
1208 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1209 | QQuickAnchorChanges *ac = static_cast<QQuickAnchorChanges*>(other); | - | ||||||||||||||||||
1210 | QQuickAnchorChangesPrivate *acp = ac->d_func(); | - | ||||||||||||||||||
1211 | - | |||||||||||||||||||
1212 | QQuickAnchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors | | - | ||||||||||||||||||
1213 | acp->anchorSet->d_func()->resetAnchors; | - | ||||||||||||||||||
1214 | - | |||||||||||||||||||
1215 | //probably also need to revert some things | - | ||||||||||||||||||
1216 | d->applyOrigLeft = (combined & QQuickAnchors::LeftAnchor); | - | ||||||||||||||||||
1217 | d->applyOrigRight = (combined & QQuickAnchors::RightAnchor); | - | ||||||||||||||||||
1218 | d->applyOrigHCenter = (combined & QQuickAnchors::HCenterAnchor); | - | ||||||||||||||||||
1219 | d->applyOrigTop = (combined & QQuickAnchors::TopAnchor); | - | ||||||||||||||||||
1220 | d->applyOrigBottom = (combined & QQuickAnchors::BottomAnchor); | - | ||||||||||||||||||
1221 | d->applyOrigVCenter = (combined & QQuickAnchors::VCenterAnchor); | - | ||||||||||||||||||
1222 | d->applyOrigBaseline = (combined & QQuickAnchors::BaselineAnchor); | - | ||||||||||||||||||
1223 | - | |||||||||||||||||||
1224 | d->origLeftBinding = acp->origLeftBinding; | - | ||||||||||||||||||
1225 | d->origRightBinding = acp->origRightBinding; | - | ||||||||||||||||||
1226 | d->origHCenterBinding = acp->origHCenterBinding; | - | ||||||||||||||||||
1227 | d->origTopBinding = acp->origTopBinding; | - | ||||||||||||||||||
1228 | d->origBottomBinding = acp->origBottomBinding; | - | ||||||||||||||||||
1229 | d->origVCenterBinding = acp->origVCenterBinding; | - | ||||||||||||||||||
1230 | d->origBaselineBinding = acp->origBaselineBinding; | - | ||||||||||||||||||
1231 | - | |||||||||||||||||||
1232 | d->origWidth = acp->origWidth; | - | ||||||||||||||||||
1233 | d->origHeight = acp->origHeight; | - | ||||||||||||||||||
1234 | d->origX = acp->origX; | - | ||||||||||||||||||
1235 | d->origY = acp->origY; | - | ||||||||||||||||||
1236 | - | |||||||||||||||||||
1237 | //clear old values from other | - | ||||||||||||||||||
1238 | //### could this be generalized for all QQuickStateActionEvents, and called after copyOriginals? | - | ||||||||||||||||||
1239 | acp->leftBinding = nullptr; | - | ||||||||||||||||||
1240 | acp->rightBinding = nullptr; | - | ||||||||||||||||||
1241 | acp->hCenterBinding = nullptr; | - | ||||||||||||||||||
1242 | acp->topBinding = nullptr; | - | ||||||||||||||||||
1243 | acp->bottomBinding = nullptr; | - | ||||||||||||||||||
1244 | acp->vCenterBinding = nullptr; | - | ||||||||||||||||||
1245 | acp->baselineBinding = nullptr; | - | ||||||||||||||||||
1246 | acp->origLeftBinding = nullptr; | - | ||||||||||||||||||
1247 | acp->origRightBinding = nullptr; | - | ||||||||||||||||||
1248 | acp->origHCenterBinding = nullptr; | - | ||||||||||||||||||
1249 | acp->origTopBinding = nullptr; | - | ||||||||||||||||||
1250 | acp->origBottomBinding = nullptr; | - | ||||||||||||||||||
1251 | acp->origVCenterBinding = nullptr; | - | ||||||||||||||||||
1252 | acp->origBaselineBinding = nullptr; | - | ||||||||||||||||||
1253 | - | |||||||||||||||||||
1254 | saveCurrentValues(); | - | ||||||||||||||||||
1255 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
1256 | - | |||||||||||||||||||
1257 | void QQuickAnchorChanges::clearBindings() | - | ||||||||||||||||||
1258 | { | - | ||||||||||||||||||
1259 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1260 | if (!d->target)
| 2-80 | ||||||||||||||||||
1261 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
1262 | - | |||||||||||||||||||
1263 | //### should this (saving "from" values) be moved to saveCurrentValues()? | - | ||||||||||||||||||
1264 | d->fromX = d->target->x(); | - | ||||||||||||||||||
1265 | d->fromY = d->target->y(); | - | ||||||||||||||||||
1266 | d->fromWidth = d->target->width(); | - | ||||||||||||||||||
1267 | d->fromHeight = d->target->height(); | - | ||||||||||||||||||
1268 | - | |||||||||||||||||||
1269 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
1270 | //reset any anchors with corresponding reverts | - | ||||||||||||||||||
1271 | //reset any anchors that have been specified as "undefined" | - | ||||||||||||||||||
1272 | //reset any anchors that we'll be setting in the state | - | ||||||||||||||||||
1273 | QQuickAnchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | | - | ||||||||||||||||||
1274 | d->anchorSet->d_func()->usedAnchors; | - | ||||||||||||||||||
1275 | if (d->applyOrigLeft || (combined & QQuickAnchors::LeftAnchor)) {
| 12-68 | ||||||||||||||||||
1276 | targetPrivate->anchors()->resetLeft(); | - | ||||||||||||||||||
1277 | QQmlPropertyPrivate::removeBinding(d->leftProp); | - | ||||||||||||||||||
1278 | } executed 62 times by 3 tests: end of block Executed by:
| 62 | ||||||||||||||||||
1279 | if (d->applyOrigRight || (combined & QQuickAnchors::RightAnchor)) {
| 12-68 | ||||||||||||||||||
1280 | targetPrivate->anchors()->resetRight(); | - | ||||||||||||||||||
1281 | QQmlPropertyPrivate::removeBinding(d->rightProp); | - | ||||||||||||||||||
1282 | } executed 64 times by 3 tests: end of block Executed by:
| 64 | ||||||||||||||||||
1283 | if (d->applyOrigHCenter || (combined & QQuickAnchors::HCenterAnchor)) {
| 0-80 | ||||||||||||||||||
1284 | targetPrivate->anchors()->resetHorizontalCenter(); | - | ||||||||||||||||||
1285 | QQmlPropertyPrivate::removeBinding(d->hCenterProp); | - | ||||||||||||||||||
1286 | } executed 16 times by 3 tests: end of block Executed by:
| 16 | ||||||||||||||||||
1287 | if (d->applyOrigTop || (combined & QQuickAnchors::TopAnchor)) {
| 12-68 | ||||||||||||||||||
1288 | targetPrivate->anchors()->resetTop(); | - | ||||||||||||||||||
1289 | QQmlPropertyPrivate::removeBinding(d->topProp); | - | ||||||||||||||||||
1290 | } executed 38 times by 3 tests: end of block Executed by:
| 38 | ||||||||||||||||||
1291 | if (d->applyOrigBottom || (combined & QQuickAnchors::BottomAnchor)) {
| 12-68 | ||||||||||||||||||
1292 | targetPrivate->anchors()->resetBottom(); | - | ||||||||||||||||||
1293 | QQmlPropertyPrivate::removeBinding(d->bottomProp); | - | ||||||||||||||||||
1294 | } executed 38 times by 2 tests: end of block Executed by:
| 38 | ||||||||||||||||||
1295 | if (d->applyOrigVCenter || (combined & QQuickAnchors::VCenterAnchor)) {
| 0-80 | ||||||||||||||||||
1296 | targetPrivate->anchors()->resetVerticalCenter(); | - | ||||||||||||||||||
1297 | QQmlPropertyPrivate::removeBinding(d->vCenterProp); | - | ||||||||||||||||||
1298 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
1299 | if (d->applyOrigBaseline || (combined & QQuickAnchors::BaselineAnchor)) {
| 0-80 | ||||||||||||||||||
1300 | targetPrivate->anchors()->resetBaseline(); | - | ||||||||||||||||||
1301 | QQmlPropertyPrivate::removeBinding(d->baselineProp); | - | ||||||||||||||||||
1302 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
1303 | } executed 80 times by 5 tests: end of block Executed by:
| 80 | ||||||||||||||||||
1304 | - | |||||||||||||||||||
1305 | bool QQuickAnchorChanges::mayOverride(QQuickStateActionEvent*other) | - | ||||||||||||||||||
1306 | { | - | ||||||||||||||||||
1307 | if (other->type() != AnchorChanges)
| 0-4 | ||||||||||||||||||
1308 | return false; never executed: return false; | 0 | ||||||||||||||||||
1309 | if (static_cast<QQuickStateActionEvent*>(this) == other)
| 0-4 | ||||||||||||||||||
1310 | return true; never executed: return true; | 0 | ||||||||||||||||||
1311 | if (static_cast<QQuickAnchorChanges*>(other)->object() == object())
| 0-4 | ||||||||||||||||||
1312 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||
1313 | return false; never executed: return false; | 0 | ||||||||||||||||||
1314 | } | - | ||||||||||||||||||
1315 | - | |||||||||||||||||||
1316 | void QQuickAnchorChanges::rewind() | - | ||||||||||||||||||
1317 | { | - | ||||||||||||||||||
1318 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1319 | if (!d->target)
| 0-10 | ||||||||||||||||||
1320 | return; never executed: return; | 0 | ||||||||||||||||||
1321 | - | |||||||||||||||||||
1322 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
1323 | - | |||||||||||||||||||
1324 | //restore previous values (but not previous bindings, i.e. anchors) | - | ||||||||||||||||||
1325 | d->target->setX(d->rewindX); | - | ||||||||||||||||||
1326 | d->target->setY(d->rewindY); | - | ||||||||||||||||||
1327 | if (targetPrivate->widthValid) {
| 0-10 | ||||||||||||||||||
1328 | d->target->setWidth(d->rewindWidth); | - | ||||||||||||||||||
1329 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1330 | if (targetPrivate->heightValid) {
| 0-10 | ||||||||||||||||||
1331 | d->target->setHeight(d->rewindHeight); | - | ||||||||||||||||||
1332 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1333 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1334 | - | |||||||||||||||||||
1335 | void QQuickAnchorChanges::saveCurrentValues() | - | ||||||||||||||||||
1336 | { | - | ||||||||||||||||||
1337 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1338 | if (!d->target)
| 0-60 | ||||||||||||||||||
1339 | return; never executed: return; | 0 | ||||||||||||||||||
1340 | - | |||||||||||||||||||
1341 | QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target); | - | ||||||||||||||||||
1342 | d->rewindLeft = targetPrivate->anchors()->left(); | - | ||||||||||||||||||
1343 | d->rewindRight = targetPrivate->anchors()->right(); | - | ||||||||||||||||||
1344 | d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); | - | ||||||||||||||||||
1345 | d->rewindTop = targetPrivate->anchors()->top(); | - | ||||||||||||||||||
1346 | d->rewindBottom = targetPrivate->anchors()->bottom(); | - | ||||||||||||||||||
1347 | d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); | - | ||||||||||||||||||
1348 | d->rewindBaseline = targetPrivate->anchors()->baseline(); | - | ||||||||||||||||||
1349 | - | |||||||||||||||||||
1350 | d->rewindX = d->target->x(); | - | ||||||||||||||||||
1351 | d->rewindY = d->target->y(); | - | ||||||||||||||||||
1352 | d->rewindWidth = d->target->width(); | - | ||||||||||||||||||
1353 | d->rewindHeight = d->target->height(); | - | ||||||||||||||||||
1354 | } executed 60 times by 5 tests: end of block Executed by:
| 60 | ||||||||||||||||||
1355 | - | |||||||||||||||||||
1356 | void QQuickAnchorChanges::saveTargetValues() | - | ||||||||||||||||||
1357 | { | - | ||||||||||||||||||
1358 | Q_D(QQuickAnchorChanges); | - | ||||||||||||||||||
1359 | if (!d->target)
| 0-10 | ||||||||||||||||||
1360 | return; never executed: return; | 0 | ||||||||||||||||||
1361 | - | |||||||||||||||||||
1362 | d->toX = d->target->x(); | - | ||||||||||||||||||
1363 | d->toY = d->target->y(); | - | ||||||||||||||||||
1364 | d->toWidth = d->target->width(); | - | ||||||||||||||||||
1365 | d->toHeight = d->target->height(); | - | ||||||||||||||||||
1366 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||
1367 | - | |||||||||||||||||||
1368 | #include <moc_qquickstateoperations_p.cpp> | - | ||||||||||||||||||
1369 | - | |||||||||||||||||||
1370 | QT_END_NAMESPACE | - | ||||||||||||||||||
1371 | - | |||||||||||||||||||
Source code | Switch to Preprocessed file |