Item: only save fields that are set in the item
This commit is contained in:
parent
221cb519a2
commit
a96b27c741
1 changed files with 21 additions and 15 deletions
|
|
@ -58,9 +58,9 @@ void ItemData::storeWithChanges(QJsonObject& json, const ItemFieldChanges& chang
|
|||
json["Name"] = name_;
|
||||
if(changes.value)
|
||||
json["Value"] = static_cast<double>(value_);
|
||||
if(changes.groupName)
|
||||
if(changes.groupName && !groupName_.isEmpty() && groupName_ != "All")
|
||||
json["GroupName"] = groupName_;
|
||||
if(changes.valueNames)
|
||||
if(changes.valueNames && !valueNames_.empty())
|
||||
{
|
||||
QJsonArray valueNamesArray;
|
||||
for(const QString& name : valueNames_)
|
||||
|
|
@ -218,6 +218,8 @@ void Item::store(QJsonObject &json)
|
|||
{
|
||||
ItemData::store(json);
|
||||
json["override"] = override_;
|
||||
if(!actors_.empty())
|
||||
{
|
||||
QJsonArray actorsArray;
|
||||
for(size_t i = 0; i < actors_.size(); ++i)
|
||||
{
|
||||
|
|
@ -230,11 +232,14 @@ void Item::store(QJsonObject &json)
|
|||
}
|
||||
json["Actors"] = actorsArray;
|
||||
}
|
||||
}
|
||||
|
||||
void Item::load(const QJsonObject &json, const bool preserve)
|
||||
{
|
||||
ItemData::load(json, preserve);
|
||||
override_ = json["override"].toBool(false);
|
||||
if(json.contains("Actors"))
|
||||
{
|
||||
const QJsonArray actorsArray(json["Actors"].toArray(QJsonArray()));
|
||||
for(int i = 0; i < actorsArray.size(); ++i)
|
||||
{
|
||||
|
|
@ -246,6 +251,7 @@ void Item::load(const QJsonObject &json, const bool preserve)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item& Item::operator=(const ItemData& other)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue