From a09e9a53514dba640728ead4547c10374798bc22 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 30 Jan 2019 23:07:11 +0100 Subject: [PATCH 1/3] Split subtest 1 into four widgets, extracted TPeModel --- source/DataModel.cpp | 8 ++- source/DataModel.h | 4 ++ source/SubTests/V2Svk/CMakeLists.txt | 1 + source/SubTests/V2Svk/TPeModel.cpp | 95 +++++++++++++++++++++++++++ source/SubTests/V2Svk/TPeModel.h | 18 +++++ source/SubTests/V2Svk/V2SvkModel.cpp | 21 +----- source/SubTests/V2Svk/V2SvkWidget.cpp | 11 +++- source/SubTests/V2Svk/V2SvkWidget.h | 2 + source/SubTests/V2Svk/V2SvkWidget.ui | 11 +++- source/mainwindow.cpp | 1 + 10 files changed, 148 insertions(+), 24 deletions(-) create mode 100644 source/SubTests/V2Svk/TPeModel.cpp create mode 100644 source/SubTests/V2Svk/TPeModel.h diff --git a/source/DataModel.cpp b/source/DataModel.cpp index 0b94963..6f4dee1 100644 --- a/source/DataModel.cpp +++ b/source/DataModel.cpp @@ -15,6 +15,7 @@ DataModel::DataModel(QObject *parent) , m_akkusativ(this) , m_dativ(this) , m_v2Svk(this) + , m_tPeModel(this) , m_passiv(this) , m_genitiv(this) { @@ -25,6 +26,7 @@ DataModel::DataModel(QObject *parent) connect(&m_akkusativ, &AkkusativModel::dataChanged, this, &DataModel::akkusativModelChanged); connect(&m_dativ, &DativModel::dataChanged, this, &DataModel::dativModelChanged); connect(&m_v2Svk, &V2SvkModel::dataChanged, this, &DataModel::v2SvkModelChanged); + connect(&m_tPeModel, &TPeModel::dataChanged, this, &DataModel::v2SvkModelChanged); connect(&m_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged); connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged); } @@ -35,6 +37,7 @@ void DataModel::write(const QString &filename) const m_metaData.write(*dataModel.mutable_metadata()); m_v2Svk.write(*dataModel.mutable_v2svk()); + m_tPeModel.write(*dataModel.mutable_v2svk()); m_verbEnd.write(*dataModel.mutable_verbend()); m_genus.write(*dataModel.mutable_genus()); m_akkusativ.write(*dataModel.mutable_akkusativ()); @@ -73,6 +76,7 @@ void DataModel::read(const QString &filename) m_metaData.read(dataModel.metadata()); m_v2Svk.read(dataModel.v2svk()); + m_tPeModel.read(dataModel.v2svk()); m_verbEnd.read(dataModel.verbend()); m_genus.read(dataModel.genus()); m_akkusativ.read(dataModel.akkusativ()); @@ -149,8 +153,8 @@ void DataModel::dativModelChanged() void DataModel::v2SvkModelChanged() { - m_results.setV2Result(m_v2Svk.getV2Points()); - m_results.setSvkResult(m_v2Svk.getSvkPoints()); + m_results.setV2Result(m_v2Svk.getV2Points() + m_tPeModel.getV2Points()); + m_results.setSvkResult(m_v2Svk.getSvkPoints() + m_tPeModel.getSvkPoints()); emit modelChanged(); } diff --git a/source/DataModel.h b/source/DataModel.h index 42b5294..61037a3 100644 --- a/source/DataModel.h +++ b/source/DataModel.h @@ -7,6 +7,7 @@ #include "AkkusativModel.h" #include "DativModel.h" #include "V2SvkModel.h" +#include "TPeModel.h" #include "PassivModel.h" #include "GenitivModel.h" @@ -25,7 +26,10 @@ public: PluralModel m_plural; AkkusativModel m_akkusativ; DativModel m_dativ; + V2SvkModel m_v2Svk; + TPeModel m_tPeModel; + PassivModel m_passiv; GenitivModel m_genitiv; diff --git a/source/SubTests/V2Svk/CMakeLists.txt b/source/SubTests/V2Svk/CMakeLists.txt index caf6c8c..0269a26 100644 --- a/source/SubTests/V2Svk/CMakeLists.txt +++ b/source/SubTests/V2Svk/CMakeLists.txt @@ -20,6 +20,7 @@ protobuf_generate_cpp(V2Svk_PROTO_SRCS V2Svk_PROTO_HDRS ${V2Svk_PROTO_FILES}) add_library(${PROJECT_NAME} V2SvkWidget.cpp V2SvkModel.cpp + TPeModel.cpp ${UI_HEADERS} ${V2Svk_PROTO_SRCS} ${V2Svk_PROTO_HDRS} diff --git a/source/SubTests/V2Svk/TPeModel.cpp b/source/SubTests/V2Svk/TPeModel.cpp new file mode 100644 index 0000000..2c17da3 --- /dev/null +++ b/source/SubTests/V2Svk/TPeModel.cpp @@ -0,0 +1,95 @@ +#include "TPeModel.h" + +TPeModel::TPeModel(QObject *parent) + : CheckableTestModel(parent) +{ + m_tests = { + {"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + {"Verbtrennung", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + {"SVK: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + {"Partizip", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + }; +} + +unsigned int TPeModel::getV2Points() +{ + unsigned int points = 0; + + for (auto testIndex : {0, 1}) + { + const auto &test = m_tests.at(testIndex); + + for (const auto &item : test.items()) + { + if (item.isChecked()) + { + points++; + } + } + } + + return points; +} + +unsigned int TPeModel::getSvkPoints() +{ + unsigned int points = 0; + + for (auto testIndex : {2, 3}) + { + const auto &test = m_tests.at(testIndex); + + for (const auto &item : test.items()) + { + if (item.isChecked()) + { + points++; + } + } + } + + return points; +} + +void TPeModel::write(ESGRAF48::V2SvkModel &model) const +{ + 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_tempperf(), 0); + writeTwoVals(model.mutable_verbtrennung2(), 1); + writeTwoVals(model.mutable_svke2(), 2); + writeTwoVals(model.mutable_partizip(), 3); +} + +void TPeModel::read(const ESGRAF48::V2SvkModel &model) +{ + auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) { + auto &testItems = m_tests.at(testIndex).items(); + + 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()); + }; + + readTwoVals(model.tempperf(), 0); + readTwoVals(model.verbtrennung2(), 1); + readTwoVals(model.svke2(), 2); + readTwoVals(model.partizip(), 3); + + emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); +} diff --git a/source/SubTests/V2Svk/TPeModel.h b/source/SubTests/V2Svk/TPeModel.h new file mode 100644 index 0000000..19a1c12 --- /dev/null +++ b/source/SubTests/V2Svk/TPeModel.h @@ -0,0 +1,18 @@ +#pragma once + +#include "CheckableTestModel.h" +#include "V2SvkModel.pb.h" + +class TPeModel : public CheckableTestModel +{ + Q_OBJECT + +public: + TPeModel(QObject *parent); + + unsigned int getV2Points(); + unsigned int getSvkPoints(); + + void write(ESGRAF48::V2SvkModel &model) const; + void read(const ESGRAF48::V2SvkModel &model); +}; diff --git a/source/SubTests/V2Svk/V2SvkModel.cpp b/source/SubTests/V2Svk/V2SvkModel.cpp index 2196ba4..716f1d4 100644 --- a/source/SubTests/V2Svk/V2SvkModel.cpp +++ b/source/SubTests/V2Svk/V2SvkModel.cpp @@ -21,11 +21,6 @@ V2SvkModel::V2SvkModel(QObject *parent) {"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, {"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, - - {"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, - {"Verbtrennung", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, - {"SVK: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, - {"Partizip", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, }; } @@ -33,7 +28,7 @@ unsigned int V2SvkModel::getV2Points() { unsigned int points = 0; - for (auto testIndex : {0, 1, 3, 5, 7, 8}) + for (auto testIndex : {0, 1, 3, 5}) { const auto &test = m_tests.at(testIndex); @@ -53,7 +48,7 @@ unsigned int V2SvkModel::getSvkPoints() { unsigned int points = 0; - for (auto testIndex : {2, 4, 6, 9, 10}) + for (auto testIndex : {2, 4, 6}) { const auto &test = m_tests.at(testIndex); @@ -77,10 +72,6 @@ bool V2SvkModel::isValidIndex(const QModelIndex &index) const return index.column() == 1 || index.column() == 7 || index.column() == 10; case 5: case 6: - case 7: - case 8: - case 9: - case 10: return index.column() < 6; default: return CheckableTestModel::isValidIndex(index); @@ -141,10 +132,6 @@ void V2SvkModel::write(ESGRAF48::V2SvkModel &model) const writeFourVals(model.mutable_svkstamm(), 4); writeTwoVals(model.mutable_temppraes(), 5); writeTwoVals(model.mutable_svke1(), 6); - writeTwoVals(model.mutable_tempperf(), 7); - writeTwoVals(model.mutable_verbtrennung2(), 8); - writeTwoVals(model.mutable_svke2(), 9); - writeTwoVals(model.mutable_partizip(), 10); } void V2SvkModel::read(const ESGRAF48::V2SvkModel &model) @@ -192,10 +179,6 @@ void V2SvkModel::read(const ESGRAF48::V2SvkModel &model) readFourVals(model.svkstamm(), 4); readTwoVals(model.temppraes(), 5); readTwoVals(model.svke1(), 6); - readTwoVals(model.tempperf(), 7); - readTwoVals(model.verbtrennung2(), 8); - readTwoVals(model.svke2(), 9); - readTwoVals(model.partizip(), 10); emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); } diff --git a/source/SubTests/V2Svk/V2SvkWidget.cpp b/source/SubTests/V2Svk/V2SvkWidget.cpp index d6fe544..10d79b4 100644 --- a/source/SubTests/V2Svk/V2SvkWidget.cpp +++ b/source/SubTests/V2Svk/V2SvkWidget.cpp @@ -2,13 +2,15 @@ #include "ui_V2SvkWidget.h" #include "V2SvkModel.h" +#include "TPeModel.h" V2SvkWidget::V2SvkWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::V2SvkWidget) { ui->setupUi(this); - ui->v2SvkTableView->horizontalHeader()->hide(); + ui->wfTableView->horizontalHeader()->hide(); + ui->tpeTableView->horizontalHeader()->hide(); } V2SvkWidget::~V2SvkWidget() @@ -18,5 +20,10 @@ V2SvkWidget::~V2SvkWidget() void V2SvkWidget::setV2SvkModel(V2SvkModel *model) { - ui->v2SvkTableView->setModel(model); + ui->wfTableView->setModel(model); +} + +void V2SvkWidget::setTPeModel(TPeModel *model) +{ + ui->tpeTableView->setModel(model); } diff --git a/source/SubTests/V2Svk/V2SvkWidget.h b/source/SubTests/V2Svk/V2SvkWidget.h index e23cac5..6256e77 100644 --- a/source/SubTests/V2Svk/V2SvkWidget.h +++ b/source/SubTests/V2Svk/V2SvkWidget.h @@ -3,6 +3,7 @@ #include class V2SvkModel; +class TPeModel; namespace Ui { class V2SvkWidget; @@ -20,4 +21,5 @@ public: ~V2SvkWidget(); void setV2SvkModel(V2SvkModel *model); + void setTPeModel(TPeModel *model); }; diff --git a/source/SubTests/V2Svk/V2SvkWidget.ui b/source/SubTests/V2Svk/V2SvkWidget.ui index 73ee028..83a3b71 100644 --- a/source/SubTests/V2Svk/V2SvkWidget.ui +++ b/source/SubTests/V2Svk/V2SvkWidget.ui @@ -15,7 +15,16 @@ - + + + + + + + + + + diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index d5f425a..cadf73e 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -49,6 +49,7 @@ void MainWindow::setupUi() ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ); ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ); ui->v2SvkWidget->setV2SvkModel(&m_dataModel.m_v2Svk); + ui->v2SvkWidget->setTPeModel(&m_dataModel.m_tPeModel); ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv); ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv); ui->resultWidget->setModel(&m_dataModel.m_results); From 8678fdb2075aa7a13d8b9bdf85ca83c42c3edfd1 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 31 Jan 2019 20:14:38 +0100 Subject: [PATCH 2/3] Split subtest 1 in four blocks --- source/DataModel.cpp | 30 +++-- source/DataModel.h | 10 +- source/SubTests/V2Svk/CMakeLists.txt | 4 +- source/SubTests/V2Svk/OTModel.cpp | 105 ++++++++++++++++++ source/SubTests/V2Svk/OTModel.h | 18 +++ source/SubTests/V2Svk/TPrModel.cpp | 89 +++++++++++++++ source/SubTests/V2Svk/TPrModel.h | 18 +++ source/SubTests/V2Svk/V2SvkWidget.cpp | 26 ++++- source/SubTests/V2Svk/V2SvkWidget.h | 8 +- .../V2Svk/{V2SvkModel.cpp => WFModel.cpp} | 75 +++---------- .../V2Svk/{V2SvkModel.h => WFModel.h} | 7 +- source/mainwindow.cpp | 6 +- 12 files changed, 311 insertions(+), 85 deletions(-) create mode 100644 source/SubTests/V2Svk/OTModel.cpp create mode 100644 source/SubTests/V2Svk/OTModel.h create mode 100644 source/SubTests/V2Svk/TPrModel.cpp create mode 100644 source/SubTests/V2Svk/TPrModel.h rename source/SubTests/V2Svk/{V2SvkModel.cpp => WFModel.cpp} (57%) rename source/SubTests/V2Svk/{V2SvkModel.h => WFModel.h} (63%) diff --git a/source/DataModel.cpp b/source/DataModel.cpp index 6f4dee1..ab61bed 100644 --- a/source/DataModel.cpp +++ b/source/DataModel.cpp @@ -14,8 +14,10 @@ DataModel::DataModel(QObject *parent) , m_results(this) , m_akkusativ(this) , m_dativ(this) - , m_v2Svk(this) - , m_tPeModel(this) + , m_wfModel(this) + , m_otModel(this) + , m_tPrModel(this) + , m_tPeModel(this) , m_passiv(this) , m_genitiv(this) { @@ -25,8 +27,12 @@ DataModel::DataModel(QObject *parent) connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged); connect(&m_akkusativ, &AkkusativModel::dataChanged, this, &DataModel::akkusativModelChanged); connect(&m_dativ, &DativModel::dataChanged, this, &DataModel::dativModelChanged); - connect(&m_v2Svk, &V2SvkModel::dataChanged, this, &DataModel::v2SvkModelChanged); + + connect(&m_wfModel, &WFModel::dataChanged, this, &DataModel::v2SvkModelChanged); + connect(&m_otModel, &OTModel::dataChanged, this, &DataModel::v2SvkModelChanged); + connect(&m_tPrModel, &TPrModel::dataChanged, this, &DataModel::v2SvkModelChanged); connect(&m_tPeModel, &TPeModel::dataChanged, this, &DataModel::v2SvkModelChanged); + connect(&m_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged); connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged); } @@ -36,8 +42,12 @@ void DataModel::write(const QString &filename) const ESGRAF48::DataModel dataModel; m_metaData.write(*dataModel.mutable_metadata()); - m_v2Svk.write(*dataModel.mutable_v2svk()); + + m_wfModel.write(*dataModel.mutable_v2svk()); + m_otModel.write(*dataModel.mutable_v2svk()); + m_tPrModel.write(*dataModel.mutable_v2svk()); m_tPeModel.write(*dataModel.mutable_v2svk()); + m_verbEnd.write(*dataModel.mutable_verbend()); m_genus.write(*dataModel.mutable_genus()); m_akkusativ.write(*dataModel.mutable_akkusativ()); @@ -75,8 +85,12 @@ void DataModel::read(const QString &filename) } m_metaData.read(dataModel.metadata()); - m_v2Svk.read(dataModel.v2svk()); + + m_wfModel.read(dataModel.v2svk()); + m_otModel.read(dataModel.v2svk()); + m_tPrModel.read(dataModel.v2svk()); m_tPeModel.read(dataModel.v2svk()); + m_verbEnd.read(dataModel.verbend()); m_genus.read(dataModel.genus()); m_akkusativ.read(dataModel.akkusativ()); @@ -153,8 +167,10 @@ void DataModel::dativModelChanged() void DataModel::v2SvkModelChanged() { - m_results.setV2Result(m_v2Svk.getV2Points() + m_tPeModel.getV2Points()); - m_results.setSvkResult(m_v2Svk.getSvkPoints() + m_tPeModel.getSvkPoints()); + m_results.setV2Result(m_wfModel.getV2Points() + m_otModel.getV2Points() + + m_tPrModel.getV2Points() + m_tPeModel.getV2Points()); + m_results.setSvkResult(m_wfModel.getSvkPoints() + m_otModel.getSvkPoints() + + m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints()); emit modelChanged(); } diff --git a/source/DataModel.h b/source/DataModel.h index 61037a3..307a93b 100644 --- a/source/DataModel.h +++ b/source/DataModel.h @@ -6,8 +6,12 @@ #include "PluralModel.h" #include "AkkusativModel.h" #include "DativModel.h" -#include "V2SvkModel.h" + +#include "WFModel.h" +#include "OTModel.h" +#include "TPrModel.h" #include "TPeModel.h" + #include "PassivModel.h" #include "GenitivModel.h" @@ -27,7 +31,9 @@ public: AkkusativModel m_akkusativ; DativModel m_dativ; - V2SvkModel m_v2Svk; + WFModel m_wfModel; + OTModel m_otModel; + TPrModel m_tPrModel; TPeModel m_tPeModel; PassivModel m_passiv; diff --git a/source/SubTests/V2Svk/CMakeLists.txt b/source/SubTests/V2Svk/CMakeLists.txt index 0269a26..441c569 100644 --- a/source/SubTests/V2Svk/CMakeLists.txt +++ b/source/SubTests/V2Svk/CMakeLists.txt @@ -19,7 +19,9 @@ protobuf_generate_cpp(V2Svk_PROTO_SRCS V2Svk_PROTO_HDRS ${V2Svk_PROTO_FILES}) add_library(${PROJECT_NAME} V2SvkWidget.cpp - V2SvkModel.cpp + WFModel.cpp + OTModel.cpp + TPrModel.cpp TPeModel.cpp ${UI_HEADERS} ${V2Svk_PROTO_SRCS} diff --git a/source/SubTests/V2Svk/OTModel.cpp b/source/SubTests/V2Svk/OTModel.cpp new file mode 100644 index 0000000..1c0f477 --- /dev/null +++ b/source/SubTests/V2Svk/OTModel.cpp @@ -0,0 +1,105 @@ +#include "OTModel.h" + +OTModel::OTModel(QObject *parent) + : CheckableTestModel(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() +{ + 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() +{ + 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)); +} diff --git a/source/SubTests/V2Svk/OTModel.h b/source/SubTests/V2Svk/OTModel.h new file mode 100644 index 0000000..d4b5a49 --- /dev/null +++ b/source/SubTests/V2Svk/OTModel.h @@ -0,0 +1,18 @@ +#pragma once + +#include "CheckableTestModel.h" +#include "V2SvkModel.pb.h" + +class OTModel : public CheckableTestModel +{ + Q_OBJECT + +public: + OTModel(QObject *parent); + + unsigned int getV2Points(); + unsigned int getSvkPoints(); + + void write(ESGRAF48::V2SvkModel &model) const; + void read(const ESGRAF48::V2SvkModel &model); +}; diff --git a/source/SubTests/V2Svk/TPrModel.cpp b/source/SubTests/V2Svk/TPrModel.cpp new file mode 100644 index 0000000..fcf9c01 --- /dev/null +++ b/source/SubTests/V2Svk/TPrModel.cpp @@ -0,0 +1,89 @@ +#include "TPrModel.h" + +TPrModel::TPrModel(QObject *parent) + : CheckableTestModel(parent) +{ + m_tests = { + {"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + {"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, + }; +} + +unsigned int TPrModel::getV2Points() +{ + 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 TPrModel::getSvkPoints() +{ + 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 TPrModel::write(ESGRAF48::V2SvkModel &model) const +{ + 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); +} + +void TPrModel::read(const ESGRAF48::V2SvkModel &model) +{ + auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) { + auto &testItems = m_tests.at(testIndex).items(); + + 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()); + }; + + readTwoVals(model.temppraes(), 0); + readTwoVals(model.svke1(), 1); + + emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); +} diff --git a/source/SubTests/V2Svk/TPrModel.h b/source/SubTests/V2Svk/TPrModel.h new file mode 100644 index 0000000..257a576 --- /dev/null +++ b/source/SubTests/V2Svk/TPrModel.h @@ -0,0 +1,18 @@ +#pragma once + +#include "CheckableTestModel.h" +#include "V2SvkModel.pb.h" + +class TPrModel : public CheckableTestModel +{ + Q_OBJECT + +public: + TPrModel(QObject *parent); + + unsigned int getV2Points(); + unsigned int getSvkPoints(); + + void write(ESGRAF48::V2SvkModel &model) const; + void read(const ESGRAF48::V2SvkModel &model); +}; diff --git a/source/SubTests/V2Svk/V2SvkWidget.cpp b/source/SubTests/V2Svk/V2SvkWidget.cpp index 10d79b4..f8974dc 100644 --- a/source/SubTests/V2Svk/V2SvkWidget.cpp +++ b/source/SubTests/V2Svk/V2SvkWidget.cpp @@ -1,15 +1,19 @@ #include "V2SvkWidget.h" #include "ui_V2SvkWidget.h" -#include "V2SvkModel.h" +#include "WFModel.h" +#include "OTModel.h" +#include "TPrModel.h" #include "TPeModel.h" V2SvkWidget::V2SvkWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::V2SvkWidget) + : QWidget(parent) + , ui(new Ui::V2SvkWidget) { ui->setupUi(this); - ui->wfTableView->horizontalHeader()->hide(); + ui->wfTableView->horizontalHeader()->hide(); + ui->otTableView->horizontalHeader()->hide(); + ui->tprTableView->horizontalHeader()->hide(); ui->tpeTableView->horizontalHeader()->hide(); } @@ -18,11 +22,21 @@ V2SvkWidget::~V2SvkWidget() delete ui; } -void V2SvkWidget::setV2SvkModel(V2SvkModel *model) +void V2SvkWidget::setWFModel(WFModel *model) { ui->wfTableView->setModel(model); } - + +void V2SvkWidget::setOTModel(OTModel *model) +{ + ui->otTableView->setModel(model); +} + +void V2SvkWidget::setTPrModel(TPrModel *model) +{ + ui->tprTableView->setModel(model); +} + void V2SvkWidget::setTPeModel(TPeModel *model) { ui->tpeTableView->setModel(model); diff --git a/source/SubTests/V2Svk/V2SvkWidget.h b/source/SubTests/V2Svk/V2SvkWidget.h index 6256e77..82a15c9 100644 --- a/source/SubTests/V2Svk/V2SvkWidget.h +++ b/source/SubTests/V2Svk/V2SvkWidget.h @@ -2,7 +2,9 @@ #include -class V2SvkModel; +class WFModel; +class OTModel; +class TPrModel; class TPeModel; namespace Ui { @@ -20,6 +22,8 @@ public: V2SvkWidget(QWidget *parent = nullptr); ~V2SvkWidget(); - void setV2SvkModel(V2SvkModel *model); + void setWFModel(WFModel *model); + void setOTModel(OTModel *model); + void setTPrModel(TPrModel *model); void setTPeModel(TPeModel *model); }; diff --git a/source/SubTests/V2Svk/V2SvkModel.cpp b/source/SubTests/V2Svk/WFModel.cpp similarity index 57% rename from source/SubTests/V2Svk/V2SvkModel.cpp rename to source/SubTests/V2Svk/WFModel.cpp index 716f1d4..fac9098 100644 --- a/source/SubTests/V2Svk/V2SvkModel.cpp +++ b/source/SubTests/V2Svk/WFModel.cpp @@ -1,6 +1,6 @@ -#include "V2SvkModel.h" +#include "WFModel.h" -V2SvkModel::V2SvkModel(QObject *parent) +WFModel::WFModel(QObject *parent) : CheckableTestModel(parent) { m_tests = { @@ -11,24 +11,14 @@ V2SvkModel::V2SvkModel(QObject *parent) {"SVK: /-st/", {"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans", "Gans", "Gans", "Gans"}}, - - {"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"}}, - - {"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, - {"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}}, }; } -unsigned int V2SvkModel::getV2Points() +unsigned int WFModel::getV2Points() { unsigned int points = 0; - for (auto testIndex : {0, 1, 3, 5}) + for (auto testIndex : {0, 1}) { const auto &test = m_tests.at(testIndex); @@ -44,11 +34,11 @@ unsigned int V2SvkModel::getV2Points() return points; } -unsigned int V2SvkModel::getSvkPoints() +unsigned int WFModel::getSvkPoints() { unsigned int points = 0; - for (auto testIndex : {2, 4, 6}) + for (auto testIndex : {2}) { const auto &test = m_tests.at(testIndex); @@ -64,21 +54,17 @@ unsigned int V2SvkModel::getSvkPoints() return points; } -bool V2SvkModel::isValidIndex(const QModelIndex &index) const +bool WFModel::isValidIndex(const QModelIndex &index) const { - switch (index.row()) + if (index.row() == 1) { - case 1: - return index.column() == 1 || index.column() == 7 || index.column() == 10; - case 5: - case 6: - return index.column() < 6; - default: - return CheckableTestModel::isValidIndex(index); + return index.column() == 1 || index.column() == 7 || index.column() == 10; } + + return CheckableTestModel::isValidIndex(index); } -void V2SvkModel::write(ESGRAF48::V2SvkModel &model) const +void WFModel::write(ESGRAF48::V2SvkModel &model) const { auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) { if (modelData != nullptr) @@ -91,20 +77,6 @@ void V2SvkModel::write(ESGRAF48::V2SvkModel &model) const } }; - 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()); - } - }; - auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach *modelData, int testIndex) { if (modelData != nullptr) { @@ -127,14 +99,9 @@ void V2SvkModel::write(ESGRAF48::V2SvkModel &model) const writeFourVals(model.mutable_wfrage(), 0); writeOneVal(model.mutable_verbtrennung1(), 1); - writeFourVals(model.mutable_svkst(), 2); - writeFourVals(model.mutable_objtop(), 3); - writeFourVals(model.mutable_svkstamm(), 4); - writeTwoVals(model.mutable_temppraes(), 5); - writeTwoVals(model.mutable_svke1(), 6); } -void V2SvkModel::read(const ESGRAF48::V2SvkModel &model) +void WFModel::read(const ESGRAF48::V2SvkModel &model) { auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) { auto &testItems = m_tests.at(testIndex).items(); @@ -144,17 +111,6 @@ void V2SvkModel::read(const ESGRAF48::V2SvkModel &model) testItems[10].setState(modelData.gans()); }; - auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) { - auto &testItems = m_tests.at(testIndex).items(); - - 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()); - }; - auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach &modelData, int testIndex) { auto &testItems = m_tests.at(testIndex).items(); @@ -174,11 +130,6 @@ void V2SvkModel::read(const ESGRAF48::V2SvkModel &model) readFourVals(model.wfrage(), 0); readOneVal(model.verbtrennung1(), 1); - readFourVals(model.svkst(), 2); - readFourVals(model.objtop(), 3); - readFourVals(model.svkstamm(), 4); - readTwoVals(model.temppraes(), 5); - readTwoVals(model.svke1(), 6); emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); } diff --git a/source/SubTests/V2Svk/V2SvkModel.h b/source/SubTests/V2Svk/WFModel.h similarity index 63% rename from source/SubTests/V2Svk/V2SvkModel.h rename to source/SubTests/V2Svk/WFModel.h index 519508a..647765a 100644 --- a/source/SubTests/V2Svk/V2SvkModel.h +++ b/source/SubTests/V2Svk/WFModel.h @@ -3,12 +3,12 @@ #include "CheckableTestModel.h" #include "V2SvkModel.pb.h" -class V2SvkModel : public CheckableTestModel +class WFModel : public CheckableTestModel { Q_OBJECT public: - V2SvkModel(QObject *parent); + WFModel(QObject *parent); unsigned int getV2Points(); unsigned int getSvkPoints(); @@ -16,6 +16,5 @@ public: void write(ESGRAF48::V2SvkModel &model) const; void read(const ESGRAF48::V2SvkModel &model); -protected: - bool isValidIndex(const QModelIndex &index) const override; + bool isValidIndex(const QModelIndex &index) const; }; diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index cadf73e..9d90d06 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -48,8 +48,12 @@ void MainWindow::setupUi() ui->pluralWidget->setModel(&m_dataModel.m_plural); ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ); ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ); - ui->v2SvkWidget->setV2SvkModel(&m_dataModel.m_v2Svk); + + ui->v2SvkWidget->setWFModel(&m_dataModel.m_wfModel); + ui->v2SvkWidget->setOTModel(&m_dataModel.m_otModel); + ui->v2SvkWidget->setTPrModel(&m_dataModel.m_tPrModel); ui->v2SvkWidget->setTPeModel(&m_dataModel.m_tPeModel); + ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv); ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv); ui->resultWidget->setModel(&m_dataModel.m_results); From af6316d3a21b78690988b1126599e3df37122b79 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 31 Jan 2019 20:23:08 +0100 Subject: [PATCH 3/3] Bumped version number --- source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 24df849..6c4f314 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6) -set(BUILD_VERSION_MAJOR_MINOR 0.2) +set(BUILD_VERSION_MAJOR_MINOR 0.3) if ($ENV{BUILD_NUMBER}) set(BUILD_VERSION_PATCH $ENV{BUILD_NUMBER})