2018-05-16 05:02:12 +00:00
|
|
|
#include "DataModel.h"
|
2018-11-13 23:17:29 +00:00
|
|
|
#include "DataModel.pb.h"
|
2018-06-08 18:25:21 +00:00
|
|
|
|
2018-11-03 21:29:38 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2018-05-18 17:51:48 +00:00
|
|
|
DataModel::DataModel(QObject *parent)
|
2018-11-03 21:29:38 +00:00
|
|
|
: QObject(parent)
|
|
|
|
, m_metaData(this)
|
|
|
|
, m_verbEnd(this)
|
|
|
|
, m_genus(this)
|
|
|
|
, m_plural(this)
|
|
|
|
, m_results(this)
|
|
|
|
, m_akkusativ(this)
|
|
|
|
, m_dativ(this)
|
|
|
|
, 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-11-03 21:29:38 +00:00
|
|
|
connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged);
|
|
|
|
connect(&m_metaData, &MetaDataModel::dataChanged, this, &DataModel::metaDataChanged);
|
|
|
|
connect(&m_genus, &GenusModel::dataChanged, this, &DataModel::genusModelChanged);
|
|
|
|
connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged);
|
|
|
|
connect(&m_akkusativ, &AkkusativModel::dataChanged, this, &DataModel::akkusativModelChanged);
|
|
|
|
connect(&m_dativ, &DativModel::dataChanged, this, &DataModel::dativModelChanged);
|
|
|
|
connect(&m_v2Svk, &V2SvkModel::dataChanged, this, &DataModel::v2SvkModelChanged);
|
|
|
|
connect(&m_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged);
|
|
|
|
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
|
2018-05-16 05:02:12 +00:00
|
|
|
}
|
|
|
|
|
2018-11-20 06:59:12 +00:00
|
|
|
void DataModel::write(std::ostream &outStream) const
|
2018-11-13 23:17:29 +00:00
|
|
|
{
|
|
|
|
ESGRAF48::DataModel dataModel;
|
2018-11-16 22:21:02 +00:00
|
|
|
|
2018-11-20 06:59:12 +00:00
|
|
|
m_metaData.write(*dataModel.mutable_metadata());
|
|
|
|
m_v2Svk.write(*dataModel.mutable_v2svk());
|
2018-11-20 22:05:49 +00:00
|
|
|
m_verbEnd.write(*dataModel.mutable_verbend());
|
2018-11-20 06:59:12 +00:00
|
|
|
m_genus.write(*dataModel.mutable_genus());
|
2018-11-18 16:12:03 +00:00
|
|
|
m_akkusativ.write(*dataModel.mutable_akkusativ());
|
|
|
|
m_dativ.write(*dataModel.mutable_dativ());
|
2018-11-18 16:40:07 +00:00
|
|
|
m_plural.write(*dataModel.mutable_plural());
|
2018-11-18 20:29:43 +00:00
|
|
|
m_genitiv.write(*dataModel.mutable_lateskillsgenitiv());
|
|
|
|
m_passiv.write(*dataModel.mutable_lateskillspassiv());
|
2018-11-16 22:21:02 +00:00
|
|
|
|
2018-11-13 23:17:29 +00:00
|
|
|
dataModel.SerializeToOstream(&outStream);
|
|
|
|
}
|
|
|
|
|
2018-11-20 06:59:12 +00:00
|
|
|
void DataModel::read(std::istream &inStream)
|
2018-11-13 23:17:29 +00:00
|
|
|
{
|
|
|
|
ESGRAF48::DataModel dataModel;
|
|
|
|
dataModel.ParseFromIstream(&inStream);
|
|
|
|
|
2018-11-20 06:59:12 +00:00
|
|
|
m_metaData.read(dataModel.metadata());
|
|
|
|
m_v2Svk.read(dataModel.v2svk());
|
|
|
|
m_verbEnd.read(dataModel.verbend());
|
|
|
|
m_genus.read(dataModel.genus());
|
2018-11-18 16:12:03 +00:00
|
|
|
m_akkusativ.read(dataModel.akkusativ());
|
|
|
|
m_dativ.read(dataModel.dativ());
|
2018-11-18 16:40:07 +00:00
|
|
|
m_plural.read(dataModel.plural());
|
2018-11-18 20:29:43 +00:00
|
|
|
m_genitiv.read(dataModel.lateskillsgenitiv());
|
|
|
|
m_passiv.read(dataModel.lateskillspassiv());
|
2018-11-13 23:17:29 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 20:47:42 +00:00
|
|
|
void DataModel::printTo(QTextCursor &cursor) const
|
|
|
|
{
|
|
|
|
QTextCharFormat titleFormat;
|
2018-12-08 20:02:35 +00:00
|
|
|
titleFormat.setFontPointSize(14);
|
2018-12-02 17:26:22 +00:00
|
|
|
|
2018-11-26 20:47:42 +00:00
|
|
|
cursor.insertText("ESGRAF 4-8 Auswertungsbogen", titleFormat);
|
2018-11-28 21:39:51 +00:00
|
|
|
cursor.insertText("\n", titleFormat);
|
2018-11-26 20:47:42 +00:00
|
|
|
|
|
|
|
m_metaData.printTo(cursor);
|
2018-12-02 17:26:22 +00:00
|
|
|
|
2018-12-08 20:02:35 +00:00
|
|
|
//m_v2Svk.printTo(cursor);
|
2018-12-02 17:26:22 +00:00
|
|
|
m_verbEnd.printTo(cursor);
|
2018-12-08 20:02:35 +00:00
|
|
|
m_genus.printTo(cursor);
|
|
|
|
m_akkusativ.printTo(cursor);
|
|
|
|
m_dativ.printTo(cursor);
|
|
|
|
//m_plural.printTo(cursor);
|
|
|
|
//m_genitiv.printTo(cursor);
|
|
|
|
//m_passiv.printTo(cursor);
|
2018-12-02 17:26:22 +00:00
|
|
|
|
|
|
|
//m_results.printTo(cursor);
|
2018-11-26 20:47:42 +00:00
|
|
|
}
|
|
|
|
|
2018-06-08 18:25:21 +00:00
|
|
|
void DataModel::pluralModelChanged()
|
|
|
|
{
|
|
|
|
m_results.setPluralResult(m_plural.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-08 18:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DataModel::metaDataChanged()
|
|
|
|
{
|
2018-06-09 11:13:00 +00:00
|
|
|
m_results.setAge(m_metaData.getAge());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-08 18:25:21 +00:00
|
|
|
}
|
2018-06-15 15:53:43 +00:00
|
|
|
|
|
|
|
void DataModel::genusModelChanged()
|
|
|
|
{
|
|
|
|
m_results.setGenusResult(m_genus.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
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());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-15 16:36:58 +00:00
|
|
|
}
|
2018-06-17 16:44:54 +00:00
|
|
|
|
|
|
|
void DataModel::akkusativModelChanged()
|
|
|
|
{
|
|
|
|
m_results.setAkkusativResult(m_akkusativ.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-17 16:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DataModel::dativModelChanged()
|
|
|
|
{
|
|
|
|
m_results.setDativResult(m_dativ.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-17 16:44:54 +00:00
|
|
|
}
|
2018-06-25 21:04:32 +00:00
|
|
|
|
|
|
|
void DataModel::v2SvkModelChanged()
|
|
|
|
{
|
|
|
|
m_results.setV2Result(m_v2Svk.getV2Points());
|
|
|
|
m_results.setSvkResult(m_v2Svk.getSvkPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-25 21:04:32 +00:00
|
|
|
}
|
2018-06-26 14:59:51 +00:00
|
|
|
|
|
|
|
void DataModel::passivModelChanged()
|
|
|
|
{
|
2018-11-03 21:29:38 +00:00
|
|
|
m_results.setPassivResult(m_passiv.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-26 14:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DataModel::genitivModelChanged()
|
|
|
|
{
|
2018-11-03 21:29:38 +00:00
|
|
|
m_results.setGenitivResult(m_genitiv.getPoints());
|
2018-09-29 11:31:23 +00:00
|
|
|
|
|
|
|
emit modelChanged();
|
2018-06-26 14:59:51 +00:00
|
|
|
}
|