summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2013-04-10 10:14:28 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2013-04-10 15:19:43 +0200
commitf8c23cf4d05dd8f7faf631afdf36fecde2d3b937 (patch)
tree6a50001fd7398e728e607b003990a48b6630b0cb /src/plugins/qmldesigner
parent3ed0a4b77f3af770409f26553d0f380edd05f351 (diff)
downloadqt-creator-f8c23cf4d05dd8f7faf631afdf36fecde2d3b937.tar.gz
QmlDesigner.Rewriter: Fixing dynamic properties
Dynamic properties were not properly rewritten. Change-Id: Icf2bdd41104aaaeb0473f0616958752dcb19fdb4 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
Diffstat (limited to 'src/plugins/qmldesigner')
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp9
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h4
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp8
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h6
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp17
-rw-r--r--src/plugins/qmldesigner/designercore/model/rewriteaction.cpp2
6 files changed, 36 insertions, 10 deletions
diff --git a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp
index df647e181f..37af895cea 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp
@@ -42,13 +42,15 @@ AddPropertyVisitor::AddPropertyVisitor(QmlDesigner::TextModifier &modifier,
const QmlDesigner::PropertyName &name,
const QString &value,
QmlRefactoring::PropertyType propertyType,
- const PropertyNameList &propertyOrder):
+ const PropertyNameList &propertyOrder,
+ const QmlDesigner::TypeName &dynamicTypeName) :
QMLRewriter(modifier),
m_parentLocation(parentLocation),
m_name(name),
m_value(value),
m_propertyType(propertyType),
- m_propertyOrder(propertyOrder)
+ m_propertyOrder(propertyOrder),
+ m_dynamicTypeName(dynamicTypeName)
{
}
@@ -147,6 +149,9 @@ void AddPropertyVisitor::addInMembers(QmlJS::AST::UiObjectInitializer *initializ
Q_ASSERT(!"unknown property type");
}
+ if (!m_dynamicTypeName.isEmpty())
+ newPropertyTemplate.prepend(QString(QLatin1String("property %1 ")).arg(QString::fromUtf8(m_dynamicTypeName)));
+
if (isOneLiner) {
if (needsPreceedingSemicolon)
newPropertyTemplate.prepend(QLatin1Char(';'));
diff --git a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h
index c5da91fbaa..869edf5003 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h
+++ b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h
@@ -45,7 +45,8 @@ public:
const QmlDesigner::PropertyName &name,
const QString &value,
QmlDesigner::QmlRefactoring::PropertyType propertyType,
- const PropertyNameList &propertyOrder);
+ const PropertyNameList &propertyOrder,
+ const QmlDesigner::TypeName &dynamicTypeName);
protected:
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
@@ -60,6 +61,7 @@ private:
QString m_value;
QmlRefactoring::PropertyType m_propertyType;
PropertyNameList m_propertyOrder;
+ QmlDesigner::TypeName m_dynamicTypeName;
};
} // namespace Internal
diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
index a5646cdd02..674e2a1aa7 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
@@ -103,12 +103,16 @@ bool QmlRefactoring::addToObjectMemberList(int parentLocation, const QString &co
return visit(qmlDocument->qmlProgram());
}
-bool QmlRefactoring::addProperty(int parentLocation, const PropertyName &name, const QString &value, PropertyType propertyType)
+bool QmlRefactoring::addProperty(int parentLocation,
+ const PropertyName &name,
+ const QString &value,
+ PropertyType propertyType,
+ const TypeName &dynamicTypeName)
{
if (parentLocation < 0)
return false;
- AddPropertyVisitor visit(*textModifier, (quint32) parentLocation, name, value, propertyType, m_propertyOrder);
+ AddPropertyVisitor visit(*textModifier, (quint32) parentLocation, name, value, propertyType, m_propertyOrder, dynamicTypeName);
return visit(qmlDocument->qmlProgram());
}
diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h
index 6235933379..c6376cfbf4 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h
+++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h
@@ -60,7 +60,11 @@ public:
bool addToArrayMemberList(int parentLocation, const PropertyName &propertyName, const QString &content);
bool addToObjectMemberList(int parentLocation, const QString &content);
- bool addProperty(int parentLocation, const PropertyName &name, const QString &value, PropertyType propertyType);
+ bool addProperty(int parentLocation,
+ const PropertyName &name,
+ const QString &value,
+ PropertyType propertyType,
+ const TypeName &dynamicTypeName = TypeName());
bool changeProperty(int parentLocation, const PropertyName &name, const QString &value, PropertyType propertyType);
bool changeObjectType(int nodeLocation, const QString &newType);
diff --git a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
index 1fe6d0e027..4fa4a8b82b 100644
--- a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
@@ -230,10 +230,21 @@ QString QmlTextGenerator::propertyToQml(const AbstractProperty &property, int in
{
QString result;
- if (property.isDefaultProperty())
+ if (property.isDefaultProperty()) {
result = toQml(property, indentDepth);
- else
- result = QString(indentDepth, QLatin1Char(' ')) + property.name() + QLatin1String(": ") + toQml(property, indentDepth);
+ } else {
+ if (property.isDynamic()) {
+ result = QString(indentDepth, QLatin1Char(' '))
+ + QLatin1String("property ")
+ + property.dynamicTypeName()
+ + QLatin1String(" ")
+ + property.name()
+ + QLatin1String(": ")
+ + toQml(property, indentDepth);
+ } else {
+ result = QString(indentDepth, QLatin1Char(' ')) + property.name() + QLatin1String(": ") + toQml(property, indentDepth);
+ }
+ }
result += QLatin1Char('\n');
diff --git a/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp b/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp
index 91875e0979..41abf3d2cb 100644
--- a/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp
+++ b/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp
@@ -107,7 +107,7 @@ bool AddPropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePos
<< info();
}
} else {
- result = refactoring.addProperty(nodeLocation, m_property.name(), m_valueText, m_propertyType);
+ result = refactoring.addProperty(nodeLocation, m_property.name(), m_valueText, m_propertyType, m_property.dynamicTypeName());
if (!result) {
qDebug() << "*** AddPropertyRewriteAction::execute failed in addProperty("