Commit 52abdd69 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Profile: Make sure name is unique



... not only when adding the profile, but also when renaming it.

Change-Id: Ib13265d2619718bf2d44410b96cd5ed0eeebf38b
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 5c04b408
......@@ -35,6 +35,7 @@
#include "devicesupport/devicemanager.h"
#include "profileinformation.h"
#include "profilemanager.h"
#include "project.h"
#include "toolchainmanager.h"
#include <QApplication>
......@@ -136,9 +137,24 @@ QString Profile::displayName() const
void Profile::setDisplayName(const QString &name)
{
if (d->m_displayName == name)
// make name unique:
QStringList nameList;
foreach (Profile *p, ProfileManager::instance()->profiles())
nameList << p->displayName();
QString uniqueName = Project::makeUnique(name, nameList);
if (uniqueName != name) {
ToolChain *tc = ToolChainProfileInformation::toolChain(this);
if (tc) {
const QString tcPostfix = QString::fromLatin1("-%1").arg(tc->displayName());
if (!name.contains(tcPostfix))
uniqueName = Project::makeUnique(name + tcPostfix, nameList);
}
}
if (d->m_displayName == uniqueName)
return;
d->m_displayName = name;
d->m_displayName = uniqueName;
profileUpdated();
}
......
......@@ -397,22 +397,6 @@ bool ProfileManager::registerProfile(ProjectExplorer::Profile *p)
return false;
}
// Make name unique:
QStringList names;
foreach (Profile *tmp, profiles())
names << tmp->displayName();
QString name = p->displayName();
QString uniqueName = Project::makeUnique(name, names);
if (uniqueName != name) {
ToolChain *tc = ToolChainProfileInformation::toolChain(p);
if (tc) {
const QString tcPostfix = QString::fromLatin1("-%1").arg(tc->displayName());
if (!name.contains(tcPostfix))
uniqueName = Project::makeUnique(name + tcPostfix, names);
}
}
p->setDisplayName(uniqueName);
// make sure we have all the information in our profiles:
foreach (ProfileInformation *pi, d->m_informationList) {
if (!p->hasValue(pi->dataId()))
......
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