From 0a2a28ec47240c1dbf1067b55238f567829495e6 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 4 Oct 2010 17:50:55 +0200 Subject: Do not allow all WS names in Run-/Deploy-/BuildCOnfigs Task-number: QTCREATORBUG-2584 --- .../buildsettingspropertiespage.cpp | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/plugins/projectexplorer/buildsettingspropertiespage.cpp') diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index 8b589fc059..3bcf9fcc93 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -328,6 +328,21 @@ void BuildSettingsWidget::deleteConfiguration() deleteConfiguration(m_buildConfiguration); } +QString BuildSettingsWidget::uniqueName(const QString & name) +{ + QString result = name.trimmed(); + if (!result.isEmpty()) { + QStringList bcNames; + foreach (BuildConfiguration *bc, m_target->buildConfigurations()) { + if (bc == m_buildConfiguration) + continue; + bcNames.append(bc->displayName()); + } + result = Project::makeUnique(result, bcNames); + } + return result; +} + void BuildSettingsWidget::renameConfiguration() { bool ok; @@ -339,15 +354,10 @@ void BuildSettingsWidget::renameConfiguration() if (!ok || !this) return; - if (!name.isEmpty()) { - QStringList bcNames; - foreach (BuildConfiguration *bc, m_target->buildConfigurations()) { - if (bc == m_buildConfiguration) - continue; - bcNames.append(bc->displayName()); - } - name = Project::makeUnique(name, bcNames); - } + name = uniqueName(name); + if (name.isEmpty()) + return; + m_buildConfiguration->setDisplayName(name); } @@ -359,15 +369,15 @@ void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfigura return; //: Title of a the cloned BuildConfiguration window, text of the window - QString newDisplayName(QInputDialog::getText(this, tr("Clone Configuration"), tr("New configuration name:"))); - if (newDisplayName.isEmpty()) + QString name = uniqueName(QInputDialog::getText(this, tr("Clone Configuration"), tr("New configuration name:"))); + if (name.isEmpty()) return; BuildConfiguration * bc(m_target->buildConfigurationFactory()->clone(m_target, sourceConfiguration)); if (!bc) return; - bc->setDisplayName(newDisplayName); + bc->setDisplayName(name); m_target->addBuildConfiguration(bc); updateBuildSettings(); -- cgit v1.2.1