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)
|
|
|
|
{
|
|
|
|
for (const auto &itemName : itemNames)
|
|
|
|
{
|
|
|
|
emplace_back(itemName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheckableItems::write(QJsonArray &json) const
|
2018-05-23 06:11:58 +00:00
|
|
|
{
|
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 06:11:58 +00:00
|
|
|
{
|
2018-05-23 09:08:50 +00:00
|
|
|
if (itemObject.isObject())
|
|
|
|
{
|
|
|
|
CheckableItem item;
|
|
|
|
item.read(itemObject.toObject());
|
|
|
|
emplace_back(item);
|
|
|
|
}
|
2018-05-23 06:11:58 +00:00
|
|
|
}
|
|
|
|
}
|