QmlDesigner.model: rename id is now a proper refactoring operation

I an id is now changed in the navaigator or property editor,
we now use the qmljseditor to properly refactor.

Also I changed dynamic_cast to qobject_cast

Reviewed-by: Erik Verbruggen
This commit is contained in:
Thomas Hartmann
2010-09-30 14:25:20 +02:00
parent 2d5049645c
commit 4c185a9ac4
14 changed files with 70 additions and 20 deletions

View File

@@ -1045,6 +1045,18 @@ void QmlJSTextEditor::setUpdateSelectedElements(bool value)
m_updateSelectedElements = value;
}
void QmlJSTextEditor::renameId(const QString &oldId, const QString &newId)
{
Utils::ChangeSet changeSet;
foreach (const AST::SourceLocation &loc, m_semanticInfo.idLocations.value(oldId)) {
changeSet.replace(loc.begin(), loc.end(), newId);
}
QTextCursor tc = textCursor();
changeSet.apply(&tc);
}
void QmlJSTextEditor::updateUsesNow()
{
if (document()->revision() != m_semanticInfo.revision()) {
@@ -1242,14 +1254,7 @@ void QmlJSTextEditor::renameIdUnderCursor()
QLineEdit::Normal,
id, &ok);
if (ok) {
Utils::ChangeSet changeSet;
foreach (const AST::SourceLocation &loc, m_semanticInfo.idLocations.value(id)) {
changeSet.replace(loc.begin(), loc.end(), newId);
}
QTextCursor tc = textCursor();
changeSet.apply(&tc);
renameId(id, newId);
}
}