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 QQMLOPENMETAOBJECT_H |
5 | #define QQMLOPENMETAOBJECT_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 <QtCore/QMetaObject> |
19 | #include <QtCore/QObject> |
20 | |
21 | #include <private/qqmlrefcount_p.h> |
22 | #include <private/qtqmlglobal_p.h> |
23 | #include <private/qobject_p.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | |
28 | class QQmlEngine; |
29 | class QMetaPropertyBuilder; |
30 | class QQmlOpenMetaObjectTypePrivate; |
31 | class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObjectType |
32 | : public QQmlRefCounted<QQmlOpenMetaObjectType> |
33 | { |
34 | public: |
35 | QQmlOpenMetaObjectType(const QMetaObject *base); |
36 | ~QQmlOpenMetaObjectType() override; |
37 | |
38 | void createProperties(const QVector<QByteArray> &names); |
39 | int createProperty(const QByteArray &name); |
40 | |
41 | int propertyOffset() const; |
42 | int signalOffset() const; |
43 | |
44 | int propertyCount() const; |
45 | QByteArray propertyName(int) const; |
46 | |
47 | protected: |
48 | virtual void propertyCreated(int, QMetaPropertyBuilder &); |
49 | |
50 | private: |
51 | QQmlOpenMetaObjectTypePrivate *d; |
52 | friend class QQmlOpenMetaObject; |
53 | friend class QQmlOpenMetaObjectPrivate; |
54 | }; |
55 | |
56 | class QQmlOpenMetaObjectPrivate; |
57 | class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObject |
58 | { |
59 | public: |
60 | QQmlOpenMetaObject(QObject *, const QMetaObject * = nullptr); |
61 | QQmlOpenMetaObject(QObject *, const QQmlRefPointer<QQmlOpenMetaObjectType> &); |
62 | ~QQmlOpenMetaObject() override; |
63 | |
64 | QVariant value(const QByteArray &) const; |
65 | bool setValue(const QByteArray &, const QVariant &, bool force = false); |
66 | void setValues(const QHash<QByteArray, QVariant> &, bool force = false); |
67 | QVariant value(int) const; |
68 | void setValue(int, const QVariant &); |
69 | QVariant &valueRef(const QByteArray &); |
70 | bool hasValue(int) const; |
71 | |
72 | int count() const; |
73 | QByteArray name(int) const; |
74 | |
75 | QObject *object() const; |
76 | virtual QVariant initialValue(int); |
77 | |
78 | // Be careful - once setCached(true) is called createProperty() is no |
79 | // longer automatically called for new properties. |
80 | void setCached(bool); |
81 | |
82 | bool autoCreatesProperties() const; |
83 | void setAutoCreatesProperties(bool autoCreate); |
84 | |
85 | QQmlOpenMetaObjectType *type() const; |
86 | |
87 | void emitPropertyNotification(const QByteArray &propertyName); |
88 | void unparent(); |
89 | |
90 | protected: |
91 | int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; |
92 | int createProperty(const char *, const char *) override; |
93 | |
94 | virtual void propertyRead(int); |
95 | virtual void propertyWrite(int); |
96 | virtual QVariant propertyWriteValue(int, const QVariant &); |
97 | virtual void propertyWritten(int); |
98 | virtual void propertyCreated(int, QMetaPropertyBuilder &); |
99 | |
100 | QDynamicMetaObjectData *parent() const; |
101 | |
102 | bool checkedSetValue(int index, const QVariant &value, bool force); |
103 | |
104 | private: |
105 | QQmlOpenMetaObjectPrivate *d; |
106 | friend class QQmlOpenMetaObjectType; |
107 | }; |
108 | |
109 | QT_END_NAMESPACE |
110 | |
111 | #endif // QQMLOPENMETAOBJECT_H |
112 | |