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 NODEINSTANCEMETAOBJECT_H |
5 | #define NODEINSTANCEMETAOBJECT_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 "qquickdesignersupport_p.h" |
19 | |
20 | #include <QQmlContext> |
21 | #include <QScopedPointer> |
22 | #include <private/qqmlopenmetaobject_p.h> |
23 | #include <private/qqmlvmemetaobject_p.h> |
24 | |
25 | #include <memory> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | struct MetaPropertyData; |
30 | |
31 | class QQmlDesignerMetaObject : public QQmlVMEMetaObject |
32 | { |
33 | public: |
34 | ~QQmlDesignerMetaObject(); |
35 | |
36 | static void registerNotifyPropertyChangeCallBack(void (*callback)(QObject*, const QQuickDesignerSupport::PropertyName &propertyName)); |
37 | |
38 | protected: |
39 | static QQmlDesignerMetaObject* getNodeInstanceMetaObject(QObject *object, QQmlEngine *engine); |
40 | |
41 | void createNewDynamicProperty(const QString &name); |
42 | int openMetaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a); |
43 | int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; |
44 | void notifyPropertyChange(int id); |
45 | void setValue(int id, const QVariant &value); |
46 | QVariant propertyWriteValue(int, const QVariant &); |
47 | |
48 | QObject *myObject() const { return QQmlVMEMetaObject::object; } |
49 | |
50 | QDynamicMetaObjectData *dynamicMetaObjectParent() const; |
51 | |
52 | const QMetaObject *metaObjectParent() const; |
53 | |
54 | int propertyOffset() const; |
55 | |
56 | int count() const; |
57 | QByteArray name(int) const; |
58 | |
59 | void copyTypeMetaObject(); |
60 | |
61 | private: |
62 | QQmlDesignerMetaObject(QObject *object, QQmlEngine *engine); |
63 | void init(QObject *); |
64 | QQmlOpenMetaObjectType *type() const { return m_openMetaObject->type(); } |
65 | |
66 | QPointer<QQmlContext> m_context; |
67 | std::unique_ptr<QQmlOpenMetaObject> m_openMetaObject; |
68 | QScopedPointer<MetaPropertyData> m_data; |
69 | |
70 | // This is non-const. You cannot use threads when using the designer metaobject. |
71 | // Otherwise it's the same as QQmlVMEMetaObject's "cache" member. |
72 | QQmlPropertyCache::Ptr m_cache; |
73 | |
74 | friend class QQuickDesignerSupportProperties; |
75 | }; |
76 | |
77 | QT_END_NAMESPACE |
78 | |
79 | #endif // NODEINSTANCEMETAOBJECT_H |
80 | |