OSDN Git Service

QmlDesigner.statesEditor: usability fix
authorThomas Hartmann <Thomas.Hartmann@nokia.com>
Fri, 4 Mar 2011 13:54:30 +0000 (14:54 +0100)
committerThomas Hartmann <Thomas.Hartmann@nokia.com>
Fri, 4 Mar 2011 13:54:30 +0000 (14:54 +0100)
If the user aborts state renaming or gives the state the same
name again there is no MessageBox shown anymore.

src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp
src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
src/plugins/qmldesigner/components/stateseditor/stateseditorview.h

index 8367b24..837973c 100644 (file)
@@ -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() ?
index 16e2ca8..a3694f1 100644 (file)
@@ -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)) {
index 8e1faa2..e09fe0d 100644 (file)
@@ -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);