From 00a4d37ec301e6aa75b718d6179fcd8443be638a Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sat, 30 Jun 2018 10:05:49 +0200 Subject: [PATCH] implemented exclusive checking in GenitivModel --- source/SubTests/LateSkills/GenitivModel.cpp | 41 +++++++++++++++++++-- source/SubTests/LateSkills/GenitivModel.h | 4 +- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/SubTests/LateSkills/GenitivModel.cpp b/source/SubTests/LateSkills/GenitivModel.cpp index 59c9e2c..af69325 100644 --- a/source/SubTests/LateSkills/GenitivModel.cpp +++ b/source/SubTests/LateSkills/GenitivModel.cpp @@ -4,7 +4,42 @@ GenitivModel::GenitivModel(QObject *parent) : CheckableTestModel(parent) { m_tests = { - { "Genitiv Präpositionen", { "anstelle", "außerhalb", "mithilfe" } }, - { "Attributierung", { "Schuhe", "Zauberstab", "Hut", "Brille", "Gürtel" } }, - }; + { "Genitiv Präpositionen", + { "anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)", + "mithilfe (1)", "mithilfe (2)" } }, + { "Attributierung", + { "Schuhe (1)", "Schuhe (2)", "Zauberstab (1)", "Zauberstab (2)", + "Hut (1)", "Hut (2)", "Brille (1)", "Brille (2)", "Gürtel (1)", + "Gürtel (2)" } }, + }; + + for (auto index : { 1, 3, 5 }) + { + m_tests[0].items()[index].setValue(2); + } + + for (auto index : { 1, 3, 5, 7, 9 }) + { + m_tests[1].items()[index].setValue(2); + } +} + +bool GenitivModel::setData( + const QModelIndex &modelIndex, const QVariant &value, int role) +{ + if (role == Qt::CheckStateRole && value.toBool() == true) + { + if (modelIndex.column() % 2 == 0) + { + CheckableTestModel::setData( + index(modelIndex.row(), modelIndex.column() + 1), false, role); + } + else + { + CheckableTestModel::setData( + index(modelIndex.row(), modelIndex.column() - 1), false, role); + } + } + + return CheckableTestModel::setData(modelIndex, value, role); } diff --git a/source/SubTests/LateSkills/GenitivModel.h b/source/SubTests/LateSkills/GenitivModel.h index 722135f..4f6687a 100644 --- a/source/SubTests/LateSkills/GenitivModel.h +++ b/source/SubTests/LateSkills/GenitivModel.h @@ -7,5 +7,7 @@ class GenitivModel : public CheckableTestModel Q_OBJECT public: - GenitivModel(QObject *parent); + GenitivModel(QObject *parent); + bool setData(const QModelIndex &index, const QVariant &value, + int role = Qt::EditRole) override; };