2018-06-26 14:59:51 +00:00
|
|
|
#include "PassivModel.h"
|
|
|
|
|
|
|
|
PassivModel::PassivModel(QObject *parent)
|
2018-11-18 20:29:43 +00:00
|
|
|
: CheckableTestModel(parent)
|
2018-06-26 14:59:51 +00:00
|
|
|
{
|
2018-11-18 20:29:43 +00:00
|
|
|
m_tests = {{"Passiv",
|
|
|
|
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
|
|
|
|
"Ball (1)", "Ball (2)", "Fleisch (1)", "Fleisch (2)"}}};
|
2018-06-29 17:31:28 +00:00
|
|
|
|
2018-11-18 20:29:43 +00:00
|
|
|
for (auto index : {1, 3, 5, 7, 9})
|
2018-06-29 17:31:28 +00:00
|
|
|
{
|
|
|
|
m_tests[0].items()[index].setValue(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:29:43 +00:00
|
|
|
bool PassivModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
|
2018-06-29 17:31:28 +00:00
|
|
|
{
|
|
|
|
if (role == Qt::CheckStateRole && value.toBool() == true)
|
|
|
|
{
|
|
|
|
if (modelIndex.column() % 2 == 0)
|
|
|
|
{
|
2018-11-18 20:29:43 +00:00
|
|
|
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
|
|
|
|
role);
|
2018-06-29 17:31:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-18 20:29:43 +00:00
|
|
|
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
|
|
|
|
role);
|
2018-06-29 17:31:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CheckableTestModel::setData(modelIndex, value, role);
|
2018-06-26 14:59:51 +00:00
|
|
|
}
|
2018-11-18 20:29:43 +00:00
|
|
|
|
|
|
|
void PassivModel::read(const ESGRAF48::LateSkillsPassivModel &model)
|
|
|
|
{
|
|
|
|
auto &testItems = m_tests.at(0).items();
|
|
|
|
|
|
|
|
testItems[0].setState(model.elefant1());
|
|
|
|
testItems[1].setState(model.elefant2());
|
|
|
|
testItems[2].setState(model.pferde1());
|
|
|
|
testItems[3].setState(model.pferde2());
|
|
|
|
testItems[4].setState(model.baelle1());
|
|
|
|
testItems[5].setState(model.baelle2());
|
|
|
|
testItems[6].setState(model.ball1());
|
|
|
|
testItems[7].setState(model.ball2());
|
|
|
|
testItems[8].setState(model.fleisch1());
|
|
|
|
testItems[9].setState(model.fleisch2());
|
|
|
|
|
|
|
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PassivModel::write(ESGRAF48::LateSkillsPassivModel &model) const
|
|
|
|
{
|
|
|
|
const auto &testItems = m_tests.at(0).items();
|
|
|
|
|
|
|
|
model.set_elefant1(testItems[0].isChecked());
|
|
|
|
model.set_elefant2(testItems[1].isChecked());
|
|
|
|
model.set_pferde1(testItems[2].isChecked());
|
|
|
|
model.set_pferde2(testItems[3].isChecked());
|
|
|
|
model.set_baelle1(testItems[4].isChecked());
|
|
|
|
model.set_baelle2(testItems[5].isChecked());
|
|
|
|
model.set_ball1(testItems[6].isChecked());
|
|
|
|
model.set_ball2(testItems[7].isChecked());
|
|
|
|
model.set_fleisch1(testItems[8].isChecked());
|
|
|
|
model.set_fleisch2(testItems[9].isChecked());
|
|
|
|
}
|