forked from qt-creator/qt-creator
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:
@@ -131,7 +131,7 @@ void IosDevice::fromMap(const Store &map)
|
||||
IDevice::fromMap(map);
|
||||
|
||||
m_extraInfo.clear();
|
||||
const Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>();
|
||||
const Store vMap = storeFromVariant(map.value(Constants::EXTRA_INFO_KEY));
|
||||
for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i)
|
||||
m_extraInfo.insert(stringFromKey(i.key()), i.value().toString());
|
||||
}
|
||||
@@ -142,7 +142,7 @@ Store IosDevice::toMap() const
|
||||
Store vMap;
|
||||
for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i)
|
||||
vMap.insert(keyFromString(i.key()), i.value());
|
||||
res.insert(Constants::EXTRA_INFO_KEY, QVariant::fromValue(vMap));
|
||||
res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ void IosDeviceTypeAspect::fromMap(const Store &map)
|
||||
{
|
||||
bool deviceTypeIsInt;
|
||||
map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
|
||||
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).value<Store>()))
|
||||
if (deviceTypeIsInt || !m_deviceType.fromMap(storeFromVariant(map.value(deviceTypeKey))))
|
||||
updateDeviceType();
|
||||
|
||||
m_runConfiguration->update();
|
||||
|
||||
Reference in New Issue
Block a user