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 <tim.jenssen@theqtcompany.com>
This commit is contained in:
Thomas Hartmann
2015-07-08 14:44:37 +02:00
committed by Thomas Hartmann
parent f6d6db5b4c
commit 41cec55d20

View File

@@ -666,8 +666,22 @@ ModelNode RewriterView::nodeAtTextCursorPosition(int cursorPosition) const
bool RewriterView::renameId(const QString& oldId, const QString& newId) bool RewriterView::renameId(const QString& oldId, const QString& newId)
{ {
if (textModifier()) if (textModifier()) {
return textModifier()->renameId(oldId, newId); 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; return false;
} }