Commit e1b11736 authored by Tobias Hunger's avatar Tobias Hunger

SettingsAccessor: Introduce prepareToSaveSettings

Factoring out code out of ::saveSettings

Change-Id: Iba2e88acef55e244b069ec9f3b31367cd809160f
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 56ddd194
......@@ -419,6 +419,15 @@ QVariantMap UserFileAccessor::prepareSettings(const QVariantMap &data) const
return result;
}
QVariantMap UserFileAccessor::prepareToSaveSettings(const QVariantMap &data) const
{
QVariantMap tmp = SettingsAccessor::prepareToSaveSettings(data);
// for compatibility with QtC 3.1 and older:
tmp.insert(QLatin1String(OBSOLETE_VERSION_KEY), currentVersion());
return tmp;
}
namespace ProjectExplorer {
// --------------------------------------------------------------------
// SettingsAccessorPrivate:
......@@ -823,6 +832,19 @@ QVariantMap SettingsAccessor::restoreSettings(QWidget *parent) const
return mergeSettings(userSettings, sharedSettings);
}
QVariantMap SettingsAccessor::prepareToSaveSettings(const QVariantMap &data) const
{
QVariantMap tmp = data;
const QVariant &shared = m_project->property(SHARED_SETTINGS);
if (shared.isValid())
trackUserStickySettings(tmp, shared.toMap());
tmp.insert(QLatin1String(VERSION_KEY), d->currentVersion());
tmp.insert(QLatin1String(ENVIRONMENT_ID_KEY), SettingsAccessor::creatorId());
return tmp;
}
bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) const
{
if (map.isEmpty())
......@@ -830,22 +852,14 @@ bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) con
backupUserFile();
QVariantMap data = map;
QVariantMap data = prepareToSaveSettings(map);
Utils::FileName path = FileName::fromString(defaultFileName(m_userSuffix));
const QVariant &shared = m_project->property(SHARED_SETTINGS);
if (shared.isValid())
trackUserStickySettings(data, shared.toMap());
if (!d->m_writer || d->m_writer->fileName() != path) {
delete d->m_writer;
d->m_writer = new PersistentSettingsWriter(path, QLatin1String("QtCreatorProject"));
}
data.insert(QLatin1String(VERSION_KEY), d->currentVersion());
// for compatibility with QtC 3.1 and older:
data.insert(QLatin1String(OBSOLETE_VERSION_KEY), d->currentVersion()); // TODO: Move into UserfileAccessor!
data.insert(QLatin1String(ENVIRONMENT_ID_KEY), SettingsAccessor::creatorId());
return d->m_writer->save(data, parent);
}
......
......@@ -110,6 +110,7 @@ protected:
ProceedInfo reportIssues(const QVariantMap &data, const Utils::FileName &path, QWidget *parent) const;
virtual QVariantMap prepareSettings(const QVariantMap &data) const;
virtual QVariantMap prepareToSaveSettings(const QVariantMap &data) const;
virtual bool isBetterMatch(const QVariantMap &origData, const QVariantMap &newData) const;
......@@ -146,6 +147,7 @@ public:
protected:
QVariantMap prepareSettings(const QVariantMap &data) const;
QVariantMap prepareToSaveSettings(const QVariantMap &data) const;
};
} // namespace Internal
......
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