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.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_H
6#define QQUICKSTATE_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 <qqml.h>
20#include <qqmlproperty.h>
21#include <QtCore/qobject.h>
22#include <QtCore/qsharedpointer.h>
23#include <private/qtquickglobal_p.h>
24#include <private/qqmlabstractbinding_p.h>
25#include <private/qqmlanybinding_p.h>
26
27#include <QtCore/private/qproperty_p.h>
28
30
31Q_DECLARE_LOGGING_CATEGORY(lcStates)
32
33class QQuickStateActionEvent;
34class QQmlBinding;
35class QQmlExpression;
36
37class Q_QUICK_EXPORT QQuickStateAction
38{
39public:
40 QQuickStateAction();
41 QQuickStateAction(QObject *, const QString &, const QVariant &);
42 QQuickStateAction(QObject *, const QQmlProperty &property, const QString &,
43 const QVariant &);
44
45 bool restore:1;
46 bool actionDone:1;
47 bool reverseEvent:1;
48 bool deletableToBinding:1;
49
50 QQmlProperty property;
51 QVariant fromValue;
52 QVariant toValue;
53
54 QQmlAnyBinding fromBinding;
55 QQmlAnyBinding toBinding;
56 QQuickStateActionEvent *event;
57
58 //strictly for matching
59 QObject *specifiedObject;
60 QString specifiedProperty;
61
62 void deleteFromBinding();
63};
64
65class Q_AUTOTEST_EXPORT QQuickStateActionEvent
66{
67public:
68 virtual ~QQuickStateActionEvent();
69
70 enum EventType { Script, SignalHandler, ParentChange, AnchorChanges };
71
72 virtual EventType type() const = 0;
73
74 virtual void execute();
75 virtual bool isReversable();
76 virtual void reverse();
77 virtual void saveOriginals() {}
78 virtual bool needsCopy() { return false; }
79 virtual void copyOriginals(QQuickStateActionEvent *) {}
80
81 virtual bool isRewindable() { return isReversable(); }
82 virtual void rewind() {}
83 virtual void saveCurrentValues() {}
84 virtual void saveTargetValues() {}
85
86 virtual bool changesBindings();
87 virtual void clearBindings();
88 virtual bool mayOverride(QQuickStateActionEvent*other);
89};
90
91//### rename to QQuickStateChange?
92class QQuickStateGroup;
93class QQuickState;
95class Q_QUICK_EXPORT QQuickStateOperation : public QObject
96{
97 Q_OBJECT
98 QML_ANONYMOUS
99 QML_ADDED_IN_VERSION(2, 0)
100public:
101 QQuickStateOperation(QObject *parent = nullptr)
102 : QObject(parent) {}
103 typedef QList<QQuickStateAction> ActionList;
104
105 virtual ActionList actions();
106
107 QQuickState *state() const;
108 void setState(QQuickState *state);
109
110protected:
111 QQuickStateOperation(QObjectPrivate &dd, QObject *parent = nullptr);
112
113private:
114 Q_DECLARE_PRIVATE(QQuickStateOperation)
115 Q_DISABLE_COPY(QQuickStateOperation)
116};
117
119
120class QQuickTransition;
122class Q_QUICK_EXPORT QQuickState : public QObject
123{
124 Q_OBJECT
125
126 Q_PROPERTY(QString name READ name WRITE setName)
127 Q_PROPERTY(bool when READ when WRITE setWhen)
128 Q_PROPERTY(QString extend READ extends WRITE setExtends)
129 Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes)
130 Q_CLASSINFO("DefaultProperty", "changes")
131 Q_CLASSINFO("DeferredPropertyNames", "changes")
132 QML_NAMED_ELEMENT(State)
133 QML_ADDED_IN_VERSION(2, 0)
134
135public:
136 QQuickState(QObject *parent=nullptr);
137 ~QQuickState() override;
138
139 QString name() const;
140 void setName(const QString &);
141 bool isNamed() const;
142
143 bool isWhenKnown() const;
144 bool when() const;
145 void setWhen(bool);
146
147 QString extends() const;
148 void setExtends(const QString &);
149
150 QQmlListProperty<QQuickStateOperation> changes();
151 int operationCount() const;
152 QQuickStateOperation *operationAt(int) const;
153
154 QQuickState &operator<<(QQuickStateOperation *);
155
156 void apply(QQuickTransition *, QQuickState *revert);
157 void cancel();
158
159 QQuickStateGroup *stateGroup() const;
160 void setStateGroup(QQuickStateGroup *);
161
162 bool containsPropertyInRevertList(QObject *target, const QString &name) const;
163 bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
164 bool changeBindingInRevertList(QObject *target, const QString &name, QQmlAnyBinding binding);
165 bool removeEntryFromRevertList(QObject *target, const QString &name);
166 void addEntryToRevertList(const QQuickStateAction &action);
167 void removeAllEntriesFromRevertList(QObject *target);
168 void addEntriesToRevertList(const QList<QQuickStateAction> &actions);
169 QVariant valueInRevertList(QObject *target, const QString &name) const;
170 QQmlAnyBinding bindingInRevertList(QObject *target, const QString &name) const;
171
172 bool isStateActive() const;
173
174Q_SIGNALS:
175 void completed();
176
177private:
178 Q_DECLARE_PRIVATE(QQuickState)
179 Q_DISABLE_COPY(QQuickState)
180};
181
182QT_END_NAMESPACE
183
184#endif // QQUICKSTATE_H
The QQmlScriptString class encapsulates a script and its context.
void animationCurrentLoopChanged(QAbstractAnimationJob *job) override
QAbstractAnimationAction * createAction()
void debugAction(QDebug d, int indentLevel) const
QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
\qmltype RotationAnimation \nativetype QQuickRotationAnimation \inqmlmodule QtQuick\inherits Property...
QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
QQuickStateOperation::ActionList QQuickStateActions