| 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 QQMLBIND_H |
| 5 | #define QQMLBIND_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 <QtQmlMeta/qtqmlmetaexports.h> |
| 19 | |
| 20 | #include <QtQml/qqml.h> |
| 21 | #include <QtCore/qobject.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQmlBindPrivate; |
| 26 | class Q_QMLMETA_EXPORT QQmlBind : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus |
| 27 | { |
| 28 | public: |
| 29 | enum RestorationMode { |
| 30 | RestoreNone = 0x0, |
| 31 | RestoreBinding = 0x1, |
| 32 | RestoreValue = 0x2, |
| 33 | RestoreBindingOrValue = RestoreBinding | RestoreValue |
| 34 | }; |
| 35 | |
| 36 | private: |
| 37 | Q_OBJECT |
| 38 | Q_DECLARE_PRIVATE(QQmlBind) |
| 39 | Q_INTERFACES(QQmlParserStatus) |
| 40 | Q_INTERFACES(QQmlPropertyValueSource) |
| 41 | Q_PROPERTY(QObject *target READ object WRITE setObject NOTIFY objectChanged) |
| 42 | Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) |
| 43 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) |
| 44 | Q_PROPERTY(bool when READ when WRITE setWhen NOTIFY whenChanged) |
| 45 | Q_PROPERTY(bool delayed READ delayed WRITE setDelayed NOTIFY delayedChanged REVISION(2, 8)) |
| 46 | Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode |
| 47 | NOTIFY restoreModeChanged REVISION(2, 14)) |
| 48 | Q_ENUM(RestorationMode) |
| 49 | QML_NAMED_ELEMENT(Binding) |
| 50 | QML_ADDED_IN_VERSION(2, 0) |
| 51 | Q_CLASSINFO("ImmediatePropertyNames" , "objectName,target,property,value,when,delayed,restoreMode" ); |
| 52 | |
| 53 | public: |
| 54 | QQmlBind(QObject *parent=nullptr); |
| 55 | ~QQmlBind(); |
| 56 | |
| 57 | bool when() const; |
| 58 | void setWhen(bool); |
| 59 | |
| 60 | QObject *object() const; |
| 61 | void setObject(QObject *); |
| 62 | |
| 63 | QString property() const; |
| 64 | void setProperty(const QString &); |
| 65 | |
| 66 | QVariant value() const; |
| 67 | void setValue(const QVariant &); |
| 68 | |
| 69 | bool delayed() const; |
| 70 | void setDelayed(bool); |
| 71 | |
| 72 | RestorationMode restoreMode() const; |
| 73 | void setRestoreMode(RestorationMode); |
| 74 | |
| 75 | Q_SIGNALS: |
| 76 | void restoreModeChanged(); |
| 77 | Q_REVISION(6, 10) void objectChanged(); |
| 78 | Q_REVISION(6, 10) void propertyChanged(); |
| 79 | Q_REVISION(6, 10) void valueChanged(); |
| 80 | Q_REVISION(6, 10) void whenChanged(); |
| 81 | Q_REVISION(6, 10) void delayedChanged(); |
| 82 | |
| 83 | protected: |
| 84 | void setTarget(const QQmlProperty &) override; |
| 85 | void classBegin() override; |
| 86 | void componentComplete() override; |
| 87 | |
| 88 | private: |
| 89 | void prepareEval(); |
| 90 | void eval(); |
| 91 | |
| 92 | private Q_SLOTS: |
| 93 | void targetValueChanged(); |
| 94 | }; |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif |
| 99 | |