QmlDesigner.statesEditor: usability fix

If the user aborts state renaming or gives the state the same
name again there is no MessageBox shown anymore.
This commit is contained in:
Thomas Hartmann
2011-03-04 14:54:30 +01:00
parent 990d66a0fb
commit df8affc87b
3 changed files with 10 additions and 1 deletions

View 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() ?

View 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)) {

View 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);