bool ChangePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) { if (m_sheduledInHierarchy) { const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode()); if (nodeLocation < 0) return true; bool result = false; if (m_property.isDefaultProperty()) { result = refactoring.addToObjectMemberList(nodeLocation, m_valueText); if (!result) { qDebug() << "*** ChangePropertyRewriteAction::execute failed in addToObjectMemberList(" << nodeLocation << ',' << m_valueText << ") **" << info(); } } else if (m_propertyType == QmlRefactoring::ArrayBinding) { result = refactoring.addToArrayMemberList(nodeLocation, m_property.name(), m_valueText); if (!result) { qDebug() << "*** ChangePropertyRewriteAction::execute failed in addToArrayMemberList(" << nodeLocation << ',' << m_property.name() << ',' << m_valueText << ") **" << info(); } } else { result = refactoring.changeProperty(nodeLocation, m_property.name(), m_valueText, m_propertyType); if (!result) { qDebug() << "*** ChangePropertyRewriteAction::execute failed in changeProperty(" << nodeLocation << ',' << m_property.name() << ',' << m_valueText << ',' << qPrintable(toString(m_propertyType)) << ") **" << info(); } } return result; } else { return true; } }
bool ChangeIdRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) { const int nodeLocation = positionStore.nodeOffset(m_node); static const PropertyName idPropertyName("id"); bool result = false; if (m_oldId.isEmpty()) { result = refactoring.addProperty(nodeLocation, idPropertyName, m_newId, QmlRefactoring::ScriptBinding); if (!result) { qDebug() << "*** ChangeIdRewriteAction::execute failed in addProperty(" << nodeLocation << ',' << idPropertyName << ',' << m_newId << ", ScriptBinding) **" << info(); } } else if (m_newId.isEmpty()) { result = refactoring.removeProperty(nodeLocation, idPropertyName); if (!result) { qDebug() << "*** ChangeIdRewriteAction::execute failed in removeProperty(" << nodeLocation << ',' << idPropertyName << ") **" << info(); } } else { result = refactoring.changeProperty(nodeLocation, idPropertyName, m_newId, QmlRefactoring::ScriptBinding); if (!result) { qDebug() << "*** ChangeIdRewriteAction::execute failed in changeProperty(" << nodeLocation << ',' << idPropertyName << ',' << m_newId << ", ScriptBinding) **" << info(); } } return result; }