Split subtest 1 into four widgets, extracted TPeModel
This commit is contained in:
parent
d59176afdf
commit
a09e9a5351
10 changed files with 148 additions and 24 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
|
95
source/SubTests/V2Svk/TPeModel.cpp
Normal file
95
source/SubTests/V2Svk/TPeModel.cpp
Normal file
|
@ -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));
|
||||
}
|
18
source/SubTests/V2Svk/TPeModel.h
Normal file
18
source/SubTests/V2Svk/TPeModel.h
Normal file
|
@ -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);
|
||||
};
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QWidget>
|
||||
|
||||
class V2SvkModel;
|
||||
class TPeModel;
|
||||
|
||||
namespace Ui {
|
||||
class V2SvkWidget;
|
||||
|
@ -20,4 +21,5 @@ public:
|
|||
~V2SvkWidget();
|
||||
|
||||
void setV2SvkModel(V2SvkModel *model);
|
||||
void setTPeModel(TPeModel *model);
|
||||
};
|
||||
|
|
|
@ -15,7 +15,16 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="v2SvkTableView"/>
|
||||
<widget class="QTableView" name="wfTableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="otTableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tprTableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tpeTableView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue