Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QQUICKSTATE_P_H
5#define QQUICKSTATE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickstate_p.h"
19
21
22#include <private/qqmlproperty_p.h>
23#include <private/qqmlguard_p.h>
24
25#include <private/qqmlbinding_p.h>
26
27#include <private/qobject_p.h>
28
30
32{
33public:
36 {
37 m_property = a.property;
38 m_specifiedObject = a.specifiedObject;
39 m_specifiedProperty = a.specifiedProperty;
40 m_event = a.event;
41 if (state == StartState) {
42 m_value = a.fromValue;
43 m_binding = QQmlAnyBinding::ofProperty(m_property);
44 m_reverseEvent = true;
45 } else {
46 m_value = a.toValue;
47 m_binding = a.toBinding;
48 m_reverseEvent = false;
49 }
50 }
51
55
57 : m_property(other.m_property),
58 m_value(other.m_value),
59 m_binding(other.binding()),
60 m_specifiedObject(other.m_specifiedObject),
61 m_specifiedProperty(other.m_specifiedProperty),
62 m_event(other.m_event),
63 m_reverseEvent(other.m_reverseEvent)
64 {
65 }
66
68 {
69 m_property = other.m_property;
70 m_value = other.m_value;
71 m_binding = other.binding();
72 m_specifiedObject = other.m_specifiedObject;
73 m_specifiedProperty = other.m_specifiedProperty;
74 m_event = other.m_event;
75 m_reverseEvent = other.m_reverseEvent;
76
77 return *this;
78 }
79
81 {
82 m_property = property;
83 }
84
85 const QQmlProperty &property() const
86 {
87 return m_property;
88 }
89
90 void setValue(const QVariant &value)
91 {
92 m_value = value;
93 }
94
95 const QVariant &value() const
96 {
97 return m_value;
98 }
99
101 {
102 m_binding = binding;
103 }
104
106 {
107 return m_binding;
108 }
109
111 {
112 return m_specifiedObject;
113 }
114
116 {
117 return m_specifiedProperty;
118 }
119
121 {
122 return m_event;
123 }
124
125 bool reverseEvent() const
126 {
127 return m_reverseEvent;
128 }
129
130private:
131 QQmlProperty m_property;
132 QVariant m_value;
133 QQmlAnyBinding m_binding;
134 QObject *m_specifiedObject;
135 QString m_specifiedProperty;
136 QQuickStateActionEvent *m_event;
137 bool m_reverseEvent;
138};
139
149
151{
152 Q_DECLARE_PUBLIC(QQuickStateOperation)
153
154public:
155
158
160};
161
163{
164 Q_DECLARE_PUBLIC(QQuickState)
165
166public:
169
170 typedef QList<QQuickSimpleAction> SimpleActionList;
171
173 bool when;
175 bool named;
176
177 struct OperationGuard : public QQmlGuard<QQuickStateOperation>
178 {
180 OperationGuard::objectDestroyedImpl, nullptr)
181 ,list(l)
182 {
183 setObject(static_cast<QQuickStateOperation *>(obj));
184 }
185 QList<OperationGuard> *list;
186
187 private:
188 static void objectDestroyedImpl(QQmlGuardImpl *guard) {
189 auto This = static_cast<OperationGuard *>(guard);
190 // we assume priv will always be destroyed after objectDestroyed calls
191 This->list->removeOne(*This);
192 }
193 };
194 QList<OperationGuard> operations;
195
196 static void operations_append(QQmlListProperty<QQuickStateOperation> *prop, QQuickStateOperation *op) {
197 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
198 op->setState(qobject_cast<QQuickState*>(prop->object));
200 }
201 static void operations_clear(QQmlListProperty<QQuickStateOperation> *prop) {
202 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
203 for (auto &e : *list)
204 e->setState(nullptr);
205 list->clear();
206 }
207 static qsizetype operations_count(QQmlListProperty<QQuickStateOperation> *prop) {
208 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
209 return list->size();
210 }
211 static QQuickStateOperation *operations_at(QQmlListProperty<QQuickStateOperation> *prop, qsizetype index) {
212 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
213 return list->at(index);
214 }
215 static void operations_replace(QQmlListProperty<QQuickStateOperation> *prop, qsizetype index,
217 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
218 auto &guard = list->at(index);
219 if (guard.object() == op) {
220 op->setState(qobject_cast<QQuickState*>(prop->object));
221 } else {
222 list->at(index)->setState(nullptr);
223 op->setState(qobject_cast<QQuickState*>(prop->object));
225 }
226 }
227 static void operations_removeLast(QQmlListProperty<QQuickStateOperation> *prop) {
228 QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
229 list->last()->setState(nullptr);
230 list->removeLast();
231 }
232
234
236 QList<QQuickRevertAction> reverting;
238 mutable bool inState;
240
242 void complete();
243};
244
246
247#endif // QQUICKSTATE_P_H
qsizetype size() const noexcept
Definition qlist.h:397
T & last()
Definition qlist.h:648
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
void replace(qsizetype i, parameter_type t)
Definition qlist.h:543
void removeLast() noexcept
Definition qlist.h:815
void append(parameter_type t)
Definition qlist.h:458
void clear()
Definition qlist.h:434
\inmodule QtCore
Definition qobject.h:103
QQmlAnyBinding is an abstraction over the various bindings in QML.
static QQmlAnyBinding ofProperty(const QQmlProperty &prop)
void setObject(QQuickStateOperation *g)
Definition qqmlguard_p.h:62
The QQmlProperty class abstracts accessing properties on objects created from QML.
QMetaProperty property() const
Returns the \l{QMetaProperty} {Qt property} associated with this QML property.
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)
void setState(QQuickState *state)
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)
QQuickStateOperation::ActionList generateActionList() const
QList< OperationGuard > operations
static void operations_replace(QQmlListProperty< QQuickStateOperation > *prop, qsizetype index, QQuickStateOperation *op)
QQuickStateGroup * group
QList< QQuickSimpleAction > SimpleActionList
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
else opt state
[0]
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLboolean GLuint group
struct _cl_event * event
GLhandleARB obj
[2]
ptrdiff_t qsizetype
Definition qtypes.h:165
QList< int > list
[14]
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QList< OperationGuard > * list
OperationGuard(QObject *obj, QList< OperationGuard > *l)