implemented verb-end results

This commit is contained in:
Michael Mandl 2018-06-15 18:36:58 +02:00
parent 5bc7edabc6
commit 1bbc6fcb30
6 changed files with 66 additions and 3 deletions

View file

@ -12,12 +12,12 @@ DataModel::DataModel(QObject *parent)
{
connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged);
connect(&m_metaData, &PluralModel::dataChanged, this,
&DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this,
&DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this,
&DataModel::verbEndModelChanged);
}
void DataModel::write(QJsonObject &target) const
@ -50,3 +50,8 @@ void DataModel::genusModelChanged()
{
m_results.setGenusResult(m_genus.getPoints());
}
void DataModel::verbEndModelChanged()
{
m_results.setVerbEndResult(m_verbEnd.getPoints());
}

View file

@ -52,4 +52,5 @@ private slots:
void pluralModelChanged();
void metaDataChanged();
void genusModelChanged();
void verbEndModelChanged();
};

View file

@ -2,6 +2,7 @@
#include "PluralPR.h"
#include "GenusPR.h"
#include "VerbEndPR.h"
#include <QDebug>
@ -136,3 +137,13 @@ 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)
{
m_results[2].setPoints(points);
m_results[2].setPR(VerbEndPR().lookup(m_age, points));
emit dataChanged(index(0, 2), index(4, 2));
}
}

View file

@ -65,4 +65,5 @@ public:
void setAge(const Age &age);
void setPluralResult(unsigned int points);
void setGenusResult(unsigned int points);
void setVerbEndResult(unsigned int points);
};

View file

@ -0,0 +1,45 @@
#pragma once
#include "PRMap.h"
class VerbEndPR : public PRMap
{
public:
VerbEndPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 4, 6 },
{ 5, 0 },
{ 6, 0 },
{ 9, 0 }
};
m_PRs = {
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 4, 1, 0, 0 },
{ 7, 4, 0, 0 },
{ 11, 4, 1, 0 },
{ 12, 4, 1, 0 },
{ 14, 4, 1, 0 },
{ 14, 6, 2, 1 },
{ 15, 8, 3, 1 },
{ 17, 8, 5, 1 },
{ 21, 11, 6, 2 },
{ 26, 14, 9, 2 },
{ 30, 18, 12, 3 },
{ 36, 22, 15, 5 },
{ 42, 29, 20, 10 },
{ 58, 39, 28, 22 },
{ 74, 51, 47, 38 },
{ 85, 79, 74, 65 },
{ 100, 100, 100, 100, 100 },
};
// clang-format on
}
};

View file

@ -32,7 +32,7 @@
</widget>
<widget class="QWidget" name="VerbEndTab">
<attribute name="title">
<string>Subtest 2: Verbenstellungsregel (VE)</string>
<string>Subtest 2: Verbendstellungsregel (VE)</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>