From 41cec55d20ec117281559e56afab408124e4511c Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 8 Jul 2015 14:44:37 +0200 Subject: [PATCH] QmlDesigner: Keep export property alias if changing id If the id of a ModelNode is changed the expression of an exporting property (property alias id: id) is changed but not the property name. So we get property alias oldId: newId. To keep the exports consistent this code adjusts the property name to the new id. Change-Id: Ibd9c9f4a2e755fbfb7beeed458ea45270db7f666 Reviewed-by: Tim Jenssen --- .../designercore/model/rewriterview.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index 4ff6161398a..a7127c66e8f 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -666,8 +666,22 @@ ModelNode RewriterView::nodeAtTextCursorPosition(int cursorPosition) const bool RewriterView::renameId(const QString& oldId, const QString& newId) { - if (textModifier()) - return textModifier()->renameId(oldId, newId); + if (textModifier()) { + PropertyName propertyName = oldId.toLatin1(); + + bool hasAliasExport = rootModelNode().isValid() + && rootModelNode().hasBindingProperty(propertyName) + && rootModelNode().bindingProperty(propertyName).isAliasExport(); + + bool refactoring = textModifier()->renameId(oldId, newId); + + if (refactoring && hasAliasExport) { //Keep export alias properties + rootModelNode().removeProperty(propertyName); + PropertyName newPropertyName = newId.toLatin1(); + rootModelNode().bindingProperty(newPropertyName).setDynamicTypeNameAndExpression("alias", newPropertyName); + } + return refactoring; + } return false; }