This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
ESGRAF48/source/DataModel.cpp

127 lines
2.9 KiB
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)
, m_akkusativ(this)
, m_dativ(this)
2018-06-25 21:04:32 +00:00
, m_v2Svk(this)
2018-06-26 14:59:51 +00:00
, m_passiv(this)
, m_genitiv(this)
2018-05-16 05:02:12 +00:00
{
2018-06-15 15:53:43 +00:00
connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged);
2018-07-17 18:33:38 +00:00
connect(&m_metaData, &MetaDataModel::dataChanged, this,
2018-06-15 15:53:43 +00:00
&DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this,
&DataModel::genusModelChanged);
2018-06-15 16:36:58 +00:00
connect(&m_verbEnd, &VerbEndModel::dataChanged, this,
&DataModel::verbEndModelChanged);
connect(&m_akkusativ, &AkkusativModel::dataChanged, this,
&DataModel::akkusativModelChanged);
connect(&m_dativ, &DativModel::dataChanged, this,
&DataModel::dativModelChanged);
2018-06-25 21:04:32 +00:00
connect(&m_v2Svk, &V2SvkModel::dataChanged, this,
&DataModel::v2SvkModelChanged);
2018-06-26 14:59:51 +00:00
connect(&m_passiv, &PassivModel::dataChanged, this,
&DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this,
&DataModel::genitivModelChanged);
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");
write(m_akkusativ, target, "Akkusativ");
write(m_dativ, target, "Dativ");
2018-06-25 21:04:32 +00:00
write(m_v2Svk, target, "V2Svk");
2018-06-26 14:59:51 +00:00
write(m_passiv, target, "Passiv");
write(m_genitiv, target, "Genitiv");
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");
read(m_akkusativ, source, "Akkusativ");
read(m_dativ, source, "Dativ");
2018-06-25 21:04:32 +00:00
read(m_v2Svk, source, "V2Svk");
2018-06-26 14:59:51 +00:00
read(m_passiv, source, "Passiv");
read(m_genitiv, source, "Genitiv");
2018-05-16 05:02:12 +00:00
}
2018-06-15 15:53:43 +00:00
void DataModel::pluralModelChanged()
{
m_results.setPluralResult(m_plural.getPoints());
emit modelChanged();
}
void DataModel::metaDataChanged()
{
2018-06-09 11:13:00 +00:00
m_results.setAge(m_metaData.getAge());
emit modelChanged();
}
2018-06-15 15:53:43 +00:00
void DataModel::genusModelChanged()
{
m_results.setGenusResult(m_genus.getPoints());
emit modelChanged();
2018-06-15 15:53:43 +00:00
}
2018-06-15 16:36:58 +00:00
void DataModel::verbEndModelChanged()
{
m_results.setVerbEndResult(m_verbEnd.getPoints());
emit modelChanged();
2018-06-15 16:36:58 +00:00
}
void DataModel::akkusativModelChanged()
{
m_results.setAkkusativResult(m_akkusativ.getPoints());
emit modelChanged();
}
void DataModel::dativModelChanged()
{
m_results.setDativResult(m_dativ.getPoints());
emit modelChanged();
}
2018-06-25 21:04:32 +00:00
void DataModel::v2SvkModelChanged()
{
m_results.setV2Result(m_v2Svk.getV2Points());
m_results.setSvkResult(m_v2Svk.getSvkPoints());
emit modelChanged();
2018-06-25 21:04:32 +00:00
}
2018-06-26 14:59:51 +00:00
void DataModel::passivModelChanged()
{
m_results.setPassivResult(m_passiv.getPoints());
emit modelChanged();
2018-06-26 14:59:51 +00:00
}
void DataModel::genitivModelChanged()
{
m_results.setGenitivResult(m_genitiv.getPoints());
emit modelChanged();
2018-06-26 14:59:51 +00:00
}