Commit 0a2a28ec authored by Tobias Hunger's avatar Tobias Hunger

Do not allow all WS names in Run-/Deploy-/BuildCOnfigs

Task-number: QTCREATORBUG-2584
parent 1261e9e1
......@@ -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();
......
......@@ -107,6 +107,7 @@ private slots:
private:
void cloneConfiguration(BuildConfiguration *toClone);
void deleteConfiguration(BuildConfiguration *toDelete);
QString uniqueName(const QString & name);
Target *m_target;
BuildConfiguration *m_buildConfiguration;
......
......@@ -293,15 +293,10 @@ void RunSettingsWidget::renameRunConfiguration()
if (!ok || !this)
return;
if (!name.isEmpty()) {
QStringList rcNames;
foreach (RunConfiguration *rc, m_target->runConfigurations()) {
if (rc == m_target->activeRunConfiguration())
continue;
rcNames.append(rc->displayName());
}
name = Project::makeUnique(name, rcNames);
}
name = uniqueRCName(name);
if (name.isEmpty())
return;
m_target->activeRunConfiguration()->setDisplayName(name);
}
......@@ -393,15 +388,9 @@ void RunSettingsWidget::renameDeployConfiguration()
if (!ok || !this)
return;
if (!name.isEmpty()) {
QStringList dcNames;
foreach (DeployConfiguration *dc, m_target->deployConfigurations()) {
if (dc == m_target->activeDeployConfiguration())
continue;
dcNames.append(dc->displayName());
}
name = Project::makeUnique(name, dcNames);
}
name = uniqueDCName(name);
if (name.isEmpty())
return;
m_target->activeDeployConfiguration()->setDisplayName(name);
}
......@@ -430,3 +419,33 @@ void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc)
m_deploySteps->init(dc->stepList());
m_deployLayout->addWidget(m_deploySteps);
}
QString RunSettingsWidget::uniqueDCName(const QString &name)
{
QString result = name.trimmed();
if (!result.isEmpty()) {
QStringList dcNames;
foreach (DeployConfiguration *dc, m_target->deployConfigurations()) {
if (dc == m_target->activeDeployConfiguration())
continue;
dcNames.append(dc->displayName());
}
result = Project::makeUnique(result, dcNames);
}
return result;
}
QString RunSettingsWidget::uniqueRCName(const QString &name)
{
QString result = name.trimmed();
if (!result.isEmpty()) {
QStringList rcNames;
foreach (RunConfiguration *rc, m_target->runConfigurations()) {
if (rc == m_target->activeRunConfiguration())
continue;
rcNames.append(rc->displayName());
}
result = Project::makeUnique(result, rcNames);
}
return result;
}
......@@ -104,7 +104,10 @@ private slots:
void renameDeployConfiguration();
private:
QString uniqueDCName(const QString &name);
QString uniqueRCName(const QString &name);
void updateDeployConfiguration(DeployConfiguration *);
Target *m_target;
RunConfigurationModel *m_runConfigurationsModel;
DeployConfigurationModel *m_deployConfigurationModel;
......
......@@ -710,6 +710,7 @@ BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Target
QLineEdit::Normal,
version->displayName(),
&ok);
buildConfigurationName = buildConfigurationName.trimmed();
if (!ok || buildConfigurationName.isEmpty())
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment