| 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) | 
| 42 |     Q_PROPERTY(QString property READ property WRITE setProperty) | 
| 43 |     Q_PROPERTY(QVariant value READ value WRITE setValue) | 
| 44 |     Q_PROPERTY(bool when READ when WRITE setWhen) | 
| 45 |     Q_PROPERTY(bool delayed READ delayed WRITE setDelayed 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(); | 
| 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 |  | 
| 78 | protected: | 
| 79 |     void setTarget(const QQmlProperty &) override; | 
| 80 |     void classBegin() override; | 
| 81 |     void componentComplete() override; | 
| 82 |  | 
| 83 | private: | 
| 84 |     void prepareEval(); | 
| 85 |     void eval(); | 
| 86 |  | 
| 87 | private Q_SLOTS: | 
| 88 |     void targetValueChanged(); | 
| 89 | }; | 
| 90 |  | 
| 91 | QT_END_NAMESPACE | 
| 92 |  | 
| 93 | #endif | 
| 94 |  |