Skip to content
Snippets Groups Projects
Commit e8e27210 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Project: Allow for additional named settings

Allow for additional named settings to be saved along with the project
data.

This allows plugins to save project-specific settings.

Change-Id: I6ed24089efad2eb466385ac9ca4c2dde8bf8c2eb
Reviewed-on: http://codereview.qt.nokia.com/2443


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent a91001d4
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ const char * const TARGET_KEY_PREFIX("ProjectExplorer.Project.Target.");
const char * const TARGET_COUNT_KEY("ProjectExplorer.Project.TargetCount");
const char * const EDITOR_SETTINGS_KEY("ProjectExplorer.Project.EditorSettings");
const char * const PLUGIN_SETTINGS_KEY("ProjectExplorer.Project.PluginSettings");
} // namespace
namespace ProjectExplorer {
......@@ -89,6 +89,7 @@ public:
EditorConfiguration *m_editorConfiguration;
Core::Context m_projectContext;
Core::Context m_projectLanguage;
QVariantMap m_pluginSettings;
};
ProjectPrivate::ProjectPrivate() :
......@@ -215,6 +216,7 @@ Target *Project::target(const QString &id) const
void Project::saveSettings()
{
emit aboutToSaveSettings();
UserFileAccessor accessor;
accessor.saveSettings(this, toMap());
}
......@@ -223,7 +225,10 @@ bool Project::restoreSettings()
{
UserFileAccessor accessor;
QVariantMap map(accessor.restoreSettings(this));
return fromMap(map);
bool ok = fromMap(map);
if (ok)
emit settingsLoaded();
return ok;
}
QList<BuildConfigWidget*> Project::subConfigWidgets()
......@@ -253,6 +258,7 @@ QVariantMap Project::toMap() const
map.insert(QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(i), ts.at(i)->toMap());
map.insert(QLatin1String(EDITOR_SETTINGS_KEY), d->m_editorConfiguration->toMap());
map.insert(QLatin1String(PLUGIN_SETTINGS_KEY), d->m_pluginSettings);
return map;
}
......@@ -278,6 +284,9 @@ bool Project::fromMap(const QVariantMap &map)
d->m_editorConfiguration->fromMap(values);
}
if (map.contains(QLatin1String(PLUGIN_SETTINGS_KEY)))
d->m_pluginSettings = map.value(QLatin1String(PLUGIN_SETTINGS_KEY)).toMap();
bool ok;
int maxI(map.value(QLatin1String(TARGET_COUNT_KEY), 0).toInt(&ok));
if (!ok || maxI < 0)
......@@ -355,4 +364,14 @@ Core::Context Project::projectLanguage() const
return d->m_projectLanguage;
}
QVariant Project::namedSettings(const QString &name) const
{
return d->m_pluginSettings.value(name);
}
void Project::setNamedSettings(const QString &name, QVariant &value)
{
d->m_pluginSettings.insert(name, value);
}
} // namespace ProjectExplorer
......@@ -114,6 +114,9 @@ public:
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguage() const;
QVariant namedSettings(const QString &name) const;
void setNamedSettings(const QString &name, QVariant &value);
signals:
void fileListChanged();
......@@ -127,6 +130,9 @@ signals:
void environmentChanged();
void buildConfigurationEnabledChanged();
void settingsLoaded();
void aboutToSaveSettings();
protected:
// restore all data from the map.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment