forked from qt-creator/qt-creator
QmlDesigner: small speed improvements
Change-Id: I8fb3f36426043ed4502ba4a8d18c677ad85a1842 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -94,7 +94,7 @@ static TypeName resolveTypeName(const ASTPropertyReference *ref, const ContextPt
|
|||||||
if (const ASTObjectValue * astObjectValue = value->asAstObjectValue()) {
|
if (const ASTObjectValue * astObjectValue = value->asAstObjectValue()) {
|
||||||
if (astObjectValue->typeName()) {
|
if (astObjectValue->typeName()) {
|
||||||
type = astObjectValue->typeName()->name.toUtf8();
|
type = astObjectValue->typeName()->name.toUtf8();
|
||||||
const ObjectValue * objectValue = context->lookupType(astObjectValue->document(), astObjectValue->typeName());;
|
const ObjectValue *objectValue = context->lookupType(astObjectValue->document(), astObjectValue->typeName());
|
||||||
if (objectValue)
|
if (objectValue)
|
||||||
dotProperties = getObjectTypes(objectValue, context);
|
dotProperties = getObjectTypes(objectValue, context);
|
||||||
}
|
}
|
||||||
@@ -332,8 +332,15 @@ private:
|
|||||||
|
|
||||||
static inline bool isValueType(const TypeName &type)
|
static inline bool isValueType(const TypeName &type)
|
||||||
{
|
{
|
||||||
PropertyTypeList objectValuesList;
|
static PropertyTypeList objectValuesList(PropertyTypeList()
|
||||||
objectValuesList << "QFont" << "QPoint" << "QPointF" << "QSize" << "QSizeF" << "QVector3D" << "QVector2D";
|
<< "QFont" << "QPoint" << "QPointF" << "QSize" << "QSizeF" << "QVector3D" << "QVector2D");
|
||||||
|
return objectValuesList.contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool isValueType(const QString &type)
|
||||||
|
{
|
||||||
|
static QStringList objectValuesList(QStringList()
|
||||||
|
<< "QFont" << "QPoint" << "QPointF" << "QSize" << "QSizeF" << "QVector3D" << "QVector2D");
|
||||||
return objectValuesList.contains(type);
|
return objectValuesList.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +383,19 @@ QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool ve
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0)
|
QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0);
|
||||||
|
|
||||||
|
QList<PropertyInfo> getTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local = false, int rec = 0)
|
||||||
|
{
|
||||||
|
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(objectValue);
|
||||||
|
|
||||||
|
if (qmlObjectValue)
|
||||||
|
return getQmlTypes(qmlObjectValue, context, local, rec);
|
||||||
|
|
||||||
|
return getObjectTypes(objectValue, context, local, rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const ContextPtr &context, bool local, int rec)
|
||||||
{
|
{
|
||||||
QList<PropertyInfo> propertyList;
|
QList<PropertyInfo> propertyList;
|
||||||
|
|
||||||
@@ -391,32 +410,28 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Cont
|
|||||||
PropertyMemberProcessor processor(context);
|
PropertyMemberProcessor processor(context);
|
||||||
objectValue->processMembers(&processor);
|
objectValue->processMembers(&processor);
|
||||||
|
|
||||||
QList<PropertyInfo> newList = processor.properties();
|
foreach (const PropertyInfo &property, processor.properties()) {
|
||||||
|
|
||||||
foreach (PropertyInfo property, newList) {
|
|
||||||
const PropertyName name = property.first;
|
const PropertyName name = property.first;
|
||||||
const QString nameAsString = QString::fromUtf8(name);
|
const QString nameAsString = QString::fromUtf8(name);
|
||||||
if (!objectValue->isWritable(nameAsString) && objectValue->isPointer(nameAsString)) {
|
if (!objectValue->isWritable(nameAsString) && objectValue->isPointer(nameAsString)) {
|
||||||
//dot property
|
//dot property
|
||||||
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(objectValue->lookupMember(nameAsString, context));
|
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(objectValue->lookupMember(nameAsString, context));
|
||||||
if (qmlValue) {
|
if (qmlValue) {
|
||||||
QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context, false, rec + 1);
|
const QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context, false, rec + 1);
|
||||||
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
||||||
PropertyName dotName = propertyInfo.first;
|
const PropertyName dotName = name + '.' + propertyInfo.first;
|
||||||
TypeName type = propertyInfo.second;
|
const TypeName type = propertyInfo.second;
|
||||||
dotName = name + '.' + dotName;
|
|
||||||
propertyList.append(qMakePair(dotName, type));
|
propertyList.append(qMakePair(dotName, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isValueType(objectValue->propertyType(nameAsString).toUtf8())) {
|
if (isValueType(objectValue->propertyType(nameAsString))) {
|
||||||
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(objectValue->lookupMember(nameAsString, context));
|
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(objectValue->lookupMember(nameAsString, context));
|
||||||
if (dotObjectValue) {
|
if (dotObjectValue) {
|
||||||
QList<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
|
const QList<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
|
||||||
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
foreach (const PropertyInfo &propertyInfo, dotProperties) {
|
||||||
PropertyName dotName = propertyInfo.first;
|
const PropertyName dotName = name + '.' + propertyInfo.first;
|
||||||
TypeName type = propertyInfo.second;
|
const TypeName type = propertyInfo.second;
|
||||||
dotName = name + '.' + dotName;
|
|
||||||
propertyList.append(qMakePair(dotName, type));
|
propertyList.append(qMakePair(dotName, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,16 +442,8 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Cont
|
|||||||
propertyList.append(qMakePair(name, type));
|
propertyList.append(qMakePair(name, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!local) {
|
if (!local)
|
||||||
const ObjectValue* prototype = objectValue->prototype(context);
|
propertyList.append(getTypes(objectValue->prototype(context), context, local, rec));
|
||||||
|
|
||||||
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype);
|
|
||||||
|
|
||||||
if (qmlObjectValue)
|
|
||||||
propertyList.append(getQmlTypes(qmlObjectValue, context, false, rec));
|
|
||||||
else
|
|
||||||
propertyList.append(getObjectTypes(prototype, context, false, rec));
|
|
||||||
}
|
|
||||||
|
|
||||||
return propertyList;
|
return propertyList;
|
||||||
}
|
}
|
||||||
@@ -466,20 +473,6 @@ PropertyNameList getSignals(const ObjectValue *objectValue, const ContextPtr &co
|
|||||||
return signalList;
|
return signalList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PropertyInfo> getTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local = false)
|
|
||||||
{
|
|
||||||
QList<PropertyInfo> propertyList;
|
|
||||||
|
|
||||||
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(objectValue);
|
|
||||||
|
|
||||||
if (qmlObjectValue)
|
|
||||||
propertyList.append(getQmlTypes(qmlObjectValue, context, local));
|
|
||||||
else
|
|
||||||
propertyList.append(getObjectTypes(objectValue, context, local));
|
|
||||||
|
|
||||||
return propertyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local, int rec)
|
QList<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const ContextPtr &context, bool local, int rec)
|
||||||
{
|
{
|
||||||
QList<PropertyInfo> propertyList;
|
QList<PropertyInfo> propertyList;
|
||||||
@@ -499,7 +492,7 @@ QList<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const Context
|
|||||||
|
|
||||||
if (!local) {
|
if (!local) {
|
||||||
const ObjectValue* prototype = objectValue->prototype(context);
|
const ObjectValue* prototype = objectValue->prototype(context);
|
||||||
|
// TODO: can we move this to getType methode and use that one here then
|
||||||
if (prototype == objectValue)
|
if (prototype == objectValue)
|
||||||
return propertyList;
|
return propertyList;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user