ESGRAF48/source/SubTests/V2Svk/TPrModel.cpp

100 lines
2.5 KiB
C++
Raw Permalink Normal View History

2019-01-31 19:14:38 +00:00
#include "TPrModel.h"
2019-10-05 14:14:45 +00:00
TPrModel::TPrModel(QObject* parent)
2019-02-03 18:53:51 +00:00
: V2SvkModel(parent)
2019-01-31 19:14:38 +00:00
{
2019-10-05 14:14:45 +00:00
m_tests = {
{"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
};
2019-01-31 19:14:38 +00:00
}
2019-02-03 18:53:51 +00:00
unsigned int TPrModel::getV2Points() const
2019-01-31 19:14:38 +00:00
{
2019-10-05 14:14:45 +00:00
unsigned int points = 0;
for (auto testIndex : {0})
{
const auto& test = m_tests.at(testIndex);
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
2019-01-31 19:14:38 +00:00
}
2019-02-03 18:53:51 +00:00
unsigned int TPrModel::getSvkPoints() const
2019-01-31 19:14:38 +00:00
{
2019-10-05 14:14:45 +00:00
unsigned int points = 0;
for (auto testIndex : {1})
{
const auto& test = m_tests.at(testIndex);
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
2019-01-31 19:14:38 +00:00
}
2019-10-05 14:14:45 +00:00
void TPrModel::write(ESGRAF48::V2SvkModel& model) const
2019-01-31 19:14:38 +00:00
{
2019-10-05 14:14:45 +00:00
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_schwein1(testItems[2].isChecked());
modelData->set_schwein2(testItems[3].isChecked());
modelData->set_gans1(testItems[4].isChecked());
modelData->set_gans2(testItems[5].isChecked());
}
};
writeTwoVals(model.mutable_temppraes(), 0);
writeTwoVals(model.mutable_svke1(), 1);
2019-01-31 19:14:38 +00:00
}
2019-10-05 14:14:45 +00:00
void TPrModel::read(const ESGRAF48::V2SvkModel& model)
2019-01-31 19:14:38 +00:00
{
2019-10-05 14:14:45 +00:00
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
2019-01-31 19:14:38 +00:00
2019-10-05 14:14:45 +00:00
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.schwein1());
testItems[3].setState(modelData.schwein2());
testItems[4].setState(modelData.gans1());
testItems[5].setState(modelData.gans2());
};
2019-01-31 19:14:38 +00:00
2019-10-05 14:14:45 +00:00
readTwoVals(model.temppraes(), 0);
readTwoVals(model.svke1(), 1);
2019-01-31 19:14:38 +00:00
2019-10-05 14:14:45 +00:00
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
2019-01-31 19:14:38 +00:00
}
2019-02-03 18:53:51 +00:00
std::set<int> TPrModel::v2Tests() const
{
2019-10-05 14:14:45 +00:00
return {0};
2019-02-03 18:53:51 +00:00
};
std::set<int> TPrModel::svkTests() const
{
2019-10-05 14:14:45 +00:00
return {1};
2019-02-03 18:53:51 +00:00
};