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 QQUICKPROPERTYCHANGES_H
5#define QQUICKPROPERTYCHANGES_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 "qquickstatechangescript_p.h"
19#include <private/qqmlcustomparser_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QQuickPropertyChangesPrivate;
24class Q_QUICK_PRIVATE_EXPORT QQuickPropertyChanges : public QQuickStateOperation
25{
26 Q_OBJECT
27 Q_DECLARE_PRIVATE(QQuickPropertyChanges)
28 Q_PROPERTY(QObject *target READ object WRITE setObject NOTIFY objectChanged FINAL)
29 Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues
30 NOTIFY restoreEntryValuesChanged FINAL)
31 Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit NOTIFY isExplicitChanged FINAL)
32 QML_NAMED_ELEMENT(PropertyChanges)
33 QML_ADDED_IN_VERSION(2, 0)
34 QML_CUSTOMPARSER
35 Q_CLASSINFO("ImmediatePropertyNames", "target,restoreEntryValues,explicit,objectName")
36
37public:
38 QQuickPropertyChanges();
39 ~QQuickPropertyChanges();
40
41 QObject *object() const;
42 void setObject(QObject *);
43
44 bool restoreEntryValues() const;
45 void setRestoreEntryValues(bool);
46
47 bool isExplicit() const;
48 void setIsExplicit(bool);
49
50 ActionList actions() override;
51
52 bool containsProperty(const QString &name) const;
53 bool containsValue(const QString &name) const;
54 bool containsExpression(const QString &name) const;
55 void changeValue(const QString &name, const QVariant &value);
56 void changeExpression(const QString &name, const QString &expression);
57 void removeProperty(const QString &name);
58 QVariant value(const QString &name) const;
59 QString expression(const QString &name) const;
60
61 void detachFromState();
62 void attachToState();
63
64 QVariant property(const QString &name) const;
65
66Q_SIGNALS:
67 void objectChanged();
68 void restoreEntryValuesChanged();
69 void isExplicitChanged();
70};
71
72class QQuickPropertyChangesParser : public QQmlCustomParser
73{
74public:
75 QQuickPropertyChangesParser()
76 : QQmlCustomParser(AcceptsAttachedProperties) {}
77
78 void verifyList(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding);
79
80 void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
81 void applyBindings(QObject *obj, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
82};
83
84template<>
85inline QQmlCustomParser *qmlCreateCustomParser<QQuickPropertyChanges>()
86{
87 return new QQuickPropertyChangesParser;
88}
89
90QT_END_NAMESPACE
91
92QML_DECLARE_TYPE(QQuickPropertyChanges)
93
94#endif // QQUICKPROPERTYCHANGES_H
95

source code of qtdeclarative/src/quick/util/qquickpropertychanges_p.h