implemented V2/SVK test

This commit is contained in:
Michael Mandl 2018-06-25 23:04:32 +02:00
parent 5f9356a7f7
commit b8c869ff39
16 changed files with 432 additions and 29 deletions

View file

@ -44,6 +44,7 @@ target_link_libraries(${PROJECT_NAME}
Plural
Genus
AkkusativDativ
V2Svk
ResultWidget
Qt5::Widgets
)

View file

@ -11,6 +11,7 @@ DataModel::DataModel(QObject *parent)
, m_results(this)
, m_akkusativ(this)
, m_dativ(this)
, m_v2Svk(this)
{
connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged);
@ -24,6 +25,8 @@ DataModel::DataModel(QObject *parent)
&DataModel::akkusativModelChanged);
connect(&m_dativ, &DativModel::dataChanged, this,
&DataModel::dativModelChanged);
connect(&m_v2Svk, &V2SvkModel::dataChanged, this,
&DataModel::v2SvkModelChanged);
}
void DataModel::write(QJsonObject &target) const
@ -34,6 +37,7 @@ void DataModel::write(QJsonObject &target) const
write(m_plural, target, "Plural");
write(m_akkusativ, target, "Akkusativ");
write(m_dativ, target, "Dativ");
write(m_v2Svk, target, "V2Svk");
}
void DataModel::read(const QJsonObject &source)
@ -44,6 +48,7 @@ void DataModel::read(const QJsonObject &source)
read(m_plural, source, "Plural");
read(m_akkusativ, source, "Akkusativ");
read(m_dativ, source, "Dativ");
read(m_v2Svk, source, "V2Svk");
}
void DataModel::pluralModelChanged()
@ -75,3 +80,9 @@ void DataModel::dativModelChanged()
{
m_results.setDativResult(m_dativ.getPoints());
}
void DataModel::v2SvkModelChanged()
{
m_results.setV2Result(m_v2Svk.getV2Points());
m_results.setSvkResult(m_v2Svk.getSvkPoints());
}

View file

@ -6,6 +6,7 @@
#include "PluralModel.h"
#include "AkkusativModel.h"
#include "DativModel.h"
#include "V2SvkModel.h"
#include "ResultModel.h"
@ -22,6 +23,7 @@ public:
PluralModel m_plural;
AkkusativModel m_akkusativ;
DativModel m_dativ;
V2SvkModel m_v2Svk;
ResultModel m_results;
@ -59,4 +61,5 @@ private slots:
void verbEndModelChanged();
void akkusativModelChanged();
void dativModelChanged();
void v2SvkModelChanged();
};

View file

@ -5,6 +5,8 @@
#include "VerbEndPR.h"
#include "AkkusativPR.h"
#include "DativPR.h"
#include "V2PR.h"
#include "SvkPR.h"
#include <QDebug>
@ -166,3 +168,23 @@ void ResultModel::setDativResult(unsigned int points)
emit dataChanged(index(0, 6), index(4, 6));
}
}
void ResultModel::setV2Result(unsigned int points)
{
if (m_results[0].points() != points)
{
m_results[0].setPoints(points);
m_results[0].setPR(V2PR().lookup(m_age, points));
emit dataChanged(index(0, 0), index(4, 0));
}
}
void ResultModel::setSvkResult(unsigned int points)
{
if (m_results[1].points() != points)
{
m_results[1].setPoints(points);
m_results[1].setPR(SvkPR().lookup(m_age, points));
emit dataChanged(index(0, 1), index(4, 1));
}
}

View file

@ -68,4 +68,6 @@ public:
void setVerbEndResult(unsigned int points);
void setAkkusativResult(unsigned int points);
void setDativResult(unsigned int points);
void setV2Result(unsigned int points);
void setSvkResult(unsigned int points);
};

View file

@ -0,0 +1,65 @@
#pragma once
#include "PRMap.h"
class SvkPR : public PRMap
{
public:
SvkPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
{ 9, 0 }
};
m_PRs = {
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 1, 0 },
{ 3, 1, 0 },
{ 4, 1, 1 },
{ 4, 1, 1 },
{ 7, 2, 1 },
{ 8, 3, 3 },
{ 8, 5, 3 },
{ 9, 5, 3 },
{ 12, 6, 4 },
{ 17, 6, 4 },
{ 18, 7, 5 },
{ 21, 7, 6 },
{ 21, 8, 7 },
{ 24, 10, 7 },
{ 28, 11, 7 },
{ 32, 12, 9 },
{ 34, 14, 9 },
{ 37, 19, 11 },
{ 42, 25, 13 },
{ 51, 28, 16 },
{ 53, 31, 19 },
{ 59, 38, 25 },
{ 71, 50, 36 },
{ 100, 100, 100 }
};
// clang-format on
}
};

View file

@ -0,0 +1,68 @@
#pragma once
#include "PRMap.h"
class V2PR : public PRMap
{
public:
V2PR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
{ 9, 0 }
};
m_PRs = {
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 1, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 0, 0 },
{ 2, 1, 0 },
{ 2, 1, 0 },
{ 2, 1, 0 },
{ 2, 1, 0 },
{ 3, 1, 0 },
{ 3, 1, 0 },
{ 3, 1, 1 },
{ 3, 1, 1 },
{ 3, 1, 1 },
{ 4, 1, 1 },
{ 5, 2, 1 },
{ 7, 2, 1 },
{ 8, 2, 1 },
{ 9, 3, 2 },
{ 14, 5, 4 },
{ 17, 6, 4 },
{ 18, 7, 5 },
{ 21, 9, 5 },
{ 21, 10, 6 },
{ 22, 10, 6 },
{ 24, 11, 7 },
{ 25, 11, 8 },
{ 27, 14, 9 },
{ 29, 14, 10 },
{ 32, 16, 10 },
{ 37, 19, 12 },
{ 42, 22, 13 },
{ 47, 26, 15 },
{ 52, 29, 19 },
{ 55, 32, 21 },
{ 60, 41, 27 },
{ 69, 52, 37 },
{ 100, 100, 100 }
};
// clang-format on
}
};

View file

@ -4,3 +4,4 @@ add_subdirectory(VerbEnd)
add_subdirectory(Genus)
add_subdirectory(Plural)
add_subdirectory(AkkusativDativ)
add_subdirectory(V2Svk)

View file

@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.6)
project(V2Svk LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
qt5_wrap_ui(UI_HEADERS
V2SvkWidget.ui
)
add_library(${PROJECT_NAME}
V2SvkWidget.cpp
V2SvkModel.cpp
${UI_HEADERS}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES CXX_STANDARD 14
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
Qt5::Widgets
)

View file

@ -0,0 +1,77 @@
#include "V2SvkModel.h"
V2SvkModel::V2SvkModel(QObject *parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "W-Frage",
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
"Gans" , "Gans", "Gans", "Gans"} },
{ "Verbtrennung",
{ "", "Affe", "", "", "", "", "", "Schwein", "" , "", "Gans", ""} },
{ "SVK: /-st/",
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
"Gans" , "Gans", "Gans", "Gans"} },
{ "Objekt-Topikalisierung",
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
"Gans" , "Gans", "Gans", "Gans"} },
{ "SVK: Stamm",
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
"Gans" , "Gans", "Gans", "Gans"} },
{ "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" } },
};
}
unsigned int V2SvkModel::getV2Points()
{
size_t points = 0;
for (auto testIndex : { 0, 1, 3, 5, 7, 8 })
{
const auto &test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
}
unsigned int V2SvkModel::getSvkPoints()
{
size_t points = 0;
for (auto testIndex : { 2, 4, 6, 9, 10 })
{
const auto &test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
}

View file

@ -0,0 +1,14 @@
#pragma once
#include "CheckableTestModel.h"
class V2SvkModel : public CheckableTestModel
{
Q_OBJECT
public:
V2SvkModel(QObject *parent);
unsigned int getV2Points();
unsigned int getSvkPoints();
};

View file

@ -0,0 +1,21 @@
#include "V2SvkWidget.h"
#include "ui_V2SvkWidget.h"
#include "V2SvkModel.h"
V2SvkWidget::V2SvkWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::V2SvkWidget)
{
ui->setupUi(this);
}
V2SvkWidget::~V2SvkWidget()
{
delete ui;
}
void V2SvkWidget::setV2SvkModel(V2SvkModel *model)
{
ui->v2SvkTableView->setModel(model);
}

View file

@ -0,0 +1,23 @@
#pragma once
#include <QWidget>
class V2SvkModel;
namespace Ui {
class V2SvkWidget;
};
class V2SvkWidget : public QWidget
{
Q_OBJECT
private:
Ui::V2SvkWidget *ui;
public:
V2SvkWidget(QWidget *parent = nullptr);
~V2SvkWidget();
void setV2SvkModel(V2SvkModel *model);
};

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>V2SvkWidget</class>
<widget class="QWidget" name="V2SvkWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="v2SvkTableView"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -37,6 +37,7 @@ void MainWindow::newFile()
ui->pluralWidget->setModel(&m_dataModel->m_plural);
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ);
ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ);
ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk);
ui->resultWidget->setModel(&m_dataModel->m_results);
@ -45,8 +46,8 @@ void MainWindow::newFile()
void MainWindow::openFile()
{
QString filename = QFileDialog::getOpenFileName(this, "Open file",
"", "ESGRAF 4-8 (*.esgraf48)");
QString filename = QFileDialog::getOpenFileName(
this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
if (filename.isEmpty())
{
return;
@ -83,8 +84,8 @@ void MainWindow::saveFile()
void MainWindow::saveFileAs()
{
QString filename = QFileDialog::getSaveFileName(this, "Save file", "",
"ESGRAF 4-8 (*.esgraf48)");
QString filename = QFileDialog::getSaveFileName(
this, "Save file", "", "ESGRAF 4-8 (*.esgraf48)");
if (filename.isEmpty())
{
return;

View file

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="testTabWidget">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="MetaDataTab">
<attribute name="title">
@ -30,6 +30,16 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="v2SvkTab">
<attribute name="title">
<string>Subtest 1: V2/SVK</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="V2SvkWidget" name="v2SvkWidget" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="VerbEndTab">
<attribute name="title">
<string>Subtest 2: Verbendstellungsregel (VE)</string>
@ -74,6 +84,24 @@
</item>
<item>
<widget class="QTabWidget" name="resultTabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>220</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>220</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
@ -100,7 +128,7 @@
<x>0</x>
<y>0</y>
<width>1125</width>
<height>17</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -227,6 +255,12 @@
<header>AkkusativDativWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>V2SvkWidget</class>
<extends>QWidget</extends>
<header location="global">V2SvkWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="mainwindow.qrc"/>