ESGRAF48/source/DataModel.cpp

45 lines
947 B
C++
Raw Normal View History

2018-05-16 05:02:12 +00:00
#include "DataModel.h"
#include <QDebug>
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-06-04 16:48:58 +00:00
, m_plural(this)
2018-06-06 16:05:30 +00:00
, m_results(this)
2018-05-16 05:02:12 +00:00
{
connect(&m_plural, &PluralModel::dataChanged,
this, &DataModel::pluralModelChanged);
connect(&m_metaData, &PluralModel::dataChanged,
this, &DataModel::metaDataChanged);
2018-05-16 05:02:12 +00:00
}
void DataModel::write(QJsonObject &target) const
{
2018-05-24 19:07:42 +00:00
write(m_metaData, target, "MetaData");
write(m_verbEnd, target, "VerbEnd");
write(m_genus, target, "Genus");
2018-06-04 16:48:58 +00:00
write(m_plural, target, "Plural");
2018-05-16 05:02:12 +00:00
}
void DataModel::read(const QJsonObject &source)
{
2018-05-24 19:07:42 +00:00
read(m_metaData, source, "MetaData");
read(m_verbEnd, source, "VerbEnd");
read(m_genus, source, "Genus");
2018-06-04 16:48:58 +00:00
read(m_plural, source, "Plural");
2018-05-16 05:02:12 +00:00
}
void DataModel::pluralModelChanged()
{
m_results.setPluralResult(m_plural.getPoints());
}
void DataModel::metaDataChanged()
{
2018-06-09 11:13:00 +00:00
m_results.setAge(m_metaData.getAge());
}