Utils: Write Key/Store to settings

We claim that we still store QVariantMap to keep the format unchanged.

Change-Id: Ie7b0a83febfeb2cb3cfc9ee42b8423453cf3b1c4
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-08-25 15:38:03 +02:00
parent e5afe02556
commit 52d1cd47cb
4 changed files with 31 additions and 18 deletions

View File

@@ -4,6 +4,7 @@
#include "store.h"
#include "algorithm.h"
#include "qtcassert.h"
namespace Utils {
@@ -24,7 +25,14 @@ QVariant variantFromStore(const Store &store)
Store storeFromVariant(const QVariant &value)
{
return value.value<Store>();
if (value.typeId() == qMetaTypeId<Store>())
return value.value<Store>();
if (value.typeId() == QMetaType::QVariantMap)
return storeFromMap(value.toMap());
QTC_CHECK(false);
return Store();
}
#ifdef QTC_USE_STORE
@@ -99,4 +107,10 @@ QVariantMap mapFromStore(const Store &store)
#endif
}
bool isStore(const QVariant &value)
{
const int typeId = value.typeId();
return typeId == QMetaType::QVariantMap || typeId == qMetaTypeId<Store>();
}
} // Utils