Merge branch 'develop'

This commit is contained in:
mandlm 2018-11-18 21:34:10 +01:00
commit 5a88e99a15
41 changed files with 1333 additions and 200 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ compile_commands.json
_*/
build-*
*.user
tags

View File

@ -0,0 +1,46 @@
syntax = "proto3";
package ESGRAF48;
message AkkusativModel
{
message TiereModel
{
bool Tiger = 1;
bool Katze = 2;
bool Affe = 3;
bool Gans = 4;
bool Baer = 5;
bool Pferd = 6;
bool Hund = 7;
bool Elefant = 8;
}
message VersteckeModel
{
bool Vorhang1 = 1;
bool Kiste1 = 2;
bool Holz1 = 3;
bool Kiste2 = 4;
bool Baum1 = 5;
bool Vorhang2 = 6;
bool Holz2 = 7;
bool Baum2 = 8;
}
message FutterModel
{
bool Salat = 1;
bool Fleisch = 2;
bool Knochen = 3;
bool Banane = 4;
bool Apfel = 5;
bool Karotte = 6;
bool Honig = 7;
bool Zucker = 8;
}
TiereModel Tiere = 1;
VersteckeModel Verstecke = 2;
FutterModel Futter = 3;
}

26
proto/DataModel.proto Normal file
View File

@ -0,0 +1,26 @@
syntax = "proto3";
package ESGRAF48;
import "MetaDataModel.proto";
import "V2SvkModel.proto";
import "VerbEndModel.proto";
import "GenusModel.proto";
import "AkkusativModel.proto";
import "DativModel.proto";
import "PluralModel.proto";
import "LateSkillsGenitivModel.proto";
import "LateSkillsPassivModel.proto";
message DataModel
{
MetaDataModel MetaData = 1;
V2SvkModel V2Svk = 2;
VerbEndModel VerbEnd = 3;
GenusModel Genus = 4;
AkkusativModel Akkusativ = 5;
DativModel Dativ = 6;
PluralModel Plural = 7;
LateSkillsGenitivModel LateSkillsGenitiv = 8;
LateSkillsPassivModel LateSkillsPassiv = 9;
}

46
proto/DativModel.proto Normal file
View File

@ -0,0 +1,46 @@
syntax = "proto3";
package ESGRAF48;
message DativModel
{
message TiereModel
{
bool Tiger = 1;
bool Katze = 2;
bool Affe = 3;
bool Gans = 4;
bool Baer = 5;
bool Pferd = 6;
bool Hund = 7;
bool Elefant = 8;
}
message VersteckeModel
{
bool Vorhang1 = 1;
bool Kiste1 = 2;
bool Holz1 = 3;
bool Kiste2 = 4;
bool Baum1 = 5;
bool Vorhang2 = 6;
bool Holz2 = 7;
bool Baum2 = 8;
}
message FutterModel
{
bool Salat = 1;
bool Fleisch = 2;
bool Knochen = 3;
bool Banane = 4;
bool Apfel = 5;
bool Karotte = 6;
bool Honig = 7;
bool Zucker = 8;
}
TiereModel Tiere = 1;
VersteckeModel Verstecke = 2;
FutterModel Futter = 3;
}

42
proto/GenusModel.proto Normal file
View File

@ -0,0 +1,42 @@
syntax = "proto3";
package ESGRAF48;
message GenusModel
{
message TiereModel
{
bool Tiger = 1;
bool Baer = 2;
bool Katze = 3;
bool Pferd = 4;
bool Gans = 5;
bool Elefant = 6;
bool Affe = 7;
bool Hund = 8;
}
message FutterModel
{
bool Salat = 1;
bool Fleisch = 2;
bool Knochen = 3;
bool Banane = 4;
bool Apfel = 5;
bool Karotte = 6;
bool Honig = 7;
bool Zucker = 8;
}
message ZirkusModel
{
bool Kiste = 1;
bool Holz = 2;
bool Vorhang = 3;
bool Baum = 4;
}
TiereModel Tiere = 1;
FutterModel Futter = 2;
ZirkusModel Zirkus = 3;
}

View File

@ -0,0 +1,33 @@
syntax = "proto3";
package ESGRAF48;
message LateSkillsGenitivModel
{
message PraepositionenModel
{
bool anstelle1 = 1;
bool anstelle2 = 2;
bool ausserhalb1 = 3;
bool ausserhalb2 = 4;
bool mithilfe1 = 5;
bool mithilfe2 = 6;
}
message AttributierungModel
{
bool Schuhe1 = 1;
bool Schuhe2 = 2;
bool Zauberstab1 = 3;
bool Zauberstab2 = 4;
bool Hut1 = 5;
bool Hut2 = 6;
bool Brille1 = 7;
bool Brille2 = 8;
bool Guertel1 = 9;
bool Guertel2 = 10;
}
PraepositionenModel Praepositionen = 1;
AttributierungModel Attributierung = 2;
}

View File

@ -0,0 +1,17 @@
syntax = "proto3";
package ESGRAF48;
message LateSkillsPassivModel
{
bool Elefant1 = 1;
bool Elefant2 = 2;
bool Pferde1 = 3;
bool Pferde2 = 4;
bool Baelle1 = 5;
bool Baelle2 = 6;
bool Ball1 = 7;
bool Ball2 = 8;
bool Fleisch1 = 9;
bool Fleisch2 = 10;
}

12
proto/MetaDataModel.proto Normal file
View File

@ -0,0 +1,12 @@
syntax = "proto3";
package ESGRAF48;
message MetaDataModel
{
string ParticipantName = 1;
string InstructorName = 2;
string DateOfBirth = 3;
string DateOfTest = 4;
string Remarks = 5;
}

16
proto/PluralModel.proto Normal file
View File

@ -0,0 +1,16 @@
syntax = "proto3";
package ESGRAF48;
message PluralModel
{
bool Fisch = 1;
bool Banane = 2;
bool Bonbon = 3;
bool Ei = 4;
bool Eimer = 5;
bool Korn = 6;
bool Nuss = 7;
bool Baer = 8;
bool Apfel = 9;
}

51
proto/V2SvkModel.proto Normal file
View File

@ -0,0 +1,51 @@
syntax = "proto3";
package ESGRAF48;
message V2SvkModel
{
message OneEach
{
bool Affe = 1;
bool Schwein = 2;
bool Gans = 3;
}
message TwoEach
{
bool Affe1 = 1;
bool Affe2 = 2;
bool Schwein1 = 3;
bool Schwein2 = 4;
bool Gans1 = 5;
bool Gans2 = 6;
}
message FourEach
{
bool Affe1 = 1;
bool Affe2 = 2;
bool Affe3 = 3;
bool Affe4 = 4;
bool Schwein1 = 5;
bool Schwein2 = 6;
bool Schwein3 = 7;
bool Schwein4 = 8;
bool Gans1 = 9;
bool Gans2 = 10;
bool Gans3 = 11;
bool Gans4 = 12;
}
FourEach WFrage = 1;
OneEach Verbtrennung1 = 2;
FourEach SvkSt = 3;
FourEach ObjTop = 4;
FourEach SvkStamm = 5;
TwoEach TempPraes = 6;
TwoEach SvkE1 = 7;
TwoEach TempPerf = 8;
TwoEach Verbtrennung2 = 9;
TwoEach SvkE2 = 10;
TwoEach Partizip = 11;
}

42
proto/VerbEndModel.proto Normal file
View File

@ -0,0 +1,42 @@
syntax = "proto3";
package ESGRAF48;
message VerbEndModel
{
message TelefonatModel
{
bool Kausal1 = 1;
bool Kausal2 = 2;
bool Relativ = 3;
bool Kausal3 = 4;
bool Final = 5;
bool Temporal1 = 6;
bool Temporal2 = 7;
}
message ZaubertrickModel
{
bool Relativ = 1;
bool Final1 = 2;
bool Kausal1 = 3;
bool Final2 = 4;
bool Temporal1 = 5;
bool Kausal2 = 6;
bool Temporal2 = 7;
}
message ZauberregelModel
{
bool Temporal1 = 1;
bool Kausal = 2;
bool Final = 3;
bool Relativ1 = 4;
bool Temporal2 = 5;
bool Relativ2 = 6;
}
TelefonatModel Telefonat = 1;
ZaubertrickModel Zaubertrick = 2;
ZauberregelModel Zauberregel = 3;
}

View File

@ -4,6 +4,7 @@ project(ESGRAF48 LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@ -16,6 +17,22 @@ qt5_add_resources(LOGO_TEST_QRC
mainwindow.qrc
)
set(DataModel_PROTO_FILES
../proto/DataModel.proto
../proto/MetaDataModel.proto
../proto/V2SvkModel.proto
../proto/VerbEndModel.proto
../proto/GenusModel.proto
../proto/AkkusativModel.proto
../proto/DativModel.proto
../proto/PluralModel.proto
../proto/LateSkillsPassivModel.proto
../proto/LateSkillsGenitivModel.proto
)
protobuf_generate_cpp(DataModel_PROTO_SRCS DataModel_PROTO_HDRS
${DataModel_PROTO_FILES})
add_executable(${PROJECT_NAME} WIN32
LogoTest.cpp
DataModel.cpp
@ -23,6 +40,8 @@ add_executable(${PROJECT_NAME} WIN32
Age.cpp
${LOGO_TEST_UI}
${LOGO_TEST_QRC}
${DataModel_PROTO_SRCS}
${DataModel_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -33,6 +52,7 @@ target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -50,6 +70,7 @@ target_link_libraries(${PROJECT_NAME}
ResultWidget
Qt5::Widgets
Qt5::PrintSupport
${Protobuf_LIBRARIES}
)
add_subdirectory(CheckableItem)

View File

@ -30,9 +30,10 @@ public:
unsigned int getPoints() const;
private:
bool isValidIndex(const QModelIndex &index) const;
protected:
virtual bool isValidIndex(const QModelIndex &index) const;
private:
CheckableItems &getItems(const QModelIndex &index);
const CheckableItems &getItems(const QModelIndex &index) const;

View File

@ -1,64 +1,86 @@
#include "DataModel.h"
#include "DataModel.pb.h"
#include <QDebug>
#include <sstream>
DataModel::DataModel(QObject *parent)
: QObject(parent)
, m_metaData(this)
, m_verbEnd(this)
, m_genus(this)
, m_plural(this)
, m_results(this)
, m_akkusativ(this)
, m_dativ(this)
, m_v2Svk(this)
: QObject(parent)
, m_metaData(this)
, m_verbEnd(this)
, m_genus(this)
, m_plural(this)
, m_results(this)
, m_akkusativ(this)
, m_dativ(this)
, m_v2Svk(this)
, m_passiv(this)
, m_genitiv(this)
{
connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged);
connect(&m_metaData, &MetaDataModel::dataChanged, this,
&DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this,
&DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this,
&DataModel::verbEndModelChanged);
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_passiv, &PassivModel::dataChanged, this,
&DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this,
&DataModel::genitivModelChanged);
connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged);
connect(&m_metaData, &MetaDataModel::dataChanged, this, &DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this, &DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged);
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_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
}
void DataModel::write(QJsonObject &target) const
void DataModel::writeProtoBuf(std::ostream &outStream) const
{
write(m_metaData, target, "MetaData");
write(m_verbEnd, target, "VerbEnd");
write(m_genus, target, "Genus");
write(m_plural, target, "Plural");
write(m_akkusativ, target, "Akkusativ");
write(m_dativ, target, "Dativ");
write(m_v2Svk, target, "V2Svk");
write(m_passiv, target, "Passiv");
write(m_genitiv, target, "Genitiv");
ESGRAF48::DataModel dataModel;
m_metaData.writeProtoBuf(*dataModel.mutable_metadata());
m_v2Svk.writeProtoBuf(*dataModel.mutable_v2svk());
m_verbEnd.writeProtoBuf(*dataModel.mutable_verbend());
m_genus.writeProtoBuf(*dataModel.mutable_genus());
m_akkusativ.write(*dataModel.mutable_akkusativ());
m_dativ.write(*dataModel.mutable_dativ());
m_plural.write(*dataModel.mutable_plural());
m_genitiv.write(*dataModel.mutable_lateskillsgenitiv());
m_passiv.write(*dataModel.mutable_lateskillspassiv());
dataModel.SerializeToOstream(&outStream);
}
void DataModel::read(const QJsonObject &source)
void DataModel::readProtoBuf(std::istream &inStream)
{
read(m_metaData, source, "MetaData");
read(m_verbEnd, source, "VerbEnd");
read(m_genus, source, "Genus");
read(m_plural, source, "Plural");
read(m_akkusativ, source, "Akkusativ");
read(m_dativ, source, "Dativ");
read(m_v2Svk, source, "V2Svk");
read(m_passiv, source, "Passiv");
read(m_genitiv, source, "Genitiv");
ESGRAF48::DataModel dataModel;
dataModel.ParseFromIstream(&inStream);
m_metaData.readProtoBuf(dataModel.metadata());
m_v2Svk.readProtoBuf(dataModel.v2svk());
m_verbEnd.readProtoBuf(dataModel.verbend());
m_genus.readProtoBuf(dataModel.genus());
m_akkusativ.read(dataModel.akkusativ());
m_dativ.read(dataModel.dativ());
m_plural.read(dataModel.plural());
m_genitiv.read(dataModel.lateskillsgenitiv());
m_passiv.read(dataModel.lateskillspassiv());
}
std::string DataModel::toHtml() const
{
std::stringstream out;
out << "<html>" << std::endl;
out << "<head>" << std::endl;
out << "<style>" << std::endl;
out << "body {" << std::endl;
out << "font-family:sans-serif;" << std::endl;
out << "}" << std::endl;
out << "</style>" << std::endl;
out << "</head>" << std::endl;
out << "<body>" << std::endl;
out << "<h2>ESGRAF 4-8 Auswertungsbogen</h2>" << std::endl;
out << "<p>" << std::endl;
out << m_metaData.toHtml();
out << "</p>" << std::endl;
out << "</body>" << std::endl;
out << "</html>" << std::endl;
return out.str();
}
void DataModel::pluralModelChanged()
@ -113,14 +135,14 @@ void DataModel::v2SvkModelChanged()
void DataModel::passivModelChanged()
{
m_results.setPassivResult(m_passiv.getPoints());
m_results.setPassivResult(m_passiv.getPoints());
emit modelChanged();
}
void DataModel::genitivModelChanged()
{
m_results.setGenitivResult(m_genitiv.getPoints());
m_results.setGenitivResult(m_genitiv.getPoints());
emit modelChanged();
}

View File

@ -34,8 +34,10 @@ public:
public:
DataModel(QObject *parent);
void write(QJsonObject &target) const;
void read(const QJsonObject &source);
std::string toHtml() const;
void writeProtoBuf(std::ostream &outStream) const;
void readProtoBuf(std::istream &inStream);
signals:
void modelChanged();

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(MetaData LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,10 +11,20 @@ qt5_wrap_ui(META_DATA_UI
MetaDataWidget.ui
)
set(MetaDataModel_PROTO_FILES
../../proto/MetaDataModel.proto
)
protobuf_generate_cpp(MetaDataModel_PROTO_SRCS MetaDataModel_PROTO_HDRS
${MetaDataModel_PROTO_FILES}
)
add_library(${PROJECT_NAME}
MetaDataModel.cpp
MetaDataWidget.cpp
${META_DATA_UI}
${MetaDataModel_PROTO_SRCS}
${MetaDataModel_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -23,6 +34,7 @@ set_target_properties(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
@ -30,4 +42,5 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -2,8 +2,10 @@
#include <QDebug>
#include <sstream>
MetaDataModel::MetaDataModel(QObject *parent)
: QAbstractTableModel(parent)
: QAbstractTableModel(parent)
{
m_dateOfBirth = QDate::currentDate().addYears(-9);
m_dateOfTest = QDate::currentDate();
@ -50,8 +52,7 @@ Qt::ItemFlags MetaDataModel::flags(const QModelIndex &modelIndex) const
return QAbstractTableModel::flags(modelIndex) | Qt::ItemIsEditable;
}
bool MetaDataModel::setData(
const QModelIndex &modelIndex, const QVariant &value, int role)
bool MetaDataModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
{
if (role != Qt::EditRole)
{
@ -111,20 +112,57 @@ bool MetaDataModel::setData(
return valueChanged;
}
void MetaDataModel::write(QJsonObject &json) const
void MetaDataModel::readProtoBuf(const ESGRAF48::MetaDataModel &model)
{
json["participant name"] = m_participant;
json["instructor name"] = m_instructor;
json["date of birth"] = m_dateOfBirth.toString(Qt::ISODate);
json["date of test"] = m_dateOfTest.toString(Qt::ISODate);
json["remarks"] = m_remarks;
setData(index(0, 0), QString::fromStdString(model.participantname()));
setData(index(0, 1), QString::fromStdString(model.instructorname()));
setData(index(0, 2), QString::fromStdString(model.dateofbirth()));
setData(index(0, 3), QString::fromStdString(model.dateoftest()));
setData(index(0, 4), QString::fromStdString(model.remarks()));
}
void MetaDataModel::read(const QJsonObject &json)
void MetaDataModel::writeProtoBuf(ESGRAF48::MetaDataModel &model) const
{
setData(index(0, 0), json["participant name"].toVariant(), Qt::EditRole);
setData(index(0, 1), json["instructor name"].toVariant(), Qt::EditRole);
setData(index(0, 2), json["date of birth"].toVariant(), Qt::EditRole);
setData(index(0, 3), json["date of test"].toVariant(), Qt::EditRole);
setData(index(0, 4), json["remarks"].toVariant(), Qt::EditRole);
model.set_participantname(m_participant.toStdString());
model.set_instructorname(m_instructor.toStdString());
model.set_dateofbirth(m_dateOfBirth.toString(Qt::ISODate).toStdString());
model.set_dateoftest(m_dateOfTest.toString(Qt::ISODate).toStdString());
model.set_remarks(m_remarks.toStdString());
}
std::string MetaDataModel::toHtml() const
{
std::ostringstream out;
out << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" frame=\"box\" rules=\"all\">"
<< std::endl;
out << "<tr>" << std::endl;
out << "<td width=\"25%\">Name, Vorname</td>" << std::endl;
out << "<td width=\"25%\">" << m_participant.toHtmlEscaped().toStdString() << "</td>"
<< std::endl;
out << "<td width=\"25%\">Untersucher(in)</td>" << std::endl;
out << "<td width=\"25%\">" << m_instructor.toHtmlEscaped().toStdString() << "</td>"
<< std::endl;
out << "</tr>" << std::endl;
out << "<tr>" << std::endl;
out << "<td>Geburtsdatum</td>" << std::endl;
out << "<td>" << m_dateOfBirth.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
<< std::endl;
out << "<td colspan=\"2\">Bemerkungen</td>" << std::endl;
out << "</tr>" << std::endl;
out << "<tr>" << std::endl;
out << "<td>Untersuchungsdatum</td>" << std::endl;
out << "<td>" << m_dateOfTest.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
<< std::endl;
out << "<td colspan=\"2\" rowspan=\"2\">"
<< m_remarks.trimmed().toHtmlEscaped().replace("\n", "<br>").toStdString() << "</td>"
<< std::endl;
out << "</tr>" << std::endl;
out << "<tr>" << std::endl;
out << "<td>Alter am Testtag</td>" << std::endl;
out << "<td>" << getAge().toString() << "</td>" << std::endl;
out << "</tr>" << std::endl;
out << "</table>" << std::endl;
return out.str();
}

View File

@ -2,6 +2,8 @@
#include "../Age.h"
#include "MetaDataModel.pb.h"
#include <QAbstractTableModel>
#include <QString>
#include <QDate>
@ -28,8 +30,10 @@ public:
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
void write(QJsonObject &json) const;
void read(const QJsonObject &json);
void readProtoBuf(const ESGRAF48::MetaDataModel &model);
void writeProtoBuf(ESGRAF48::MetaDataModel &model) const;
std::string toHtml() const;
Age getAge() const
{

View File

@ -1,15 +1,107 @@
#include "AkkusativModel.h"
AkkusativModel::AkkusativModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "Akkusativ Nominalphrase", { "Tiger", "Katze", "Affe", "Gans", "Bär",
"Pferd", "Hund", "Elefant" } },
{ "Präpositionalphrase (Verstecke)",
{ "Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz",
"Baum" } },
{ "Nominalphrase (Futter)", { "Salat", "Fleisch", "Knochen", "Banane",
"Apfel", "Karotte", "Honig", "Zucker" } }
};
m_tests = {{"Akkusativ Nominalphrase",
{"Tiger", "Katze", "Affe", "Gans", "Bär", "Pferd", "Hund", "Elefant"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Futter)",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}}};
}
void AkkusativModel::read(const ESGRAF48::AkkusativModel &model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.katze());
testItems[2].setState(tiereModel.affe());
testItems[3].setState(tiereModel.gans());
testItems[4].setState(tiereModel.baer());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.hund());
testItems[7].setState(tiereModel.elefant());
}
const auto &versteckeModel = model.verstecke();
{
auto &testItems = m_tests.at(1).items();
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
const auto &futterModel = model.futter();
{
auto &testItems = m_tests.at(2).items();
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void AkkusativModel::write(ESGRAF48::AkkusativModel &model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_katze(testItems[1].isChecked());
tiereModel->set_affe(testItems[2].isChecked());
tiereModel->set_gans(testItems[3].isChecked());
tiereModel->set_baer(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_hund(testItems[6].isChecked());
tiereModel->set_elefant(testItems[7].isChecked());
}
auto *versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
auto *futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "AkkusativModel.pb.h"
class AkkusativModel : public CheckableTestModel
{
@ -8,4 +9,7 @@ class AkkusativModel : public CheckableTestModel
public:
AkkusativModel(QObject *parent);
void read(const ESGRAF48::AkkusativModel &model);
void write(ESGRAF48::AkkusativModel &model) const;
};

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(AkkusativDativ LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,11 +11,22 @@ qt5_wrap_ui(UI_HEADERS
AkkusativDativWidget.ui
)
set(AkkusativDativ_PROTO_FILES
../../../proto/AkkusativModel.proto
../../../proto/DativModel.proto
)
protobuf_generate_cpp(AkkusativDativ_PROTO_SRCS AkkusativDativ_PROTO_HDRS
${AkkusativDativ_PROTO_FILES}
)
add_library(${PROJECT_NAME}
AkkusativDativWidget.cpp
AkkusativModel.cpp
DativModel.cpp
${UI_HEADERS}
${AkkusativDativ_PROTO_SRCS}
${AkkusativDativ_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -26,6 +38,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -34,4 +47,5 @@ target_link_libraries(${PROJECT_NAME}
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,15 +1,107 @@
#include "DativModel.h"
DativModel::DativModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "Dativ Nominalphrase", { "Tiger", "Katze", "Affe", "Gans", "Bär",
"Pferd", "Hund", "Elefant" } },
{ "Präpositionalphrase (Verstecke)",
{ "Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz",
"Baum" } },
{ "Nominalphrase (Tiere)", { "Salat", "Fleisch", "Knochen", "Banane",
"Apfel", "Karotte", "Honig", "Zucker" } }
};
m_tests = {{"Dativ Nominalphrase",
{"Tiger", "Katze", "Affe", "Gans", "Bär", "Pferd", "Hund", "Elefant"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Tiere)",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}}};
}
void DativModel::read(const ESGRAF48::DativModel &model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.katze());
testItems[2].setState(tiereModel.affe());
testItems[3].setState(tiereModel.gans());
testItems[4].setState(tiereModel.baer());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.hund());
testItems[7].setState(tiereModel.elefant());
}
const auto &versteckeModel = model.verstecke();
{
auto &testItems = m_tests.at(1).items();
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
const auto &futterModel = model.futter();
{
auto &testItems = m_tests.at(2).items();
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void DativModel::write(ESGRAF48::DativModel &model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_katze(testItems[1].isChecked());
tiereModel->set_affe(testItems[2].isChecked());
tiereModel->set_gans(testItems[3].isChecked());
tiereModel->set_baer(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_hund(testItems[6].isChecked());
tiereModel->set_elefant(testItems[7].isChecked());
}
auto *versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
auto *futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "DativModel.pb.h"
class DativModel : public CheckableTestModel
{
@ -8,4 +9,7 @@ class DativModel : public CheckableTestModel
public:
DativModel(QObject *parent);
void read(const ESGRAF48::DativModel &model);
void write(ESGRAF48::DativModel &model) const;
};

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(Genus LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,10 +11,18 @@ qt5_wrap_ui(GENUS_UI
GenusWidget.ui
)
set(Genus_PROTO_FILES
../../../proto/GenusModel.proto
)
protobuf_generate_cpp(Genus_PROTO_SRCS Genus_PROTO_HDRS ${Genus_PROTO_FILES})
add_library(${PROJECT_NAME}
GenusWidget.cpp
GenusModel.cpp
${GENUS_UI}
${Genus_PROTO_SRCS}
${Genus_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -25,6 +34,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -33,4 +43,5 @@ target_link_libraries(${PROJECT_NAME}
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,11 +1,97 @@
#include "GenusModel.h"
GenusModel::GenusModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = { { "Tiere", { "Tiger", "Bär", "Katze", "Pferd", "Gans",
"Elefant", "Affe", "Hund" } },
{ "Futter", { "Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte",
"Honig", "Zucker" } },
{ "Zirkus", { "Kiste", "Holz", "Vorhang", "Baum" } } };
m_tests = {{"Tiere", {"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Affe", "Hund"}},
{"Futter",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}},
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
}
void GenusModel::readProtoBuf(const ESGRAF48::GenusModel &model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.baer());
testItems[2].setState(tiereModel.katze());
testItems[3].setState(tiereModel.pferd());
testItems[4].setState(tiereModel.gans());
testItems[5].setState(tiereModel.elefant());
testItems[6].setState(tiereModel.affe());
testItems[7].setState(tiereModel.hund());
}
const auto &futterModel = model.futter();
{
auto &testItems = m_tests.at(1).items();
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
const auto &zirkusModel = model.zirkus();
{
auto &testItems = m_tests.at(2).items();
testItems[0].setState(zirkusModel.kiste());
testItems[1].setState(zirkusModel.holz());
testItems[2].setState(zirkusModel.vorhang());
testItems[3].setState(zirkusModel.baum());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void GenusModel::writeProtoBuf(ESGRAF48::GenusModel &model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_baer(testItems[1].isChecked());
tiereModel->set_katze(testItems[2].isChecked());
tiereModel->set_pferd(testItems[3].isChecked());
tiereModel->set_gans(testItems[4].isChecked());
tiereModel->set_elefant(testItems[5].isChecked());
tiereModel->set_affe(testItems[6].isChecked());
tiereModel->set_hund(testItems[7].isChecked());
}
auto *futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
auto *zirkusModel = model.mutable_zirkus();
if (zirkusModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
zirkusModel->set_kiste(testItems[0].isChecked());
zirkusModel->set_holz(testItems[1].isChecked());
zirkusModel->set_vorhang(testItems[2].isChecked());
zirkusModel->set_baum(testItems[3].isChecked());
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "GenusModel.pb.h"
class GenusModel : public CheckableTestModel
{
@ -8,4 +9,7 @@ class GenusModel : public CheckableTestModel
public:
GenusModel(QObject *parent);
void readProtoBuf(const ESGRAF48::GenusModel &model);
void writeProtoBuf(ESGRAF48::GenusModel &model) const;
};

View File

@ -3,18 +3,30 @@ cmake_minimum_required(VERSION 3.6)
project(LateSkills LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
qt5_wrap_ui(UI_HEADERS
LateSkillsWidget.ui
LateSkillsWidget.ui
)
set(LateSkills_PROTO_FILES
../../../proto/LateSkillsGenitivModel.proto
../../../proto/LateSkillsPassivModel.proto
)
protobuf_generate_cpp(LateSkills_PROTO_SRCS LateSkills_PROTO_HDRS
${LateSkills_PROTO_FILES}
)
add_library(${PROJECT_NAME}
LateSkillsWidget.cpp
LateSkillsWidget.cpp
PassivModel.cpp
GenitivModel.cpp
${UI_HEADERS}
${LateSkills_PROTO_SRCS}
${LateSkills_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -23,15 +35,17 @@ set_target_properties(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
Qt5::Widgets
CheckableItem
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,45 +1,109 @@
#include "GenitivModel.h"
GenitivModel::GenitivModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "Genitiv Präpositionen",
{ "anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)",
"mithilfe (1)", "mithilfe (2)" } },
{ "Attributierung",
{ "Schuhe (1)", "Schuhe (2)", "Zauberstab (1)", "Zauberstab (2)",
"Hut (1)", "Hut (2)", "Brille (1)", "Brille (2)", "Gürtel (1)",
"Gürtel (2)" } },
{"Genitiv Präpositionen",
{"anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)", "mithilfe (1)",
"mithilfe (2)"}},
{"Attributierung",
{"Schuhe (1)", "Schuhe (2)", "Zauberstab (1)", "Zauberstab (2)", "Hut (1)", "Hut (2)",
"Brille (1)", "Brille (2)", "Gürtel (1)", "Gürtel (2)"}},
};
for (auto index : { 1, 3, 5 })
for (auto index : {1, 3, 5})
{
m_tests[0].items()[index].setValue(2);
}
for (auto index : { 1, 3, 5, 7, 9 })
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[1].items()[index].setValue(2);
}
}
bool GenitivModel::setData(
const QModelIndex &modelIndex, const QVariant &value, int role)
bool GenitivModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
{
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(
index(modelIndex.row(), modelIndex.column() + 1), false, role);
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(
index(modelIndex.row(), modelIndex.column() - 1), false, role);
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
return CheckableTestModel::setData(modelIndex, value, role);
}
void GenitivModel::read(const ESGRAF48::LateSkillsGenitivModel &model)
{
const auto &praepositionenModel = model.praepositionen();
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(praepositionenModel.anstelle1());
testItems[1].setState(praepositionenModel.anstelle2());
testItems[2].setState(praepositionenModel.ausserhalb1());
testItems[3].setState(praepositionenModel.ausserhalb2());
testItems[4].setState(praepositionenModel.mithilfe1());
testItems[5].setState(praepositionenModel.mithilfe2());
}
const auto &attributierungModel = model.attributierung();
{
auto &testItems = m_tests.at(1).items();
testItems[0].setState(attributierungModel.schuhe1());
testItems[1].setState(attributierungModel.schuhe2());
testItems[2].setState(attributierungModel.zauberstab1());
testItems[3].setState(attributierungModel.zauberstab2());
testItems[4].setState(attributierungModel.hut1());
testItems[5].setState(attributierungModel.hut2());
testItems[6].setState(attributierungModel.brille1());
testItems[7].setState(attributierungModel.brille2());
testItems[8].setState(attributierungModel.guertel1());
testItems[9].setState(attributierungModel.guertel2());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void GenitivModel::write(ESGRAF48::LateSkillsGenitivModel &model) const
{
auto *praepositionenModel = model.mutable_praepositionen();
if (praepositionenModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
praepositionenModel->set_anstelle1(testItems[0].isChecked());
praepositionenModel->set_anstelle2(testItems[1].isChecked());
praepositionenModel->set_ausserhalb1(testItems[2].isChecked());
praepositionenModel->set_ausserhalb2(testItems[3].isChecked());
praepositionenModel->set_mithilfe1(testItems[4].isChecked());
praepositionenModel->set_mithilfe2(testItems[5].isChecked());
}
auto *attributierungModel = model.mutable_attributierung();
if (attributierungModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
attributierungModel->set_schuhe1(testItems[0].isChecked());
attributierungModel->set_schuhe2(testItems[1].isChecked());
attributierungModel->set_zauberstab1(testItems[2].isChecked());
attributierungModel->set_zauberstab2(testItems[3].isChecked());
attributierungModel->set_hut1(testItems[4].isChecked());
attributierungModel->set_hut2(testItems[5].isChecked());
attributierungModel->set_brille1(testItems[6].isChecked());
attributierungModel->set_brille2(testItems[7].isChecked());
attributierungModel->set_guertel1(testItems[8].isChecked());
attributierungModel->set_guertel2(testItems[9].isChecked());
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "LateSkillsGenitivModel.pb.h"
class GenitivModel : public CheckableTestModel
{
@ -10,4 +11,7 @@ public:
GenitivModel(QObject *parent);
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
void read(const ESGRAF48::LateSkillsGenitivModel &model);
void write(ESGRAF48::LateSkillsGenitivModel &model) const;
};

View File

@ -1,35 +1,67 @@
#include "PassivModel.h"
PassivModel::PassivModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = { { "Passiv",
{ "Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)",
"Bälle (2)", "Ball (1)", "Ball (2)", "Fleisch (1)",
"Fleisch (2)" } } };
m_tests = {{"Passiv",
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
"Ball (1)", "Ball (2)", "Fleisch (1)", "Fleisch (2)"}}};
for (auto index : { 1, 3, 5, 7, 9 })
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[0].items()[index].setValue(2);
}
}
bool PassivModel::setData(
const QModelIndex &modelIndex, const QVariant &value, int role)
bool PassivModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
{
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(
index(modelIndex.row(), modelIndex.column() + 1), false, role);
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(
index(modelIndex.row(), modelIndex.column() - 1), false, role);
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
return CheckableTestModel::setData(modelIndex, value, role);
}
void PassivModel::read(const ESGRAF48::LateSkillsPassivModel &model)
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(model.elefant1());
testItems[1].setState(model.elefant2());
testItems[2].setState(model.pferde1());
testItems[3].setState(model.pferde2());
testItems[4].setState(model.baelle1());
testItems[5].setState(model.baelle2());
testItems[6].setState(model.ball1());
testItems[7].setState(model.ball2());
testItems[8].setState(model.fleisch1());
testItems[9].setState(model.fleisch2());
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void PassivModel::write(ESGRAF48::LateSkillsPassivModel &model) const
{
const auto &testItems = m_tests.at(0).items();
model.set_elefant1(testItems[0].isChecked());
model.set_elefant2(testItems[1].isChecked());
model.set_pferde1(testItems[2].isChecked());
model.set_pferde2(testItems[3].isChecked());
model.set_baelle1(testItems[4].isChecked());
model.set_baelle2(testItems[5].isChecked());
model.set_ball1(testItems[6].isChecked());
model.set_ball2(testItems[7].isChecked());
model.set_fleisch1(testItems[8].isChecked());
model.set_fleisch2(testItems[9].isChecked());
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "LateSkillsPassivModel.pb.h"
class PassivModel : public CheckableTestModel
{
@ -10,4 +11,7 @@ public:
PassivModel(QObject *parent);
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
void read(const ESGRAF48::LateSkillsPassivModel &model);
void write(ESGRAF48::LateSkillsPassivModel &model) const;
};

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(Plural LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,10 +11,18 @@ qt5_wrap_ui(UI_HEADERS
PluralWidget.ui
)
set(Plural_PROTO_FILES
../../../proto/PluralModel.proto
)
protobuf_generate_cpp(Plural_PROTO_SRCS Plural_PROTO_HDRS ${Plural_PROTO_FILES})
add_library(${PROJECT_NAME}
PluralWidget.cpp
PluralModel.cpp
${UI_HEADERS}
${Plural_PROTO_SRCS}
${Plural_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -25,6 +34,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -33,4 +43,5 @@ target_link_libraries(${PROJECT_NAME}
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -3,20 +3,51 @@
#include <QSize>
PluralModel::PluralModel(QObject *parent)
: CheckableTestModel(parent)
: CheckableTestModel(parent)
{
m_tests = { { "",
{ "Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML" } } };
m_tests = {{"",
{"Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML"}}};
}
QVariant PluralModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::SizeHintRole)
{
return QSize(180, 0);
}
if (role == Qt::SizeHintRole)
{
return QSize(180, 0);
}
return CheckableTestModel::data(index, role);
return CheckableTestModel::data(index, role);
}
void PluralModel::read(const ESGRAF48::PluralModel &model)
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(model.fisch());
testItems[1].setState(model.banane());
testItems[2].setState(model.bonbon());
testItems[3].setState(model.ei());
testItems[4].setState(model.eimer());
testItems[5].setState(model.korn());
testItems[6].setState(model.nuss());
testItems[7].setState(model.baer());
testItems[8].setState(model.apfel());
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void PluralModel::write(ESGRAF48::PluralModel &model) const
{
const auto &testItems = m_tests.at(0).items();
model.set_fisch(testItems[0].isChecked());
model.set_banane(testItems[1].isChecked());
model.set_bonbon(testItems[2].isChecked());
model.set_ei(testItems[3].isChecked());
model.set_eimer(testItems[4].isChecked());
model.set_korn(testItems[5].isChecked());
model.set_nuss(testItems[6].isChecked());
model.set_baer(testItems[7].isChecked());
model.set_apfel(testItems[8].isChecked());
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "PluralModel.pb.h"
class PluralModel : public CheckableTestModel
{
@ -11,4 +12,7 @@ public:
QVariant data(
const QModelIndex &index, int role = Qt::DisplayRole) const override;
void read(const ESGRAF48::PluralModel &model);
void write(ESGRAF48::PluralModel &model) const;
};

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(V2Svk LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,10 +11,18 @@ qt5_wrap_ui(UI_HEADERS
V2SvkWidget.ui
)
set(V2Svk_PROTO_FILES
../../../proto/V2SvkModel.proto
)
protobuf_generate_cpp(V2Svk_PROTO_SRCS V2Svk_PROTO_HDRS ${V2Svk_PROTO_FILES})
add_library(${PROJECT_NAME}
V2SvkWidget.cpp
V2SvkModel.cpp
${UI_HEADERS}
${V2Svk_PROTO_SRCS}
${V2Svk_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -25,6 +34,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -33,4 +43,5 @@ target_link_libraries(${PROJECT_NAME}
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,46 +1,39 @@
#include "V2SvkModel.h"
V2SvkModel::V2SvkModel(QObject *parent)
: CheckableTestModel(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"} },
{"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"} },
{"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 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" } },
{"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()
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : { 0, 1, 3, 5, 7, 8 })
for (auto testIndex : {0, 1, 3, 5, 7, 8})
{
const auto &test = m_tests.at(testIndex);
@ -58,9 +51,9 @@ unsigned int V2SvkModel::getV2Points()
unsigned int V2SvkModel::getSvkPoints()
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : { 2, 4, 6, 9, 10 })
for (auto testIndex : {2, 4, 6, 9, 10})
{
const auto &test = m_tests.at(testIndex);
@ -75,3 +68,134 @@ unsigned int V2SvkModel::getSvkPoints()
return points;
}
bool V2SvkModel::isValidIndex(const QModelIndex &index) const
{
switch (index.row())
{
case 1:
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);
}
}
void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
{
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
modelData->set_affe(testItems[1].isChecked());
modelData->set_schwein(testItems[7].isChecked());
modelData->set_gans(testItems[10].isChecked());
}
};
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());
}
};
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach *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_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
writeFourVals(model.mutable_wfrage(), 0);
writeOneVal(model.mutable_verbtrennung1(), 1);
writeFourVals(model.mutable_svkst(), 2);
writeFourVals(model.mutable_objtop(), 3);
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::readProtoBuf(const ESGRAF48::V2SvkModel &model)
{
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
testItems[1].setState(modelData.affe());
testItems[7].setState(modelData.schwein());
testItems[10].setState(modelData.gans());
};
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());
};
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
readFourVals(model.wfrage(), 0);
readOneVal(model.verbtrennung1(), 1);
readFourVals(model.svkst(), 2);
readFourVals(model.objtop(), 3);
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));
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "V2SvkModel.pb.h"
class V2SvkModel : public CheckableTestModel
{
@ -11,4 +12,10 @@ public:
unsigned int getV2Points();
unsigned int getSvkPoints();
void writeProtoBuf(ESGRAF48::V2SvkModel &model) const;
void readProtoBuf(const ESGRAF48::V2SvkModel &model);
protected:
bool isValidIndex(const QModelIndex &index) const override;
};

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
project(VerbEnd LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
set(CMAKE_AUTOMOC ON)
@ -10,10 +11,18 @@ qt5_wrap_ui(UI_HEADERS
VerbEndWidget.ui
)
set(VerbEnd_PROTO_FILES
../../../proto/VerbEndModel.proto
)
protobuf_generate_cpp(VerbEnd_PROTO_SRCS VerbEnd_PROTO_HDRS ${VerbEnd_PROTO_FILES})
add_library(${PROJECT_NAME}
VerbEndWidget.cpp
VerbEndModel.cpp
${UI_HEADERS}
${VerbEnd_PROTO_SRCS}
${VerbEnd_PROTO_HDRS}
)
set_target_properties(${PROJECT_NAME}
@ -25,6 +34,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${Protobuf_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
@ -33,4 +43,5 @@ target_link_libraries(${PROJECT_NAME}
CheckableTest
CheckableTestModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -11,3 +11,90 @@ VerbEndModel::VerbEndModel(QObject *parent)
{ "Zauberregel", { "Temporal", "Kausal", "Final", "Relativ",
"Temporal", "Relativ" } } };
}
void VerbEndModel::writeProtoBuf(ESGRAF48::VerbEndModel &model) const
{
auto *telefonatModel = model.mutable_telefonat();
if (telefonatModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
telefonatModel->set_kausal1(testItems[0].isChecked());
telefonatModel->set_kausal2(testItems[1].isChecked());
telefonatModel->set_relativ(testItems[2].isChecked());
telefonatModel->set_kausal3(testItems[3].isChecked());
telefonatModel->set_final(testItems[4].isChecked());
telefonatModel->set_temporal1(testItems[5].isChecked());
telefonatModel->set_temporal2(testItems[6].isChecked());
}
auto *zaubertrickModel = model.mutable_zaubertrick();
if (zaubertrickModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
zaubertrickModel->set_relativ(testItems[0].isChecked());
zaubertrickModel->set_final1(testItems[1].isChecked());
zaubertrickModel->set_kausal1(testItems[2].isChecked());
zaubertrickModel->set_final2(testItems[3].isChecked());
zaubertrickModel->set_temporal1(testItems[4].isChecked());
zaubertrickModel->set_kausal2(testItems[5].isChecked());
zaubertrickModel->set_temporal2(testItems[6].isChecked());
}
auto *zauberregelModel = model.mutable_zauberregel();
if (zauberregelModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
zauberregelModel->set_temporal1(testItems[0].isChecked());
zauberregelModel->set_kausal(testItems[1].isChecked());
zauberregelModel->set_final(testItems[2].isChecked());
zauberregelModel->set_relativ1(testItems[3].isChecked());
zauberregelModel->set_temporal2(testItems[4].isChecked());
zauberregelModel->set_relativ2(testItems[5].isChecked());
}
}
void VerbEndModel::readProtoBuf(const ESGRAF48::VerbEndModel &model)
{
const auto &telefonatModel = model.telefonat();
{
auto &testItems = m_tests.at(0).items();
testItems[0].setState(telefonatModel.kausal1());
testItems[1].setState(telefonatModel.kausal2());
testItems[2].setState(telefonatModel.relativ());
testItems[3].setState(telefonatModel.kausal3());
testItems[4].setState(telefonatModel.final());
testItems[5].setState(telefonatModel.temporal1());
testItems[6].setState(telefonatModel.temporal2());
}
const auto &zaubertrickModel = model.zaubertrick();
{
auto &testItems = m_tests.at(1).items();
testItems[0].setState(zaubertrickModel.relativ());
testItems[1].setState(zaubertrickModel.final1());
testItems[2].setState(zaubertrickModel.kausal1());
testItems[3].setState(zaubertrickModel.final2());
testItems[4].setState(zaubertrickModel.temporal1());
testItems[5].setState(zaubertrickModel.kausal2());
testItems[6].setState(zaubertrickModel.temporal2());
}
const auto &zauberregelModel = model.zauberregel();
{
auto &testItems = m_tests.at(2).items();
testItems[0].setState(zauberregelModel.temporal1());
testItems[1].setState(zauberregelModel.kausal());
testItems[2].setState(zauberregelModel.final());
testItems[3].setState(zauberregelModel.relativ1());
testItems[4].setState(zauberregelModel.temporal2());
testItems[5].setState(zauberregelModel.relativ2());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "CheckableTestModel.h"
#include "VerbEndModel.pb.h"
class VerbEndModel : public CheckableTestModel
{
@ -8,4 +9,7 @@ class VerbEndModel : public CheckableTestModel
public:
VerbEndModel(QObject *parent);
void writeProtoBuf(ESGRAF48::VerbEndModel &model) const;
void readProtoBuf(const ESGRAF48::VerbEndModel &model);
};

View File

@ -16,6 +16,8 @@
#include <QDebug>
#include <fstream>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
@ -72,17 +74,8 @@ void MainWindow::openFile()
closeFile();
QFile loadFile(filename);
if (!loadFile.open(QFile::ReadOnly))
{
qWarning("Could not open file");
return;
}
QByteArray byteData = loadFile.readAll();
QJsonDocument loadDoc = QJsonDocument::fromJson(byteData);
m_dataModel->read(loadDoc.object());
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
m_dataModel->readProtoBuf(protoInFile);
setWindowModified(false);
setWindowTitle(filename + "[*]");
@ -135,6 +128,9 @@ void MainWindow::closeFile()
void MainWindow::print() const
{
//std::ofstream htmlfile("print.html");
//htmlfile << m_dataModel->toHtml();
QPrinter printer;
QPrintDialog dialog(&printer);
@ -144,12 +140,7 @@ void MainWindow::print() const
}
QTextDocument printDoc;
printDoc.setHtml(
"<html>"
"<body>"
"<h2>Hello World</h2>"
"</body>"
"</hthml>");
printDoc.setHtml(QString::fromStdString(m_dataModel->toHtml()));
printDoc.print(&printer);
}
@ -167,15 +158,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::saveFile(const QString &filename)
{
QJsonObject saveData;
m_dataModel->write(saveData);
QJsonDocument saveDoc(saveData);
QFile saveFile(filename);
saveFile.open(QFile::WriteOnly);
saveFile.write(saveDoc.toJson());
saveFile.close();
std::fstream protoOutFile(filename.toStdString(),
std::ios::out | std::ios::trunc | std::ios::binary);
m_dataModel->writeProtoBuf(protoOutFile);
qDebug() << "Wrote" << filename;