AutoTest: Only write values that are not default to user files

Change-Id: I0e36cdbc850c148e5fa7c865f3f1136a4dc8a11f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2023-01-17 16:01:40 +01:00
parent 41294e70b4
commit 534e1f34b2
2 changed files with 7 additions and 4 deletions

View File

@@ -47,18 +47,21 @@ public:
void clear() { m_cache.clear(); } void clear() { m_cache.clear(); }
bool isEmpty() const { return m_cache.isEmpty(); } bool isEmpty() const { return m_cache.isEmpty(); }
QVariantMap toSettings() const QVariantMap toSettings(const T &valueToIgnore) const
{ {
QVariantMap result; QVariantMap result;
for (auto it = m_cache.cbegin(), end = m_cache.cend(); it != end; ++it) for (auto it = m_cache.cbegin(), end = m_cache.cend(); it != end; ++it) {
if (it.value().value == valueToIgnore)
continue;
result.insert(QString::number(it.value().type) + '@' result.insert(QString::number(it.value().type) + '@'
+ it.key(), QVariant::fromValue(it.value().value)); + it.key(), QVariant::fromValue(it.value().value));
}
return result; return result;
} }
void fromSettings(const QVariantMap &stored) void fromSettings(const QVariantMap &stored)
{ {
const QRegularExpression regex("^((\\d+)@)?(.*)$"); static const QRegularExpression regex("^((\\d+)@)?(.*)$");
m_cache.clear(); m_cache.clear();
for (auto it = stored.cbegin(), end = stored.cend(); it != end; ++it) { for (auto it = stored.cbegin(), end = stored.cend(); it != end; ++it) {
const QRegularExpressionMatch match = regex.match(it.key()); const QRegularExpressionMatch match = regex.match(it.key());

View File

@@ -108,7 +108,7 @@ void TestProjectSettings::save()
activeFrameworks.insert(it.key()->id().toString(), it.value()); activeFrameworks.insert(it.key()->id().toString(), it.value());
m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks); m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks);
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, int(m_runAfterBuild)); m_project->setNamedSettings(SK_RUN_AFTER_BUILD, int(m_runAfterBuild));
m_project->setNamedSettings(SK_CHECK_STATES, m_checkStateCache.toSettings()); m_project->setNamedSettings(SK_CHECK_STATES, m_checkStateCache.toSettings(Qt::Checked));
} }
} // namespace Internal } // namespace Internal