forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user