ESGRAF48/source/SubTests/V2Svk/OTModel.cpp

116 lines
3.3 KiB
C++

#include "OTModel.h"
OTModel::OTModel(QObject* parent)
: V2SvkModel(parent)
{
m_tests = {
{"Objekt-Topikalisierung",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
{"SVK: Stamm",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
};
}
unsigned int OTModel::getV2Points() const
{
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;
}
unsigned int OTModel::getSvkPoints() const
{
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;
}
void OTModel::write(ESGRAF48::V2SvkModel& model) const
{
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach* 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_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
writeFourVals(model.mutable_objtop(), 0);
writeFourVals(model.mutable_svkstamm(), 1);
}
void OTModel::read(const ESGRAF48::V2SvkModel& model)
{
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
readFourVals(model.objtop(), 0);
readFourVals(model.svkstamm(), 1);
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> OTModel::v2Tests() const
{
return {0};
};
std::set<int> OTModel::svkTests() const
{
return {1};
};