ESGRAF48/source/Genus/CheckableItems.cpp

37 lines
706 B
C++
Raw Normal View History

#include "CheckableItems.h"
2018-05-23 09:08:50 +00:00
#include <QJsonArray>
CheckableItems::CheckableItems(std::initializer_list<std::string> itemNames)
{
for (const auto &itemName : itemNames)
{
emplace_back(itemName);
}
}
void CheckableItems::write(QJsonArray &json) const
{
2018-05-23 09:08:50 +00:00
for (const auto &item : *this)
{
QJsonObject itemObject;
item.write(itemObject);
json.append(itemObject);
}
}
void CheckableItems::read(const QJsonArray &json)
{
clear();
for (const auto &itemObject : json)
{
2018-05-23 09:08:50 +00:00
if (itemObject.isObject())
{
CheckableItem item;
item.read(itemObject.toObject());
emplace_back(item);
}
}
}