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:
@@ -62,7 +62,7 @@ Store BuildStepList::toMap() const
|
||||
for (int i = 0; i < m_steps.count(); ++i) {
|
||||
Store data;
|
||||
m_steps.at(i)->toMap(data);
|
||||
map.insert(STEPS_PREFIX + Key::number(i), QVariant::fromValue(data));
|
||||
map.insert(STEPS_PREFIX + Key::number(i), variantFromStore(data));
|
||||
}
|
||||
|
||||
return map;
|
||||
@@ -111,7 +111,7 @@ bool BuildStepList::fromMap(const Store &map)
|
||||
|
||||
int maxSteps = map.value(STEPS_COUNT_KEY, 0).toInt();
|
||||
for (int i = 0; i < maxSteps; ++i) {
|
||||
Store bsData(map.value(STEPS_PREFIX + Key::number(i)).value<Store>());
|
||||
Store bsData = storeFromVariant(map.value(STEPS_PREFIX + Key::number(i)));
|
||||
if (bsData.isEmpty()) {
|
||||
qWarning() << "No step data found for" << i << "(continuing).";
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user