ESGRAF48/source/DataModel.cpp

46 lines
830 B
C++
Raw Normal View History

2018-05-16 05:02:12 +00:00
#include "DataModel.h"
2018-05-18 17:51:48 +00:00
DataModel::DataModel(QObject *parent)
: QObject(parent)
, m_metaData(this)
2018-05-23 16:43:57 +00:00
, m_verbEnd(this)
2018-05-22 18:23:03 +00:00
, m_genus(this)
2018-05-16 05:02:12 +00:00
{
}
void DataModel::write(QJsonObject &target) const
{
QJsonObject metaData;
m_metaData.write(metaData);
target["MetaData"] = metaData;
2018-05-22 18:23:03 +00:00
2018-05-23 16:43:57 +00:00
QJsonObject verbEnd;
m_verbEnd.write(verbEnd);
target["VerbEnd"] = verbEnd;
2018-05-22 18:23:03 +00:00
QJsonObject genus;
m_genus.write(genus);
target["Genus"] = genus;
2018-05-16 05:02:12 +00:00
}
void DataModel::read(const QJsonObject &source)
{
const auto &metaData = source["MetaData"];
if (metaData.isObject())
{
m_metaData.read(metaData.toObject());
}
2018-05-23 09:08:50 +00:00
2018-05-23 16:43:57 +00:00
const auto &verbEnd = source["VerbEnd"];
if (verbEnd.isObject())
{
m_verbEnd.read(verbEnd.toObject());
}
2018-05-23 09:08:50 +00:00
const auto &genus = source["Genus"];
if (genus.isObject())
{
m_genus.read(genus.toObject());
}
2018-05-16 05:02:12 +00:00
}