From 8ef56f1855d7448bc0b655973ff1198afb944d59 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 12 Dec 2018 21:33:44 +0100 Subject: [PATCH] Display causal sentence point count below subtest 2 --- source/SubTests/VerbEnd/VerbEndModel.cpp | 27 ++++++++++++++++++++++ source/SubTests/VerbEnd/VerbEndModel.h | 8 +++++++ source/SubTests/VerbEnd/VerbEndWidget.cpp | 7 ++++++ source/SubTests/VerbEnd/VerbEndWidget.h | 3 +++ source/SubTests/VerbEnd/VerbEndWidget.ui | 28 +++++++++++++++++++++-- 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/source/SubTests/VerbEnd/VerbEndModel.cpp b/source/SubTests/VerbEnd/VerbEndModel.cpp index 89d9a70..87a17fc 100644 --- a/source/SubTests/VerbEnd/VerbEndModel.cpp +++ b/source/SubTests/VerbEnd/VerbEndModel.cpp @@ -1,6 +1,7 @@ #include "VerbEndModel.h" #include +#include VerbEndModel::VerbEndModel(QObject *parent) : CheckableTestModel(parent) @@ -9,6 +10,8 @@ VerbEndModel::VerbEndModel(QObject *parent) {"Telefonat", {"Kausal", "Kausal", "Relativ", "Kausal", "Final", "Temporal", "Temporal"}}, {"Zaubertrick", {"Relativ", "Final", "Kausal", "Final", "Temporal", "Kausal", "Temporal"}}, {"Zauberregel", {"Temporal", "Kausal", "Final", "Relativ", "Temporal", "Relativ"}}}; + + connect(this, &VerbEndModel::dataChanged, this, &VerbEndModel::modelChanged); } void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const @@ -98,7 +101,31 @@ void VerbEndModel::read(const ESGRAF48::VerbEndModel &model) emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); } +unsigned int VerbEndModel::getCausalPoints() const +{ + unsigned int points = 0; + + for (const auto &test : m_tests) + { + for (const auto &item : test.items()) + { + if (item.getText() == "Kausal") + { + points += item.points(); + } + } + } + + return points; +} + +void VerbEndModel::modelChanged() +{ + emit causalPointsChanged(getCausalPoints()); +} + std::string VerbEndModel::getName() const { return "Subtest 2: Verbendstellungsregel (VE)"; }; + diff --git a/source/SubTests/VerbEnd/VerbEndModel.h b/source/SubTests/VerbEnd/VerbEndModel.h index 10b4b1e..411d455 100644 --- a/source/SubTests/VerbEnd/VerbEndModel.h +++ b/source/SubTests/VerbEnd/VerbEndModel.h @@ -15,6 +15,14 @@ public: void write(ESGRAF48::VerbEndModel &model) const; void read(const ESGRAF48::VerbEndModel &model); + unsigned int getCausalPoints() const; + protected: std::string getName() const override; + +private slots: + void modelChanged(); + +signals: + void causalPointsChanged(unsigned int points); }; diff --git a/source/SubTests/VerbEnd/VerbEndWidget.cpp b/source/SubTests/VerbEnd/VerbEndWidget.cpp index c3ebbc5..ee3ffee 100644 --- a/source/SubTests/VerbEnd/VerbEndWidget.cpp +++ b/source/SubTests/VerbEnd/VerbEndWidget.cpp @@ -20,4 +20,11 @@ VerbEndWidget::~VerbEndWidget() void VerbEndWidget::setModel(VerbEndModel *model) { ui->verbEndTableView->setModel(model); + + connect(model, &VerbEndModel::causalPointsChanged, this, &VerbEndWidget::causalPointsChanged); +} + +void VerbEndWidget::causalPointsChanged(unsigned int points) +{ + ui->causalPointsLabel->setText(QString::number(points)); } diff --git a/source/SubTests/VerbEnd/VerbEndWidget.h b/source/SubTests/VerbEnd/VerbEndWidget.h index 95f7ef5..e3b3eaa 100644 --- a/source/SubTests/VerbEnd/VerbEndWidget.h +++ b/source/SubTests/VerbEnd/VerbEndWidget.h @@ -20,4 +20,7 @@ public: ~VerbEndWidget(); void setModel(VerbEndModel *model); + +public slots: + void causalPointsChanged(unsigned int points); }; diff --git a/source/SubTests/VerbEnd/VerbEndWidget.ui b/source/SubTests/VerbEnd/VerbEndWidget.ui index 98c9e4e..b57c1f0 100644 --- a/source/SubTests/VerbEnd/VerbEndWidget.ui +++ b/source/SubTests/VerbEnd/VerbEndWidget.ui @@ -6,8 +6,8 @@ 0 0 - 556 - 210 + 732 + 381 @@ -17,6 +17,30 @@ + + + + + + + 80 + 16777215 + + + + Kausalsätze: + + + + + + + 0 + + + + +