Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickstate_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSTATE_P_H
6#define QQUICKSTATE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qquickstate_p.h"
20
22
23#include <private/qqmlproperty_p.h>
24#include <private/qqmlguard_p.h>
25
26#include <private/qqmlbinding_p.h>
27
28#include <private/qobject_p.h>
29
31
33{
34public:
36 QQuickSimpleAction(const QQuickStateAction &a, State state = StartState)
37 {
38 m_property = a.property;
39 m_specifiedObject = a.specifiedObject;
40 m_specifiedProperty = a.specifiedProperty;
41 m_event = a.event;
42 if (state == StartState) {
43 m_value = a.fromValue;
44 m_binding = QQmlAnyBinding::ofProperty(m_property);
45 m_reverseEvent = true;
46 } else {
47 m_value = a.toValue;
48 m_binding = a.toBinding;
49 m_reverseEvent = false;
50 }
51 }
52
54 {
55 }
56
61 m_specifiedObject(other.m_specifiedObject),
64 m_reverseEvent(other.m_reverseEvent)
65 {
66 }
67
69 {
70 m_property = other.m_property;
71 m_value = other.m_value;
72 m_binding = other.binding();
73 m_specifiedObject = other.m_specifiedObject;
74 m_specifiedProperty = other.m_specifiedProperty;
75 m_event = other.m_event;
76 m_reverseEvent = other.m_reverseEvent;
77
78 return *this;
79 }
80
81 void setProperty(const QQmlProperty &property)
82 {
83 m_property = property;
84 }
85
86 const QQmlProperty &property() const
87 {
88 return m_property;
89 }
90
91 void setValue(const QVariant &value)
92 {
93 m_value = value;
94 }
95
96 const QVariant &value() const
97 {
98 return m_value;
99 }
100
101 void setBinding(QQmlAnyBinding binding)
102 {
103 m_binding = binding;
104 }
105
107 {
108 return m_binding;
109 }
110
111 QObject *specifiedObject() const
112 {
113 return m_specifiedObject;
114 }
115
117 {
118 return m_specifiedProperty;
119 }
120
122 {
123 return m_event;
124 }
125
126 bool reverseEvent() const
127 {
128 return m_reverseEvent;
129 }
130
131private:
132 QQmlProperty m_property;
133 QVariant m_value;
134 QQmlAnyBinding m_binding;
135 QObject *m_specifiedObject;
136 QString m_specifiedProperty;
137 QQuickStateActionEvent *m_event;
138 bool m_reverseEvent;
139};
140
142{
143public:
144 QQuickRevertAction() : event(nullptr) {}
145 QQuickRevertAction(const QQmlProperty &prop) : property(prop), event(nullptr) {}
146 QQuickRevertAction(QQuickStateActionEvent *e) : event(e) {}
147 QQmlProperty property;
149};
150
152{
153 Q_DECLARE_PUBLIC(QQuickStateOperation)
154
155public:
156
159
161};
162
164{
165 Q_DECLARE_PUBLIC(QQuickState)
166
167public:
169 : when(false), whenKnown(false), named(false), inState(false), group(nullptr) {}
170
172
174 bool when;
176 bool named;
177
179 {
180 OperationGuard(QObject *obj, QList<OperationGuard> *l) : QQmlGuard<QQuickStateOperation>(
182 ,list(l)
183 {
184 setObject(static_cast<QQuickStateOperation *>(obj));
185 }
187
188 private:
189 static void objectDestroyedImpl(QQmlGuardImpl *guard) {
190 auto This = static_cast<OperationGuard *>(guard);
191 // we assume priv will always be destroyed after objectDestroyed calls
192 This->list->removeOne(*This);
193 }
194 };
196
197 static void operations_append(QQmlListProperty<QQuickStateOperation> *prop, QQuickStateOperation *op) {
198 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
199 op->setState(qobject_cast<QQuickState*>(prop->object));
200 list->append(OperationGuard(op, list));
201 }
202 static void operations_clear(QQmlListProperty<QQuickStateOperation> *prop) {
203 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
204 for (auto &e : *list)
205 e->setState(nullptr);
206 list->clear();
207 }
208 static qsizetype operations_count(QQmlListProperty<QQuickStateOperation> *prop) {
209 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
210 return list->size();
211 }
212 static QQuickStateOperation *operations_at(QQmlListProperty<QQuickStateOperation> *prop, qsizetype index) {
213 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
214 return list->at(index);
215 }
216 static void operations_replace(QQmlListProperty<QQuickStateOperation> *prop, qsizetype index,
217 QQuickStateOperation *op) {
218 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
219 auto &guard = list->at(index);
220 if (guard.object() == op) {
221 op->setState(qobject_cast<QQuickState*>(prop->object));
222 } else {
223 list->at(index)->setState(nullptr);
224 op->setState(qobject_cast<QQuickState*>(prop->object));
225 list->replace(index, OperationGuard(op, list));
226 }
227 }
228 static void operations_removeLast(QQmlListProperty<QQuickStateOperation> *prop) {
229 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
230 list->last()->setState(nullptr);
231 list->removeLast();
232 }
233
235
239 mutable bool inState;
240 QQuickStateGroup *group;
241
243 void complete();
244};
245
246QT_END_NAMESPACE
247
248#endif // QQUICKSTATE_P_H
QQuickRevertAction(QQuickStateActionEvent *e)
QQuickRevertAction(const QQmlProperty &prop)
QQuickStateActionEvent * event
const QVariant & value() const
QQuickStateActionEvent * event() const
QQuickSimpleAction & operator=(const QQuickSimpleAction &other)
void setProperty(const QQmlProperty &property)
bool reverseEvent() const
QObject * specifiedObject() const
const QQmlProperty & property() const
void setValue(const QVariant &value)
const QString & specifiedProperty() const
QQmlAnyBinding binding() const
void setBinding(QQmlAnyBinding binding)
QQuickSimpleAction(const QQuickSimpleAction &other)
QQuickSimpleAction(const QQuickStateAction &a, State state=StartState)
SimpleActionList revertList
static void operations_append(QQmlListProperty< QQuickStateOperation > *prop, QQuickStateOperation *op)
static qsizetype operations_count(QQmlListProperty< QQuickStateOperation > *prop)
static void operations_clear(QQmlListProperty< QQuickStateOperation > *prop)
static QQuickStateOperation * operations_at(QQmlListProperty< QQuickStateOperation > *prop, qsizetype index)
QQuickTransitionManager transitionManager
QList< QQuickRevertAction > reverting
static void operations_removeLast(QQmlListProperty< QQuickStateOperation > *prop)
QList< OperationGuard > operations
static void operations_replace(QQmlListProperty< QQuickStateOperation > *prop, qsizetype index, QQuickStateOperation *op)
QQuickStateGroup * group
QList< OperationGuard > * list
OperationGuard(QObject *obj, QList< OperationGuard > *l)