summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/projectexplorer/profile.cpp48
-rw-r--r--src/plugins/projectexplorer/profile.h2
-rw-r--r--src/plugins/projectexplorer/profileinformation.cpp12
-rw-r--r--src/plugins/projectexplorer/profileinformation.h4
-rw-r--r--src/plugins/projectexplorer/profilemanager.cpp7
-rw-r--r--src/plugins/projectexplorer/profilemanager.h2
-rw-r--r--src/plugins/qtsupport/qtprofileinformation.cpp6
-rw-r--r--src/plugins/qtsupport/qtprofileinformation.h2
8 files changed, 72 insertions, 11 deletions
diff --git a/src/plugins/projectexplorer/profile.cpp b/src/plugins/projectexplorer/profile.cpp
index 934038dd90..867282ca72 100644
--- a/src/plugins/projectexplorer/profile.cpp
+++ b/src/plugins/projectexplorer/profile.cpp
@@ -101,11 +101,14 @@ Profile::~Profile()
delete d;
}
-Profile *Profile::clone() const
+Profile *Profile::clone(bool keepName) const
{
Profile *p = new Profile;
- p->d->m_displayName = QCoreApplication::translate("ProjectExplorer::Profile", "Clone of %1")
- .arg(d->m_displayName);
+ if (keepName)
+ p->d->m_displayName = d->m_displayName;
+ else
+ p->d->m_displayName = QCoreApplication::translate("ProjectExplorer::Profile", "Clone of %1")
+ .arg(d->m_displayName);
p->d->m_autodetected = false;
p->d->m_data = d->m_data;
p->d->m_isValid = d->m_isValid;
@@ -133,20 +136,45 @@ QString Profile::displayName() const
return d->m_displayName;
}
+static QString candidateName(const QString &name, const QString &postfix)
+{
+ if (name.contains(postfix))
+ return QString();
+ return name + QLatin1Char('-') + postfix;
+}
+
void Profile::setDisplayName(const QString &name)
{
- // make name unique:
+ ProfileManager *pm = ProfileManager::instance();
+ QList<ProfileInformation *> profileInfo = pm->profileInformation();
+
QStringList nameList;
- foreach (Profile *p, ProfileManager::instance()->profiles())
+ foreach (Profile *p, pm->profiles()) {
nameList << p->displayName();
+ foreach (ProfileInformation *pi, profileInfo) {
+ const QString postfix = pi->displayNamePostfix(p);
+ if (!postfix.isEmpty())
+ nameList << candidateName(p->displayName(), postfix);
+ }
+ }
+
+ QStringList candidateNames;
+ candidateNames << name;
+
+ foreach (ProfileInformation *pi, profileInfo) {
+ const QString postfix = pi->displayNamePostfix(this);
+ if (!postfix.isEmpty())
+ candidateNames << candidateName(name, postfix);
+ }
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);
+ foreach (const QString &candidate, candidateNames) {
+ const QString tmp = Project::makeUnique(candidate, nameList);
+ if (tmp == candidate) {
+ uniqueName = tmp;
+ break;
+ }
}
}
diff --git a/src/plugins/projectexplorer/profile.h b/src/plugins/projectexplorer/profile.h
index 88d619dc61..4db326dbdf 100644
--- a/src/plugins/projectexplorer/profile.h
+++ b/src/plugins/projectexplorer/profile.h
@@ -82,7 +82,7 @@ public:
void addToEnvironment(Utils::Environment &env) const;
QString toHtml();
- Profile *clone() const;
+ Profile *clone(bool keepName = false) const;
private:
// Unimplemented.
diff --git a/src/plugins/projectexplorer/profileinformation.cpp b/src/plugins/projectexplorer/profileinformation.cpp
index c75f265a9a..29a90d8811 100644
--- a/src/plugins/projectexplorer/profileinformation.cpp
+++ b/src/plugins/projectexplorer/profileinformation.cpp
@@ -178,6 +178,12 @@ ProfileConfigWidget *ToolChainProfileInformation::createConfigWidget(Profile *p)
return new Internal::ToolChainInformationConfigWidget(p);
}
+QString ToolChainProfileInformation::displayNamePostfix(const Profile *p) const
+{
+ ToolChain *tc = toolChain(p);
+ return tc ? tc->displayName() : QString();
+}
+
ProfileInformation::ItemList ToolChainProfileInformation::toUserOutput(Profile *p) const
{
ToolChain *tc = toolChain(p);
@@ -327,6 +333,12 @@ ProfileConfigWidget *DeviceProfileInformation::createConfigWidget(Profile *p) co
return new Internal::DeviceInformationConfigWidget(p);
}
+QString DeviceProfileInformation::displayNamePostfix(const Profile *p) const
+{
+ IDevice::ConstPtr dev = device(p);
+ return dev.isNull() ? QString() : dev->displayName();
+}
+
ProfileInformation::ItemList DeviceProfileInformation::toUserOutput(Profile *p) const
{
IDevice::ConstPtr dev = device(p);
diff --git a/src/plugins/projectexplorer/profileinformation.h b/src/plugins/projectexplorer/profileinformation.h
index 24485b33e6..641743924f 100644
--- a/src/plugins/projectexplorer/profileinformation.h
+++ b/src/plugins/projectexplorer/profileinformation.h
@@ -107,6 +107,8 @@ public:
ProfileConfigWidget *createConfigWidget(Profile *p) const;
+ QString displayNamePostfix(const Profile *p) const;
+
ItemList toUserOutput(Profile *p) const;
void addToEnvironment(const Profile *p, Utils::Environment &env) const;
@@ -196,6 +198,8 @@ public:
ProfileConfigWidget *createConfigWidget(Profile *p) const;
+ QString displayNamePostfix(const Profile *p) const;
+
ItemList toUserOutput(Profile *p) const;
static IDevice::ConstPtr device(const Profile *p);
diff --git a/src/plugins/projectexplorer/profilemanager.cpp b/src/plugins/projectexplorer/profilemanager.cpp
index dcfe0e9bfc..2c2ad231e6 100644
--- a/src/plugins/projectexplorer/profilemanager.cpp
+++ b/src/plugins/projectexplorer/profilemanager.cpp
@@ -452,6 +452,7 @@ void ProfileManager::addProfile(Profile *p)
{
if (!p)
return;
+ p->setDisplayName(p->displayName()); // make name unique
d->validateProfile(p);
d->m_profileList.append(p);
if (!d->m_defaultProfile ||
@@ -466,4 +467,10 @@ void ProfileInformation::addToEnvironment(const Profile *p, Utils::Environment &
Q_UNUSED(env);
}
+QString ProfileInformation::displayNamePostfix(const Profile *p) const
+{
+ Q_UNUSED(p);
+ return QString();
+}
+
} // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/profilemanager.h b/src/plugins/projectexplorer/profilemanager.h
index 1132f80b83..48da926dc6 100644
--- a/src/plugins/projectexplorer/profilemanager.h
+++ b/src/plugins/projectexplorer/profilemanager.h
@@ -82,6 +82,8 @@ public:
virtual void addToEnvironment(const Profile *p, Utils::Environment &env) const;
+ virtual QString displayNamePostfix(const Profile *p) const;
+
signals:
void validationNeeded();
};
diff --git a/src/plugins/qtsupport/qtprofileinformation.cpp b/src/plugins/qtsupport/qtprofileinformation.cpp
index 84b7409bf3..a6d1db6b11 100644
--- a/src/plugins/qtsupport/qtprofileinformation.cpp
+++ b/src/plugins/qtsupport/qtprofileinformation.cpp
@@ -98,6 +98,12 @@ QtProfileInformation::createConfigWidget(ProjectExplorer::Profile *p) const
return new Internal::QtProfileConfigWidget(p);
}
+QString QtProfileInformation::displayNamePostfix(const ProjectExplorer::Profile *p) const
+{
+ BaseQtVersion *version = qtVersion(p);
+ return version ? version->displayName() : QString();
+}
+
ProjectExplorer::ProfileInformation::ItemList
QtProfileInformation::toUserOutput(ProjectExplorer::Profile *p) const
{
diff --git a/src/plugins/qtsupport/qtprofileinformation.h b/src/plugins/qtsupport/qtprofileinformation.h
index e5369c710d..9b3c65241e 100644
--- a/src/plugins/qtsupport/qtprofileinformation.h
+++ b/src/plugins/qtsupport/qtprofileinformation.h
@@ -56,6 +56,8 @@ public:
ProjectExplorer::ProfileConfigWidget *createConfigWidget(ProjectExplorer::Profile *p) const;
+ QString displayNamePostfix(const ProjectExplorer::Profile *p) const;
+
ItemList toUserOutput(ProjectExplorer::Profile *p) const;
void addToEnvironment(const ProjectExplorer::Profile *p, Utils::Environment &env) const;