implemented Akkusativ/Dativ result updates

This commit is contained in:
Michael Mandl 2018-06-17 18:44:54 +02:00
parent 3c2ac70a1c
commit a951589787
7 changed files with 58 additions and 11 deletions

View file

@ -9,6 +9,8 @@ DataModel::DataModel(QObject *parent)
, m_genus(this) , m_genus(this)
, m_plural(this) , m_plural(this)
, m_results(this) , m_results(this)
, m_akkusativ(this)
, m_dativ(this)
{ {
connect(&m_plural, &PluralModel::dataChanged, this, connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged); &DataModel::pluralModelChanged);
@ -18,6 +20,10 @@ DataModel::DataModel(QObject *parent)
&DataModel::genusModelChanged); &DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this, connect(&m_verbEnd, &VerbEndModel::dataChanged, this,
&DataModel::verbEndModelChanged); &DataModel::verbEndModelChanged);
connect(&m_akkusativ, &AkkusativModel::dataChanged, this,
&DataModel::akkusativModelChanged);
connect(&m_dativ, &DativModel::dataChanged, this,
&DataModel::dativModelChanged);
} }
void DataModel::write(QJsonObject &target) const void DataModel::write(QJsonObject &target) const
@ -26,6 +32,8 @@ void DataModel::write(QJsonObject &target) const
write(m_verbEnd, target, "VerbEnd"); write(m_verbEnd, target, "VerbEnd");
write(m_genus, target, "Genus"); write(m_genus, target, "Genus");
write(m_plural, target, "Plural"); write(m_plural, target, "Plural");
write(m_akkusativ, target, "Akkusativ");
write(m_dativ, target, "Dativ");
} }
void DataModel::read(const QJsonObject &source) void DataModel::read(const QJsonObject &source)
@ -34,6 +42,8 @@ void DataModel::read(const QJsonObject &source)
read(m_verbEnd, source, "VerbEnd"); read(m_verbEnd, source, "VerbEnd");
read(m_genus, source, "Genus"); read(m_genus, source, "Genus");
read(m_plural, source, "Plural"); read(m_plural, source, "Plural");
read(m_akkusativ, source, "Akkusativ");
read(m_dativ, source, "Dativ");
} }
void DataModel::pluralModelChanged() void DataModel::pluralModelChanged()
@ -55,3 +65,13 @@ void DataModel::verbEndModelChanged()
{ {
m_results.setVerbEndResult(m_verbEnd.getPoints()); m_results.setVerbEndResult(m_verbEnd.getPoints());
} }
void DataModel::akkusativModelChanged()
{
m_results.setAkkusativResult(m_akkusativ.getPoints());
}
void DataModel::dativModelChanged()
{
m_results.setDativResult(m_dativ.getPoints());
}

View file

@ -4,6 +4,8 @@
#include "GenusModel.h" #include "GenusModel.h"
#include "VerbEndModel.h" #include "VerbEndModel.h"
#include "PluralModel.h" #include "PluralModel.h"
#include "AkkusativModel.h"
#include "DativModel.h"
#include "ResultModel.h" #include "ResultModel.h"
@ -18,6 +20,8 @@ public:
VerbEndModel m_verbEnd; VerbEndModel m_verbEnd;
GenusModel m_genus; GenusModel m_genus;
PluralModel m_plural; PluralModel m_plural;
AkkusativModel m_akkusativ;
DativModel m_dativ;
ResultModel m_results; ResultModel m_results;
@ -53,4 +57,6 @@ private slots:
void metaDataChanged(); void metaDataChanged();
void genusModelChanged(); void genusModelChanged();
void verbEndModelChanged(); void verbEndModelChanged();
void akkusativModelChanged();
void dativModelChanged();
}; };

View file

@ -15,7 +15,7 @@ ResultModel::ResultModel(QObject *parent)
int ResultModel::rowCount(const QModelIndex &parent) const int ResultModel::rowCount(const QModelIndex &parent) const
{ {
return 5; return 4;
} }
int ResultModel::columnCount(const QModelIndex &parent) const int ResultModel::columnCount(const QModelIndex &parent) const
@ -101,8 +101,6 @@ QVariant ResultModel::headerData(
return "< PR 84"; return "< PR 84";
case 3: case 3:
return "<= PR 16"; return "<= PR 16";
case 4:
return "T-Wert";
default: default:
return {}; return {};
} }
@ -136,7 +134,7 @@ void ResultModel::setGenusResult(unsigned int points)
emit dataChanged(index(0, 4), index(4, 4)); emit dataChanged(index(0, 4), index(4, 4));
} }
} }
void ResultModel::setVerbEndResult(unsigned int points) void ResultModel::setVerbEndResult(unsigned int points)
{ {
if (m_results[2].points() != 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)); 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));
}
}

View file

@ -66,4 +66,6 @@ public:
void setPluralResult(unsigned int points); void setPluralResult(unsigned int points);
void setGenusResult(unsigned int points); void setGenusResult(unsigned int points);
void setVerbEndResult(unsigned int points); void setVerbEndResult(unsigned int points);
void setAkkusativResult(unsigned int points);
void setDativResult(unsigned int points);
}; };

View file

@ -4,10 +4,10 @@ VerbEndModel::VerbEndModel(QObject *parent)
: CheckableTestModel(parent) : CheckableTestModel(parent)
{ {
m_tests = { { "Telefonat", m_tests = { { "Telefonat",
{ "Kausal (1)", "Kausal (2)", "Relativ", "Kausal (3)", { "Kausal", "Kausal", "Relativ", "Kausal",
"Final", "Temporal (1)", "Temporal (2)" } }, "Final", "Temporal", "Temporal" } },
{ "Zaubertrick", { "Relativ", "Final (1)", "Kausal (1)", "Final (2)", { "Zaubertrick", { "Relativ", "Final", "Kausal", "Final",
"Temporal (1)", "Kausal (2)", "Temporal (2)" } }, "Temporal", "Kausal", "Temporal" } },
{ "Zauberregel", { "Temporal (1)", "Kausal", "Final", "Relativ (1)", { "Zauberregel", { "Temporal", "Kausal", "Final", "Relativ",
"Temporal (2)", "Relativ (2)" } } }; "Temporal", "Relativ" } } };
} }

View file

@ -35,6 +35,9 @@ void MainWindow::newFile()
ui->verbEndWidget->setModel(&m_dataModel->m_verbEnd); ui->verbEndWidget->setModel(&m_dataModel->m_verbEnd);
ui->genusWidget->setModel(&m_dataModel->m_genus); ui->genusWidget->setModel(&m_dataModel->m_genus);
ui->pluralWidget->setModel(&m_dataModel->m_plural); 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); ui->resultWidget->setModel(&m_dataModel->m_results);
m_filename = ""; m_filename = "";

View file

@ -56,7 +56,7 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="AkkusativDativWidget" name="widget" native="true"/> <widget class="AkkusativDativWidget" name="akkusativDativWidget" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>