From df8affc87ba7931a643377032c2331dc01f6de4b Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 4 Mar 2011 14:54:30 +0100 Subject: QmlDesigner.statesEditor: usability fix If the user aborts state renaming or gives the state the same name again there is no MessageBox shown anymore. --- .../qmldesigner/components/stateseditor/stateseditormodel.cpp | 5 ++++- src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp | 5 +++++ src/plugins/qmldesigner/components/stateseditor/stateseditorview.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 8367b242d0..837973cbb1 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -169,7 +169,10 @@ void StatesEditorModel::removeState(int stateIndex) } void StatesEditorModel::renameState(int nodeId, const QString &newName) -{ +{ + if (newName == m_statesEditorView->currentStateName()) + return; + if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) { QMessageBox::warning(0, tr("Invalid state name"), newName.isEmpty() ? diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 16e2ca82c7..a3694f10d4 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -198,6 +198,11 @@ bool StatesEditorView::validStateName(const QString &name) const return true; } +QString StatesEditorView::currentStateName() const +{ + return currentState().isValid() ? currentState().name() : QString(); +} + void StatesEditorView::renameState(int nodeId, const QString &newName) { if (hasModelNodeForInternalId(nodeId)) { diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 8e1faa2785..e09fe0d3a1 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -50,6 +50,7 @@ public: void renameState(int nodeId,const QString &newName); bool validStateName(const QString &name) const; + QString currentStateName() const; void nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName); -- cgit v1.2.1