| 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 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QQuickPropertyChangesPrivate; |
| 24 | class Q_QUICK_EXPORT QQuickPropertyChanges : public QQuickStateOperation |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | Q_DECLARE_PRIVATE(QQuickPropertyChanges) |
| 28 | Q_PROPERTY(QObject *target READ object WRITE setObject NOTIFY objectChanged) |
| 29 | Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues |
| 30 | NOTIFY restoreEntryValuesChanged) |
| 31 | Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit NOTIFY isExplicitChanged) |
| 32 | QML_NAMED_ELEMENT(PropertyChanges) |
| 33 | QML_ADDED_IN_VERSION(2, 0) |
| 34 | QML_CUSTOMPARSER |
| 35 | Q_CLASSINFO("ImmediatePropertyNames" , "target,restoreEntryValues,explicit,objectName" ) |
| 36 | |
| 37 | public: |
| 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 | |
| 66 | Q_SIGNALS: |
| 67 | void objectChanged(); |
| 68 | void restoreEntryValuesChanged(); |
| 69 | void isExplicitChanged(); |
| 70 | }; |
| 71 | |
| 72 | class QQuickPropertyChangesParser : public QQmlCustomParser |
| 73 | { |
| 74 | public: |
| 75 | QQuickPropertyChangesParser() |
| 76 | : QQmlCustomParser(AcceptsAttachedProperties) {} |
| 77 | |
| 78 | void verifyList( |
| 79 | const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, |
| 80 | const QV4::CompiledData::Binding *binding); |
| 81 | |
| 82 | void verifyBindings( |
| 83 | const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, |
| 84 | const QList<const QV4::CompiledData::Binding *> &props) override; |
| 85 | void applyBindings( |
| 86 | QObject *obj, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, |
| 87 | const QList<const QV4::CompiledData::Binding *> &bindings) override; |
| 88 | }; |
| 89 | |
| 90 | template<> |
| 91 | inline QQmlCustomParser *qmlCreateCustomParser<QQuickPropertyChanges>() |
| 92 | { |
| 93 | return new QQuickPropertyChangesParser; |
| 94 | } |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif // QQUICKPROPERTYCHANGES_H |
| 99 | |