2018-05-22 03:55:46 +00:00
|
|
|
#include "GenusModel.h"
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
GenusModel::GenusModel(QObject* parent)
|
2019-02-03 18:53:51 +00:00
|
|
|
: PrintableModel(parent)
|
2018-05-22 08:57:25 +00:00
|
|
|
{
|
2019-10-05 14:14:45 +00:00
|
|
|
m_title = "Subtest 3: Genus";
|
2019-02-03 18:53:51 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
m_tests = {{"Tiere", {"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Affe", "Hund"}},
|
|
|
|
{"Futter",
|
|
|
|
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}},
|
|
|
|
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
|
2018-11-18 14:27:00 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
void GenusModel::read(const ESGRAF48::GenusModel& model)
|
2018-11-18 14:27:00 +00:00
|
|
|
{
|
2019-10-05 14:14:45 +00:00
|
|
|
const auto& tiereModel = model.tiere();
|
|
|
|
{
|
|
|
|
auto& testItems = m_tests.at(0).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
testItems[0].setState(tiereModel.tiger());
|
|
|
|
testItems[1].setState(tiereModel.baer());
|
|
|
|
testItems[2].setState(tiereModel.katze());
|
|
|
|
testItems[3].setState(tiereModel.pferd());
|
|
|
|
testItems[4].setState(tiereModel.gans());
|
|
|
|
testItems[5].setState(tiereModel.elefant());
|
|
|
|
testItems[6].setState(tiereModel.affe());
|
|
|
|
testItems[7].setState(tiereModel.hund());
|
|
|
|
}
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
const auto& futterModel = model.futter();
|
|
|
|
{
|
|
|
|
auto& testItems = m_tests.at(1).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
testItems[0].setState(futterModel.salat());
|
|
|
|
testItems[1].setState(futterModel.fleisch());
|
|
|
|
testItems[2].setState(futterModel.knochen());
|
|
|
|
testItems[3].setState(futterModel.banane());
|
|
|
|
testItems[4].setState(futterModel.apfel());
|
|
|
|
testItems[5].setState(futterModel.karotte());
|
|
|
|
testItems[6].setState(futterModel.honig());
|
|
|
|
testItems[7].setState(futterModel.zucker());
|
|
|
|
}
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
const auto& zirkusModel = model.zirkus();
|
|
|
|
{
|
|
|
|
auto& testItems = m_tests.at(2).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
testItems[0].setState(zirkusModel.kiste());
|
|
|
|
testItems[1].setState(zirkusModel.holz());
|
|
|
|
testItems[2].setState(zirkusModel.vorhang());
|
|
|
|
testItems[3].setState(zirkusModel.baum());
|
|
|
|
}
|
2018-11-18 20:29:43 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
2018-11-18 14:27:00 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
void GenusModel::write(ESGRAF48::GenusModel& model) const
|
2018-11-18 14:27:00 +00:00
|
|
|
{
|
2019-10-05 14:14:45 +00:00
|
|
|
auto* tiereModel = model.mutable_tiere();
|
|
|
|
if (tiereModel != nullptr)
|
|
|
|
{
|
|
|
|
const auto& testItems = m_tests.at(0).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
tiereModel->set_tiger(testItems[0].isChecked());
|
|
|
|
tiereModel->set_baer(testItems[1].isChecked());
|
|
|
|
tiereModel->set_katze(testItems[2].isChecked());
|
|
|
|
tiereModel->set_pferd(testItems[3].isChecked());
|
|
|
|
tiereModel->set_gans(testItems[4].isChecked());
|
|
|
|
tiereModel->set_elefant(testItems[5].isChecked());
|
|
|
|
tiereModel->set_affe(testItems[6].isChecked());
|
|
|
|
tiereModel->set_hund(testItems[7].isChecked());
|
|
|
|
}
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
auto* futterModel = model.mutable_futter();
|
|
|
|
if (futterModel != nullptr)
|
|
|
|
{
|
|
|
|
const auto& testItems = m_tests.at(1).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
futterModel->set_salat(testItems[0].isChecked());
|
|
|
|
futterModel->set_fleisch(testItems[1].isChecked());
|
|
|
|
futterModel->set_knochen(testItems[2].isChecked());
|
|
|
|
futterModel->set_banane(testItems[3].isChecked());
|
|
|
|
futterModel->set_apfel(testItems[4].isChecked());
|
|
|
|
futterModel->set_karotte(testItems[5].isChecked());
|
|
|
|
futterModel->set_honig(testItems[6].isChecked());
|
|
|
|
futterModel->set_zucker(testItems[7].isChecked());
|
|
|
|
}
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
auto* zirkusModel = model.mutable_zirkus();
|
|
|
|
if (zirkusModel != nullptr)
|
|
|
|
{
|
|
|
|
const auto& testItems = m_tests.at(2).items();
|
2018-11-18 14:27:00 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
zirkusModel->set_kiste(testItems[0].isChecked());
|
|
|
|
zirkusModel->set_holz(testItems[1].isChecked());
|
|
|
|
zirkusModel->set_vorhang(testItems[2].isChecked());
|
|
|
|
zirkusModel->set_baum(testItems[3].isChecked());
|
|
|
|
}
|
2018-05-22 08:57:25 +00:00
|
|
|
}
|