forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user