Commit e6be4484 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.MetaInfo: Initiliase property info lazily

There exists cases where collecting the properties is
very slow. We only have to do this on demand
for the property editor.

Change-Id: I92d7270481db94655c95ab8d69f373488d841b4e
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 334273be
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include <qmljs/qmljsvalueowner.h> #include <qmljs/qmljsvalueowner.h>
#include <languageutils/fakemetaobject.h> #include <languageutils/fakemetaobject.h>
#include <utils/qtcassert.h>
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
...@@ -565,6 +567,9 @@ private: ...@@ -565,6 +567,9 @@ private:
const CppComponentValue *getNearestCppComponentValue() const; const CppComponentValue *getNearestCppComponentValue() const;
QString fullQualifiedImportAliasType() const; QString fullQualifiedImportAliasType() const;
void ensureProperties() const;
void initialiseProperties();
TypeName m_qualfiedTypeName; TypeName m_qualfiedTypeName;
int m_majorVersion; int m_majorVersion;
int m_minorVersion; int m_minorVersion;
...@@ -585,6 +590,8 @@ private: ...@@ -585,6 +590,8 @@ private:
QPointer<Model> m_model; QPointer<Model> m_model;
static QHash<TypeName, Pointer> m_nodeMetaInfoCache; static QHash<TypeName, Pointer> m_nodeMetaInfoCache;
const ObjectValue *m_objectValue = nullptr;
bool m_propertiesSetup = false;
}; };
QHash<TypeName, NodeMetaInfoPrivate::Pointer> NodeMetaInfoPrivate::m_nodeMetaInfoCache; QHash<TypeName, NodeMetaInfoPrivate::Pointer> NodeMetaInfoPrivate::m_nodeMetaInfoCache;
...@@ -596,16 +603,21 @@ bool NodeMetaInfoPrivate::isFileComponent() const ...@@ -596,16 +603,21 @@ bool NodeMetaInfoPrivate::isFileComponent() const
PropertyNameList NodeMetaInfoPrivate::properties() const PropertyNameList NodeMetaInfoPrivate::properties() const
{ {
ensureProperties();
return m_properties; return m_properties;
} }
PropertyNameList NodeMetaInfoPrivate::localProperties() const PropertyNameList NodeMetaInfoPrivate::localProperties() const
{ {
ensureProperties();
return m_localProperties; return m_localProperties;
} }
PropertyNameList NodeMetaInfoPrivate::signalNames() const PropertyNameList NodeMetaInfoPrivate::signalNames() const
{ {
ensureProperties();
return m_signals; return m_signals;
} }
...@@ -670,12 +682,10 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i ...@@ -670,12 +682,10 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
m_majorVersion = cppObjectValue->componentVersion().majorVersion(); m_majorVersion = cppObjectValue->componentVersion().majorVersion();
m_minorVersion = cppObjectValue->componentVersion().minorVersion(); m_minorVersion = cppObjectValue->componentVersion().minorVersion();
} }
setupPropertyInfo(getTypes(cppObjectValue, context())); m_objectValue = cppObjectValue;
setupLocalPropertyInfo(getTypes(cppObjectValue, context(), true));
m_defaultPropertyName = cppObjectValue->defaultPropertyName().toUtf8(); m_defaultPropertyName = cppObjectValue->defaultPropertyName().toUtf8();
m_isValid = true; m_isValid = true;
setupPrototypes(); setupPrototypes();
m_signals = getSignals(cppObjectValue, context());
} else { } else {
const ObjectValue *objectValue = getObjectValue(); const ObjectValue *objectValue = getObjectValue();
if (objectValue) { if (objectValue) {
...@@ -699,12 +709,10 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i ...@@ -699,12 +709,10 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
m_minorVersion = importInfo.version().minorVersion(); m_minorVersion = importInfo.version().minorVersion();
} }
} }
setupPropertyInfo(getTypes(objectValue, context())); m_objectValue = objectValue;
setupLocalPropertyInfo(getTypes(objectValue, context(), true));
m_defaultPropertyName = context()->defaultPropertyName(objectValue).toUtf8(); m_defaultPropertyName = context()->defaultPropertyName(objectValue).toUtf8();
m_isValid = true; m_isValid = true;
setupPrototypes(); setupPrototypes();
m_signals = getSignals(objectValue, context());
} }
} }
} }
...@@ -803,6 +811,8 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const PropertyName &propertyName) c ...@@ -803,6 +811,8 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const PropertyName &propertyName) c
if (!isValid()) if (!isValid())
return false; return false;
ensureProperties();
if (propertyName.contains('.')) { if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.'); const PropertyNameList parts = propertyName.split('.');
const PropertyName objectName = parts.first(); const PropertyName objectName = parts.first();
...@@ -834,6 +844,8 @@ bool NodeMetaInfoPrivate::isPropertyList(const PropertyName &propertyName) const ...@@ -834,6 +844,8 @@ bool NodeMetaInfoPrivate::isPropertyList(const PropertyName &propertyName) const
if (!isValid()) if (!isValid())
return false; return false;
ensureProperties();
if (propertyName.contains('.')) { if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.'); const PropertyNameList parts = propertyName.split('.');
const PropertyName objectName = parts.first(); const PropertyName objectName = parts.first();
...@@ -861,6 +873,8 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const PropertyName &propertyName) co ...@@ -861,6 +873,8 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const PropertyName &propertyName) co
if (!isValid()) if (!isValid())
return false; return false;
ensureProperties();
if (propertyName.contains('.')) { if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.'); const PropertyNameList parts = propertyName.split('.');
const PropertyName objectName = parts.first(); const PropertyName objectName = parts.first();
...@@ -888,6 +902,8 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const PropertyName &propertyName) const ...@@ -888,6 +902,8 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const PropertyName &propertyName) const
if (!isValid()) if (!isValid())
return false; return false;
ensureProperties();
if (propertyType(propertyName).contains("Qt::")) if (propertyType(propertyName).contains("Qt::"))
return true; return true;
...@@ -918,6 +934,8 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const PropertyName &propertyName) ...@@ -918,6 +934,8 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const PropertyName &propertyName)
if (!isValid()) if (!isValid())
return QString(); return QString();
ensureProperties();
if (propertyType(propertyName).contains("Qt::")) if (propertyType(propertyName).contains("Qt::"))
return QStringLiteral("Qt"); return QStringLiteral("Qt");
...@@ -1262,6 +1280,29 @@ QString NodeMetaInfoPrivate::fullQualifiedImportAliasType() const ...@@ -1262,6 +1280,29 @@ QString NodeMetaInfoPrivate::fullQualifiedImportAliasType() const
return QString::fromUtf8(m_qualfiedTypeName); return QString::fromUtf8(m_qualfiedTypeName);
} }
void NodeMetaInfoPrivate::ensureProperties() const
{
if (m_propertiesSetup)
return;
const_cast<NodeMetaInfoPrivate*>(this)->initialiseProperties();
}
void NodeMetaInfoPrivate::initialiseProperties()
{
if (!isValid())
return;
m_propertiesSetup = true;
QTC_ASSERT(m_objectValue, qDebug() << qualfiedTypeName(); return);
setupPropertyInfo(getTypes(m_objectValue, context()));
setupLocalPropertyInfo(getTypes(m_objectValue, context(), true));
m_signals = getSignals(m_objectValue, context());
}
} //namespace Internal } //namespace Internal
NodeMetaInfo::NodeMetaInfo() : m_privateData(new Internal::NodeMetaInfoPrivate()) NodeMetaInfo::NodeMetaInfo() : m_privateData(new Internal::NodeMetaInfoPrivate())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment