summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-04 14:54:30 +0100
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-04 14:54:30 +0100
commitdf8affc87ba7931a643377032c2331dc01f6de4b (patch)
tree62744e6b0dcb5c2f4950576865ba3da9bd9dc159
parent990d66a0fb248067bfa0c3ed8a37c6dc2846112f (diff)
downloadqt-creator-df8affc87ba7931a643377032c2331dc01f6de4b.tar.gz
QmlDesigner.statesEditor: usability fix
If the user aborts state renaming or gives the state the same name again there is no MessageBox shown anymore.
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp5
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp5
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.h1
3 files changed, 10 insertions, 1 deletions
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);