diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-07-07 13:03:04 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-07-07 15:56:10 +0000 |
commit | 29214a212c36c0d52094b77a469cb1e0d3f8103e (patch) | |
tree | 61dc538ec51f19e1348d58953ca0d87c80012e9c /src/plugins/qmldesigner/designercore | |
parent | f4732b4a70513a88f5c0408f909b44fe26ee47ef (diff) |
QmlDesigner: Add slot/function support to NodeMetainfo
Change-Id: Ie8e153d552a003ca189b65fe8691cb84091c8159
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/designercore')
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/nodemetainfo.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp | 48 |
2 files changed, 48 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h index 09daa924aa..05a08d1467 100644 --- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h +++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h @@ -66,6 +66,7 @@ public: bool hasProperty(const PropertyName &propertyName) const; PropertyNameList propertyNames() const; PropertyNameList signalNames() const; + PropertyNameList slotNames() const; PropertyNameList directPropertyNames() const; PropertyName defaultPropertyName() const; bool hasDefaultProperty() const; diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 902072f129..3b64f74e0c 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -329,13 +329,21 @@ public: return true; } + bool processSlot(const QString &name, const Value * /*value*/) override + { + m_slots.append(name.toUtf8()); + return true; + } + QVector<PropertyInfo> properties() const { return m_properties; } PropertyNameList signalList() const { return m_signals; } + PropertyNameList slotList() const { return m_slots; } private: QVector<PropertyInfo> m_properties; PropertyNameList m_signals; + PropertyNameList m_slots; const ContextPtr m_context; }; @@ -486,6 +494,31 @@ PropertyNameList getSignals(const ObjectValue *objectValue, const ContextPtr &co return signalList; } +PropertyNameList getSlots(const ObjectValue *objectValue, const ContextPtr &context, bool local = false) +{ + PropertyNameList slotList; + + if (!objectValue) + return slotList; + if (objectValue->className().isEmpty()) + return slotList; + + PropertyMemberProcessor processor(context); + objectValue->processMembers(&processor); + + slotList.append(processor.slotList()); + + PrototypeIterator prototypeIterator(objectValue, context); + const QList<const ObjectValue *> objects = prototypeIterator.all(); + + if (!local) { + for (const ObjectValue *prototype : objects) + slotList.append(getSlots(prototype, context, true)); + } + + return slotList; +} + QVector<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local, int rec) { QVector<PropertyInfo> propertyList; @@ -555,6 +588,7 @@ public: PropertyNameList properties() const; PropertyNameList localProperties() const; PropertyNameList signalNames() const; + PropertyNameList slotNames() const; PropertyName defaultPropertyName() const; TypeName propertyType(const PropertyName &propertyName) const; @@ -588,7 +622,6 @@ public: static void clearCache(); - private: NodeMetaInfoPrivate(Model *model, TypeName type, int maj = -1, int min = -1); @@ -611,6 +644,7 @@ private: bool m_isFileComponent = false; PropertyNameList m_properties; PropertyNameList m_signals; + PropertyNameList m_slots; QList<TypeName> m_propertyTypes; PropertyNameList m_localProperties; PropertyName m_defaultPropertyName; @@ -655,6 +689,12 @@ PropertyNameList NodeMetaInfoPrivate::signalNames() const return m_signals; } +PropertyNameList NodeMetaInfoPrivate::slotNames() const +{ + ensureProperties(); + return m_slots; +} + QSet<QByteArray> &NodeMetaInfoPrivate::prototypeCachePositives() { return m_prototypeCachePositives; @@ -1363,6 +1403,7 @@ void NodeMetaInfoPrivate::initialiseProperties() setupLocalPropertyInfo(getTypes(m_objectValue, context(), true)); m_signals = getSignals(m_objectValue, context()); + m_slots = getSlots(m_objectValue, context()); } } //namespace Internal @@ -1414,6 +1455,11 @@ PropertyNameList NodeMetaInfo::signalNames() const return m_privateData->signalNames(); } +PropertyNameList NodeMetaInfo::slotNames() const +{ + return m_privateData->slotNames(); +} + PropertyNameList NodeMetaInfo::directPropertyNames() const { return m_privateData->localProperties(); |