mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
refs #665 Cache will only load and save the values that it really needs to.
This commit is contained in:
@@ -14,9 +14,8 @@
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
QJsonObject CVariantMap::toJson() const
|
||||
QJsonObject &CVariantMap::mergeToJson(QJsonObject &json) const
|
||||
{
|
||||
QJsonObject json;
|
||||
for (auto it = cbegin(); it != cend(); ++it)
|
||||
{
|
||||
json.insert(it.key(), it.value().toJson());
|
||||
@@ -24,6 +23,13 @@ namespace BlackMisc
|
||||
return json;
|
||||
}
|
||||
|
||||
QJsonObject CVariantMap::toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
mergeToJson(json);
|
||||
return json;
|
||||
}
|
||||
|
||||
void CVariantMap::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
clear();
|
||||
@@ -35,4 +41,17 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CVariantMap::convertFromJson(const QJsonObject &json, const QStringList &keys)
|
||||
{
|
||||
clear();
|
||||
for (const auto &key : keys)
|
||||
{
|
||||
auto value = json.value(key);
|
||||
if (value.isUndefined()) { continue; }
|
||||
CVariant var;
|
||||
var.convertFromJson(value.toObject());
|
||||
insert(key, var);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user