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