From a951589787c2c1b48405b9c4cf96b52cf408aead Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 17 Jun 2018 18:44:54 +0200 Subject: [PATCH] implemented Akkusativ/Dativ result updates --- source/DataModel.cpp | 20 ++++++++++++++++++++ source/DataModel.h | 6 ++++++ source/ResultWidget/ResultModel.cpp | 24 ++++++++++++++++++++---- source/ResultWidget/ResultModel.h | 2 ++ source/SubTests/VerbEnd/VerbEndModel.cpp | 12 ++++++------ source/mainwindow.cpp | 3 +++ source/mainwindow.ui | 2 +- 7 files changed, 58 insertions(+), 11 deletions(-) diff --git a/source/DataModel.cpp b/source/DataModel.cpp index d10b0b5..78fa623 100644 --- a/source/DataModel.cpp +++ b/source/DataModel.cpp @@ -9,6 +9,8 @@ DataModel::DataModel(QObject *parent) , m_genus(this) , m_plural(this) , m_results(this) + , m_akkusativ(this) + , m_dativ(this) { connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged); @@ -18,6 +20,10 @@ DataModel::DataModel(QObject *parent) &DataModel::genusModelChanged); connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged); + connect(&m_akkusativ, &AkkusativModel::dataChanged, this, + &DataModel::akkusativModelChanged); + connect(&m_dativ, &DativModel::dataChanged, this, + &DataModel::dativModelChanged); } void DataModel::write(QJsonObject &target) const @@ -26,6 +32,8 @@ void DataModel::write(QJsonObject &target) const write(m_verbEnd, target, "VerbEnd"); write(m_genus, target, "Genus"); write(m_plural, target, "Plural"); + write(m_akkusativ, target, "Akkusativ"); + write(m_dativ, target, "Dativ"); } void DataModel::read(const QJsonObject &source) @@ -34,6 +42,8 @@ void DataModel::read(const QJsonObject &source) read(m_verbEnd, source, "VerbEnd"); read(m_genus, source, "Genus"); read(m_plural, source, "Plural"); + read(m_akkusativ, source, "Akkusativ"); + read(m_dativ, source, "Dativ"); } void DataModel::pluralModelChanged() @@ -55,3 +65,13 @@ void DataModel::verbEndModelChanged() { m_results.setVerbEndResult(m_verbEnd.getPoints()); } + +void DataModel::akkusativModelChanged() +{ + m_results.setAkkusativResult(m_akkusativ.getPoints()); +} + +void DataModel::dativModelChanged() +{ + m_results.setDativResult(m_dativ.getPoints()); +} diff --git a/source/DataModel.h b/source/DataModel.h index e6bd592..830b614 100644 --- a/source/DataModel.h +++ b/source/DataModel.h @@ -4,6 +4,8 @@ #include "GenusModel.h" #include "VerbEndModel.h" #include "PluralModel.h" +#include "AkkusativModel.h" +#include "DativModel.h" #include "ResultModel.h" @@ -18,6 +20,8 @@ public: VerbEndModel m_verbEnd; GenusModel m_genus; PluralModel m_plural; + AkkusativModel m_akkusativ; + DativModel m_dativ; ResultModel m_results; @@ -53,4 +57,6 @@ private slots: void metaDataChanged(); void genusModelChanged(); void verbEndModelChanged(); + void akkusativModelChanged(); + void dativModelChanged(); }; diff --git a/source/ResultWidget/ResultModel.cpp b/source/ResultWidget/ResultModel.cpp index a46e265..24a7686 100644 --- a/source/ResultWidget/ResultModel.cpp +++ b/source/ResultWidget/ResultModel.cpp @@ -15,7 +15,7 @@ ResultModel::ResultModel(QObject *parent) int ResultModel::rowCount(const QModelIndex &parent) const { - return 5; + return 4; } int ResultModel::columnCount(const QModelIndex &parent) const @@ -101,8 +101,6 @@ QVariant ResultModel::headerData( return "< PR 84"; case 3: return "<= PR 16"; - case 4: - return "T-Wert"; default: return {}; } @@ -136,7 +134,7 @@ void ResultModel::setGenusResult(unsigned int points) emit dataChanged(index(0, 4), index(4, 4)); } } - + void ResultModel::setVerbEndResult(unsigned int points) { if (m_results[2].points() != points) @@ -146,3 +144,21 @@ void ResultModel::setVerbEndResult(unsigned int points) emit dataChanged(index(0, 2), index(4, 2)); } } + +void ResultModel::setAkkusativResult(unsigned int points) +{ + if (m_results[5].points() != points) + { + m_results[5].setPoints(points); + emit dataChanged(index(0, 5), index(4, 5)); + } +} + +void ResultModel::setDativResult(unsigned int points) +{ + if (m_results[6].points() != points) + { + m_results[6].setPoints(points); + emit dataChanged(index(0, 6), index(4, 6)); + } +} diff --git a/source/ResultWidget/ResultModel.h b/source/ResultWidget/ResultModel.h index 53a95c8..4befa81 100644 --- a/source/ResultWidget/ResultModel.h +++ b/source/ResultWidget/ResultModel.h @@ -66,4 +66,6 @@ public: void setPluralResult(unsigned int points); void setGenusResult(unsigned int points); void setVerbEndResult(unsigned int points); + void setAkkusativResult(unsigned int points); + void setDativResult(unsigned int points); }; diff --git a/source/SubTests/VerbEnd/VerbEndModel.cpp b/source/SubTests/VerbEnd/VerbEndModel.cpp index 8793873..bbda111 100644 --- a/source/SubTests/VerbEnd/VerbEndModel.cpp +++ b/source/SubTests/VerbEnd/VerbEndModel.cpp @@ -4,10 +4,10 @@ VerbEndModel::VerbEndModel(QObject *parent) : CheckableTestModel(parent) { m_tests = { { "Telefonat", - { "Kausal (1)", "Kausal (2)", "Relativ", "Kausal (3)", - "Final", "Temporal (1)", "Temporal (2)" } }, - { "Zaubertrick", { "Relativ", "Final (1)", "Kausal (1)", "Final (2)", - "Temporal (1)", "Kausal (2)", "Temporal (2)" } }, - { "Zauberregel", { "Temporal (1)", "Kausal", "Final", "Relativ (1)", - "Temporal (2)", "Relativ (2)" } } }; + { "Kausal", "Kausal", "Relativ", "Kausal", + "Final", "Temporal", "Temporal" } }, + { "Zaubertrick", { "Relativ", "Final", "Kausal", "Final", + "Temporal", "Kausal", "Temporal" } }, + { "Zauberregel", { "Temporal", "Kausal", "Final", "Relativ", + "Temporal", "Relativ" } } }; } diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index c2b25ce..4887656 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -35,6 +35,9 @@ void MainWindow::newFile() ui->verbEndWidget->setModel(&m_dataModel->m_verbEnd); ui->genusWidget->setModel(&m_dataModel->m_genus); ui->pluralWidget->setModel(&m_dataModel->m_plural); + ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ); + ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ); + ui->resultWidget->setModel(&m_dataModel->m_results); m_filename = ""; diff --git a/source/mainwindow.ui b/source/mainwindow.ui index 8a20f59..5532b05 100644 --- a/source/mainwindow.ui +++ b/source/mainwindow.ui @@ -56,7 +56,7 @@ - +