From 8ca90eb4f74fa57a4c95bd232d04a90d087be1ee Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Fri, 21 May 2010 11:23:58 +0200 Subject: [PATCH] QmlDesigner.propertyEditor: fix generation of property panes For custom types we auto generate property panes. With this patch also dot properties (e.g. border.width) and properties of type color (QColor) are properly supported. Task-number: BAUHAUS-208 --- .../propertyeditor/propertyeditor.cpp | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index 7c1f0518d5f..b57ad1779f2 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -550,40 +550,39 @@ QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType) qmlTemplate += QLatin1String("layout: VerticalLayout {\n"); QList<QString> orderedList; - foreach (const PropertyMetaInfo &propertyMetaInfo, type.properties()){ - orderedList.append(propertyMetaInfo.name()); - } - + orderedList = type.properties(true).keys(); qSort(orderedList); foreach (const QString &name, orderedList) { - const PropertyMetaInfo propertyMetaInfo(type.property(name)); + const PropertyMetaInfo propertyMetaInfo(type.property(name, true)); + QString properName = name; + properName.replace(".", "_"); - if (!superType.hasProperty(propertyMetaInfo.name())) { + if (!superType.hasProperty(name, true)) { if (propertyMetaInfo.type() == "int") { qmlTemplate += QString(QLatin1String( - "IntEditor { backendValue: backendValues.%1\n caption: \"%1\"\nbaseStateFlag: isBaseState\nslider: false\n}" - )).arg(propertyMetaInfo.name()); + "IntEditor { backendValue: backendValues.%2\n caption: \"%1\"\nbaseStateFlag: isBaseState\nslider: false\n}" + )).arg(name).arg(properName); } if (propertyMetaInfo.type() == "real" || propertyMetaInfo.type() == "double" || propertyMetaInfo.type() == "qreal") { qmlTemplate += QString(QLatin1String( - "DoubleSpinBoxAlternate {\ntext: \"%1\"\nbackendValue: backendValues.%1\nbaseStateFlag: isBaseState\n}\n" - )).arg(propertyMetaInfo.name()); + "DoubleSpinBoxAlternate {\ntext: \"%1\"\nbackendValue: backendValues.%2\nbaseStateFlag: isBaseState\n}\n" + )).arg(name).arg(properName); } if (propertyMetaInfo.type() == "string") { qmlTemplate += QString(QLatin1String( - "QWidget {\nlayout: HorizontalLayout {\nLabel {\ntext: \"%1\"\ntoolTip: \"%1\"\n}\nLineEdit {\nbackendValue: backendValues.%1\nbaseStateFlag: isBaseState\n}\n}\n}\n" - )).arg(propertyMetaInfo.name()); + "QWidget {\nlayout: HorizontalLayout {\nLabel {\ntext: \"%1\"\ntoolTip: \"%1\"\n}\nLineEdit {\nbackendValue: backendValues.%2\nbaseStateFlag: isBaseState\n}\n}\n}\n" + )).arg(name).arg(properName); } if (propertyMetaInfo.type() == "bool") { qmlTemplate += QString(QLatin1String( - "QWidget {\nlayout: HorizontalLayout {\nLabel {\ntext: \"%1\"\ntoolTip: \"%1\"\n}\nCheckBox {text: backendValues.%1.value\nbackendValue: backendValues.%1\nbaseStateFlag: isBaseState\ncheckable: true\n}\n}\n}\n" - )).arg(propertyMetaInfo.name()); + "QWidget {\nlayout: HorizontalLayout {\nLabel {\ntext: \"%1\"\ntoolTip: \"%1\"\n}\nCheckBox {text: backendValues.%2.value\nbackendValue: backendValues.%2\nbaseStateFlag: isBaseState\ncheckable: true\n}\n}\n}\n" + )).arg(name).arg(properName); } - if (propertyMetaInfo.type() == "color" || propertyMetaInfo.type() == "qcolor") { + if (propertyMetaInfo.type() == "color" || propertyMetaInfo.type() == "QColor") { qmlTemplate += QString(QLatin1String( - "ColorGroupBox {\ncaption: \"%1\"\nfinished: finishedNotify\nbackendColor: backendValues.%1\n}\n\n" - )).arg(propertyMetaInfo.name()); + "ColorGroupBox {\ncaption: \"%1\"\nfinished: finishedNotify\nbackendColor: backendValues.%2\n}\n\n" + )).arg(name).arg(properName); } } } -- GitLab