From 0a1eea0fe25fdbf78bd338cd4a2e639789ffa932 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 26 Jun 2018 16:59:51 +0200 Subject: [PATCH] added late skills test --- source/CMakeLists.txt | 1 + source/DataModel.cpp | 20 ++++++++++ source/DataModel.h | 6 +++ source/ResultWidget/GenitivPR.h | 39 +++++++++++++++++++ source/ResultWidget/PassivPR.h | 32 +++++++++++++++ source/ResultWidget/ResultModel.cpp | 22 +++++++++++ source/ResultWidget/ResultModel.h | 2 + source/SubTests/CMakeLists.txt | 1 + source/SubTests/LateSkills/CMakeLists.txt | 37 ++++++++++++++++++ source/SubTests/LateSkills/GenitivModel.cpp | 10 +++++ source/SubTests/LateSkills/GenitivModel.h | 11 ++++++ .../SubTests/LateSkills/LateSkillsWidget.cpp | 29 ++++++++++++++ source/SubTests/LateSkills/LateSkillsWidget.h | 25 ++++++++++++ .../SubTests/LateSkills/LateSkillsWidget.ui | 27 +++++++++++++ source/SubTests/LateSkills/PassivModel.cpp | 9 +++++ source/SubTests/LateSkills/PassivModel.h | 11 ++++++ source/mainwindow.cpp | 2 + source/mainwindow.ui | 22 +++++++++-- 18 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 source/ResultWidget/GenitivPR.h create mode 100644 source/ResultWidget/PassivPR.h create mode 100644 source/SubTests/LateSkills/CMakeLists.txt create mode 100644 source/SubTests/LateSkills/GenitivModel.cpp create mode 100644 source/SubTests/LateSkills/GenitivModel.h create mode 100644 source/SubTests/LateSkills/LateSkillsWidget.cpp create mode 100644 source/SubTests/LateSkills/LateSkillsWidget.h create mode 100644 source/SubTests/LateSkills/LateSkillsWidget.ui create mode 100644 source/SubTests/LateSkills/PassivModel.cpp create mode 100644 source/SubTests/LateSkills/PassivModel.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 57ed466..3a1cf2a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -45,6 +45,7 @@ target_link_libraries(${PROJECT_NAME} Genus AkkusativDativ V2Svk + LateSkills ResultWidget Qt5::Widgets ) diff --git a/source/DataModel.cpp b/source/DataModel.cpp index 6c19b25..6eb8554 100644 --- a/source/DataModel.cpp +++ b/source/DataModel.cpp @@ -12,6 +12,8 @@ DataModel::DataModel(QObject *parent) , m_akkusativ(this) , m_dativ(this) , m_v2Svk(this) + , m_passiv(this) + , m_genitiv(this) { connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged); @@ -27,6 +29,10 @@ DataModel::DataModel(QObject *parent) &DataModel::dativModelChanged); connect(&m_v2Svk, &V2SvkModel::dataChanged, this, &DataModel::v2SvkModelChanged); + connect(&m_passiv, &PassivModel::dataChanged, this, + &DataModel::passivModelChanged); + connect(&m_genitiv, &GenitivModel::dataChanged, this, + &DataModel::genitivModelChanged); } void DataModel::write(QJsonObject &target) const @@ -38,6 +44,8 @@ void DataModel::write(QJsonObject &target) const write(m_akkusativ, target, "Akkusativ"); write(m_dativ, target, "Dativ"); write(m_v2Svk, target, "V2Svk"); + write(m_passiv, target, "Passiv"); + write(m_genitiv, target, "Genitiv"); } void DataModel::read(const QJsonObject &source) @@ -49,6 +57,8 @@ void DataModel::read(const QJsonObject &source) read(m_akkusativ, source, "Akkusativ"); read(m_dativ, source, "Dativ"); read(m_v2Svk, source, "V2Svk"); + read(m_passiv, source, "Passiv"); + read(m_genitiv, source, "Genitiv"); } void DataModel::pluralModelChanged() @@ -86,3 +96,13 @@ void DataModel::v2SvkModelChanged() m_results.setV2Result(m_v2Svk.getV2Points()); m_results.setSvkResult(m_v2Svk.getSvkPoints()); } + +void DataModel::passivModelChanged() +{ + m_results.setPassivResult(m_passiv.getPoints()); +} + +void DataModel::genitivModelChanged() +{ + m_results.setGenitivResult(m_genitiv.getPoints()); +} diff --git a/source/DataModel.h b/source/DataModel.h index df37aeb..f226712 100644 --- a/source/DataModel.h +++ b/source/DataModel.h @@ -7,6 +7,8 @@ #include "AkkusativModel.h" #include "DativModel.h" #include "V2SvkModel.h" +#include "PassivModel.h" +#include "GenitivModel.h" #include "ResultModel.h" @@ -24,6 +26,8 @@ public: AkkusativModel m_akkusativ; DativModel m_dativ; V2SvkModel m_v2Svk; + PassivModel m_passiv; + GenitivModel m_genitiv; ResultModel m_results; @@ -62,4 +66,6 @@ private slots: void akkusativModelChanged(); void dativModelChanged(); void v2SvkModelChanged(); + void passivModelChanged(); + void genitivModelChanged(); }; diff --git a/source/ResultWidget/GenitivPR.h b/source/ResultWidget/GenitivPR.h new file mode 100644 index 0000000..fb70d23 --- /dev/null +++ b/source/ResultWidget/GenitivPR.h @@ -0,0 +1,39 @@ +#pragma once + +#include "PRMap.h" + +class GenitivPR : public PRMap +{ +public: + GenitivPR() + { + // clang-format off + m_ages = { + { 7, 0 }, + { 7, 6 }, + { 8, 0 }, + { 9, 0 } + }; + + m_PRs = { + { 0, 0, 0 }, + { 1, 3, 0 }, + { 2, 3, 0 }, + { 2, 5, 1 }, + { 7, 5, 1 }, + { 8, 6, 1 }, + { 14, 8, 2 }, + { 18, 9, 4 }, + { 21, 17, 7 }, + { 29, 18, 8 }, + { 38, 29, 14 }, + { 50, 42, 23 }, + { 66, 54, 33 }, + { 82, 68, 51 }, + { 90, 83, 72 }, + { 96, 92, 87 }, + { 100, 100, 100 } + }; + // clang-format on + } +}; diff --git a/source/ResultWidget/PassivPR.h b/source/ResultWidget/PassivPR.h new file mode 100644 index 0000000..c98bab5 --- /dev/null +++ b/source/ResultWidget/PassivPR.h @@ -0,0 +1,32 @@ +#pragma once + +#include "PRMap.h" + +class PassivPR : public PRMap +{ +public: + PassivPR() + { + // clang-format off + m_ages = { + { 7, 0 }, + { 8, 6 }, + { 9, 0 } + }; + + m_PRs = { + { 1, 0 }, + { 2, 0 }, + { 6, 2 }, + { 9, 3 }, + { 23, 12 }, + { 34, 23 }, + { 55, 41 }, + { 71, 59 }, + { 85, 76 }, + { 94, 84 }, + { 100, 100 } + }; + // clang-format on + } +}; diff --git a/source/ResultWidget/ResultModel.cpp b/source/ResultWidget/ResultModel.cpp index 15c3244..c905346 100644 --- a/source/ResultWidget/ResultModel.cpp +++ b/source/ResultWidget/ResultModel.cpp @@ -7,6 +7,8 @@ #include "DativPR.h" #include "V2PR.h" #include "SvkPR.h" +#include "PassivPR.h" +#include "GenitivPR.h" #include @@ -188,3 +190,23 @@ void ResultModel::setSvkResult(unsigned int points) emit dataChanged(index(0, 1), index(4, 1)); } } + +void ResultModel::setPassivResult(unsigned int points) +{ + if (m_results[3].points() != points) + { + m_results[3].setPoints(points); + m_results[3].setPR(PassivPR().lookup(m_age, points)); + emit dataChanged(index(0, 3), index(4, 3)); + } +} + +void ResultModel::setGenitivResult(unsigned int points) +{ + if (m_results[7].points() != points) + { + m_results[7].setPoints(points); + m_results[7].setPR(GenitivPR().lookup(m_age, points)); + emit dataChanged(index(0, 7), index(4, 7)); + } +} diff --git a/source/ResultWidget/ResultModel.h b/source/ResultWidget/ResultModel.h index 918f325..1c290f4 100644 --- a/source/ResultWidget/ResultModel.h +++ b/source/ResultWidget/ResultModel.h @@ -70,4 +70,6 @@ public: void setDativResult(unsigned int points); void setV2Result(unsigned int points); void setSvkResult(unsigned int points); + void setPassivResult(unsigned int points); + void setGenitivResult(unsigned int points); }; diff --git a/source/SubTests/CMakeLists.txt b/source/SubTests/CMakeLists.txt index 6ef8db8..3a88935 100644 --- a/source/SubTests/CMakeLists.txt +++ b/source/SubTests/CMakeLists.txt @@ -5,3 +5,4 @@ add_subdirectory(Genus) add_subdirectory(Plural) add_subdirectory(AkkusativDativ) add_subdirectory(V2Svk) +add_subdirectory(LateSkills) diff --git a/source/SubTests/LateSkills/CMakeLists.txt b/source/SubTests/LateSkills/CMakeLists.txt new file mode 100644 index 0000000..a570f42 --- /dev/null +++ b/source/SubTests/LateSkills/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.6) + +project(LateSkills LANGUAGES CXX) + +find_package(Qt5Widgets REQUIRED) + +set(CMAKE_AUTOMOC ON) + +qt5_wrap_ui(UI_HEADERS + LateSkillsWidget.ui +) + +add_library(${PROJECT_NAME} + LateSkillsWidget.cpp + PassivModel.cpp + GenitivModel.cpp + ${UI_HEADERS} +) + +set_target_properties(${PROJECT_NAME} + PROPERTIES CXX_STANDARD 14 +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + CheckableItem + CheckableTest + CheckableTestModel + Qt5::Widgets +) diff --git a/source/SubTests/LateSkills/GenitivModel.cpp b/source/SubTests/LateSkills/GenitivModel.cpp new file mode 100644 index 0000000..59c9e2c --- /dev/null +++ b/source/SubTests/LateSkills/GenitivModel.cpp @@ -0,0 +1,10 @@ +#include "GenitivModel.h" + +GenitivModel::GenitivModel(QObject *parent) + : CheckableTestModel(parent) +{ + m_tests = { + { "Genitiv Präpositionen", { "anstelle", "außerhalb", "mithilfe" } }, + { "Attributierung", { "Schuhe", "Zauberstab", "Hut", "Brille", "Gürtel" } }, + }; +} diff --git a/source/SubTests/LateSkills/GenitivModel.h b/source/SubTests/LateSkills/GenitivModel.h new file mode 100644 index 0000000..722135f --- /dev/null +++ b/source/SubTests/LateSkills/GenitivModel.h @@ -0,0 +1,11 @@ +#pragma once + +#include "CheckableTestModel.h" + +class GenitivModel : public CheckableTestModel +{ + Q_OBJECT + +public: + GenitivModel(QObject *parent); +}; diff --git a/source/SubTests/LateSkills/LateSkillsWidget.cpp b/source/SubTests/LateSkills/LateSkillsWidget.cpp new file mode 100644 index 0000000..5676dc1 --- /dev/null +++ b/source/SubTests/LateSkills/LateSkillsWidget.cpp @@ -0,0 +1,29 @@ +#include "LateSkillsWidget.h" +#include "ui_LateSkillsWidget.h" + +#include "PassivModel.h" +#include "GenitivModel.h" + +LateSkillsWidget::LateSkillsWidget(QWidget *parent) + : QWidget(parent) + , ui(new Ui::LateSkillsWidget) +{ + ui->setupUi(this); + ui->passivTableView->horizontalHeader()->hide(); + ui->genitivTableView->horizontalHeader()->hide(); +} + +LateSkillsWidget::~LateSkillsWidget() +{ + delete ui; +} + +void LateSkillsWidget::setPassivModel(PassivModel *model) +{ + ui->passivTableView->setModel(model); +} + +void LateSkillsWidget::setGenitivModel(GenitivModel *model) +{ + ui->genitivTableView->setModel(model); +} diff --git a/source/SubTests/LateSkills/LateSkillsWidget.h b/source/SubTests/LateSkills/LateSkillsWidget.h new file mode 100644 index 0000000..0fe6e48 --- /dev/null +++ b/source/SubTests/LateSkills/LateSkillsWidget.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +class PassivModel; +class GenitivModel; + +namespace Ui { +class LateSkillsWidget; +}; + +class LateSkillsWidget : public QWidget +{ + Q_OBJECT + +private: + Ui::LateSkillsWidget *ui; + +public: + LateSkillsWidget(QWidget *parent = nullptr); + ~LateSkillsWidget(); + + void setPassivModel(PassivModel *model); + void setGenitivModel(GenitivModel *model); +}; diff --git a/source/SubTests/LateSkills/LateSkillsWidget.ui b/source/SubTests/LateSkills/LateSkillsWidget.ui new file mode 100644 index 0000000..02a452a --- /dev/null +++ b/source/SubTests/LateSkills/LateSkillsWidget.ui @@ -0,0 +1,27 @@ + + + LateSkillsWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + + + + diff --git a/source/SubTests/LateSkills/PassivModel.cpp b/source/SubTests/LateSkills/PassivModel.cpp new file mode 100644 index 0000000..fedd9af --- /dev/null +++ b/source/SubTests/LateSkills/PassivModel.cpp @@ -0,0 +1,9 @@ +#include "PassivModel.h" + +PassivModel::PassivModel(QObject *parent) + : CheckableTestModel(parent) +{ + m_tests = { + { "Passiv", { "Elefant", "Pferde", "Bälle", "Ball", "Fleisch" } } + }; +} diff --git a/source/SubTests/LateSkills/PassivModel.h b/source/SubTests/LateSkills/PassivModel.h new file mode 100644 index 0000000..4247081 --- /dev/null +++ b/source/SubTests/LateSkills/PassivModel.h @@ -0,0 +1,11 @@ +#pragma once + +#include "CheckableTestModel.h" + +class PassivModel : public CheckableTestModel +{ + Q_OBJECT + +public: + PassivModel(QObject *parent); +}; diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index c0b2c0f..8f13afa 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -38,6 +38,8 @@ void MainWindow::newFile() ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ); ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ); ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk); + ui->lateSkillsWidget->setPassivModel(&m_dataModel->m_passiv); + ui->lateSkillsWidget->setGenitivModel(&m_dataModel->m_genitiv); ui->resultWidget->setModel(&m_dataModel->m_results); diff --git a/source/mainwindow.ui b/source/mainwindow.ui index 91cd0e5..a798ca6 100644 --- a/source/mainwindow.ui +++ b/source/mainwindow.ui @@ -18,7 +18,7 @@ - 1 + 6 @@ -70,7 +70,7 @@ - + Subtest 5: Plural @@ -80,6 +80,16 @@ + + + Subtest 6: Späte Fähigkeiten (7;0-8;11) + + + + + + + @@ -240,7 +250,13 @@ V2SvkWidget QWidget -
V2SvkWidget.h
+
V2SvkWidget.h
+ 1 +
+ + LateSkillsWidget + QWidget +
LateSkillsWidget.h
1