Utils: Introduce variantFromStore and storeFromVariant

These are functional replacements for
  QVariant::fromValue(QVariantMap) (or QVariant::fromValue(Store)) and
  QVariant::toMap() (or QVariant::toValue<Store>())

We will have a few code paths in the end that need to explicitly
operarate on both QVariantMap and Store (e.g. actual reading/writing
to keep format compatibility etc), so these can't in the end be
simple to/fromValue(OneType) but need an internal 'if' or such.

Change-Id: I954f3cb24fa8fe123162b72bbd25d891dd19b768
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-08-28 10:55:31 +02:00
parent bb59dfd636
commit 23149b27ab
39 changed files with 149 additions and 136 deletions

View File

@@ -612,7 +612,7 @@ QList<BaseSettings *> LanguageClientSettings::fromSettings(QSettings *settingsIn
for (auto varList :
{settingsIn->value(clientsKey).toList(), settingsIn->value(typedClientsKey).toList()}) {
for (const QVariant &var : varList) {
const Store map = var.value<Store>();
const Store map = storeFromVariant(var);
Id typeId = Id::fromSetting(map.value(typeIdKey));
if (!typeId.isValid())
typeId = Constants::LANGUAGECLIENT_STDIO_SETTINGS_ID;
@@ -659,7 +659,7 @@ void LanguageClientSettings::toSettings(QSettings *settings,
settings->beginGroup(settingsGroupKey);
auto transform = [](const QList<BaseSettings *> &settings) {
return Utils::transform(settings, [](const BaseSettings *setting) {
return QVariant::fromValue(setting->toMap());
return variantFromStore(setting->toMap());
});
};
auto isStdioSetting = Utils::equal(&BaseSettings::m_settingsTypeId,