summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/projectconfiguration.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2010-08-19 12:26:21 +0200
committerTobias Hunger <tobias.hunger@nokia.com>2010-08-24 16:04:51 +0200
commit616a9b13f08e41a8ffe67e852ed4197b99377a5f (patch)
tree824f8521e02e09ec7f38b474b8b7b397c7777879 /src/plugins/projectexplorer/projectconfiguration.cpp
parentb6f1dbeeb0036669dd75e0fe59f9b982c3fcddae (diff)
downloadqt-creator-616a9b13f08e41a8ffe67e852ed4197b99377a5f.tar.gz
Enable restoring the default names of project configuration items
* Enable support for this in all ProjectConfiguration items (Targets, projects, BCs, DCs, RCs, etc.). This is nicer than having custom code in individual configuraiton items. Reviewed-by: dt
Diffstat (limited to 'src/plugins/projectexplorer/projectconfiguration.cpp')
-rw-r--r--src/plugins/projectexplorer/projectconfiguration.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/plugins/projectexplorer/projectconfiguration.cpp b/src/plugins/projectexplorer/projectconfiguration.cpp
index 4c76cf9531..fb27a64b36 100644
--- a/src/plugins/projectexplorer/projectconfiguration.cpp
+++ b/src/plugins/projectexplorer/projectconfiguration.cpp
@@ -34,6 +34,7 @@ using namespace ProjectExplorer;
namespace {
const char * const CONFIGURATION_ID_KEY("ProjectExplorer.ProjectConfiguration.Id");
const char * const DISPLAY_NAME_KEY("ProjectExplorer.ProjectConfiguration.DisplayName");
+const char * const DEFAULT_DISPLAY_NAME_KEY("ProjectExplorer.ProjectConfiguration.DefaultDisplayName");
}
ProjectConfiguration::ProjectConfiguration(QObject *parent, const QString &id) :
@@ -44,10 +45,11 @@ ProjectConfiguration::ProjectConfiguration(QObject *parent, const QString &id) :
}
ProjectConfiguration::ProjectConfiguration(QObject *parent, const ProjectConfiguration *source) :
- QObject(parent)
+ QObject(parent),
+ m_id(source->m_id),
+ m_defaultDisplayName(source->m_defaultDisplayName)
{
Q_ASSERT(source);
- m_id = source->m_id;
m_displayName = tr("Clone of %1").arg(source->displayName());
}
@@ -61,22 +63,35 @@ QString ProjectConfiguration::id() const
QString ProjectConfiguration::displayName() const
{
- return m_displayName;
+ if (!m_displayName.isEmpty())
+ return m_displayName;
+ return m_defaultDisplayName;
}
void ProjectConfiguration::setDisplayName(const QString &name)
{
- if (name == m_displayName)
+ if (displayName() == name)
return;
m_displayName = name;
emit displayNameChanged();
}
+void ProjectConfiguration::setDefaultDisplayName(const QString &name)
+{
+ if (m_defaultDisplayName == name)
+ return;
+ const QString originalName = displayName();
+ m_defaultDisplayName = name;
+ if (originalName != displayName())
+ emit displayNameChanged();
+}
+
QVariantMap ProjectConfiguration::toMap() const
{
QVariantMap map;
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id);
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
+ map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
return map;
}
@@ -84,6 +99,7 @@ bool ProjectConfiguration::fromMap(const QVariantMap &map)
{
m_id = map.value(QLatin1String(CONFIGURATION_ID_KEY), QString()).toString();
m_displayName = map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
+ m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_displayName).toString();
return !m_id.isEmpty();
}