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 ...@@ -419,6 +419,15 @@ QVariantMap UserFileAccessor::prepareSettings(const QVariantMap &data) const
return result; 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 { namespace ProjectExplorer {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// SettingsAccessorPrivate: // SettingsAccessorPrivate:
...@@ -823,6 +832,19 @@ QVariantMap SettingsAccessor::restoreSettings(QWidget *parent) const ...@@ -823,6 +832,19 @@ QVariantMap SettingsAccessor::restoreSettings(QWidget *parent) const
return mergeSettings(userSettings, sharedSettings); 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 bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) const
{ {
if (map.isEmpty()) if (map.isEmpty())
...@@ -830,22 +852,14 @@ bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) con ...@@ -830,22 +852,14 @@ bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) con
backupUserFile(); backupUserFile();
QVariantMap data = map; QVariantMap data = prepareToSaveSettings(map);
Utils::FileName path = FileName::fromString(defaultFileName(m_userSuffix)); 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) { if (!d->m_writer || d->m_writer->fileName() != path) {
delete d->m_writer; delete d->m_writer;
d->m_writer = new PersistentSettingsWriter(path, QLatin1String("QtCreatorProject")); 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); return d->m_writer->save(data, parent);
} }
......
...@@ -110,6 +110,7 @@ protected: ...@@ -110,6 +110,7 @@ protected:
ProceedInfo reportIssues(const QVariantMap &data, const Utils::FileName &path, QWidget *parent) const; ProceedInfo reportIssues(const QVariantMap &data, const Utils::FileName &path, QWidget *parent) const;
virtual QVariantMap prepareSettings(const QVariantMap &data) 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; virtual bool isBetterMatch(const QVariantMap &origData, const QVariantMap &newData) const;
...@@ -146,6 +147,7 @@ public: ...@@ -146,6 +147,7 @@ public:
protected: protected:
QVariantMap prepareSettings(const QVariantMap &data) const; QVariantMap prepareSettings(const QVariantMap &data) const;
QVariantMap prepareToSaveSettings(const QVariantMap &data) const;
}; };
} // namespace Internal } // 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