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 <private/qtqmlglobal_p.h> |
19 | |
20 | #include <QtQml/qqml.h> |
21 | #include <QtCore/qobject.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQmlBindPrivate; |
26 | class Q_QML_PRIVATE_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 | |
56 | bool when() const; |
57 | void setWhen(bool); |
58 | |
59 | QObject *object(); |
60 | void setObject(QObject *); |
61 | |
62 | QString property() const; |
63 | void setProperty(const QString &); |
64 | |
65 | QVariant value() const; |
66 | void setValue(const QVariant &); |
67 | |
68 | bool delayed() const; |
69 | void setDelayed(bool); |
70 | |
71 | RestorationMode restoreMode() const; |
72 | void setRestoreMode(RestorationMode); |
73 | |
74 | Q_SIGNALS: |
75 | void restoreModeChanged(); |
76 | |
77 | protected: |
78 | void setTarget(const QQmlProperty &) override; |
79 | void classBegin() override; |
80 | void componentComplete() override; |
81 | |
82 | private: |
83 | void prepareEval(); |
84 | void eval(); |
85 | |
86 | private Q_SLOTS: |
87 | void targetValueChanged(); |
88 | }; |
89 | |
90 | QT_END_NAMESPACE |
91 | |
92 | QML_DECLARE_TYPE(QQmlBind) |
93 | |
94 | #endif |
95 | |