Ported late skills to protobuf, added changed-messages
This commit is contained in:
parent
87c9b0e74a
commit
f6b283b3a1
14 changed files with 222 additions and 36 deletions
|
@ -9,6 +9,8 @@ import "GenusModel.proto";
|
|||
import "AkkusativModel.proto";
|
||||
import "DativModel.proto";
|
||||
import "PluralModel.proto";
|
||||
import "LateSkillsGenitivModel.proto";
|
||||
import "LateSkillsPassivModel.proto";
|
||||
|
||||
message DataModel
|
||||
{
|
||||
|
@ -19,4 +21,6 @@ message DataModel
|
|||
AkkusativModel Akkusativ = 5;
|
||||
DativModel Dativ = 6;
|
||||
PluralModel Plural = 7;
|
||||
LateSkillsGenitivModel LateSkillsGenitiv = 8;
|
||||
LateSkillsPassivModel LateSkillsPassiv = 9;
|
||||
}
|
||||
|
|
33
proto/LateSkillsGenitivModel.proto
Normal file
33
proto/LateSkillsGenitivModel.proto
Normal 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;
|
||||
}
|
17
proto/LateSkillsPassivModel.proto
Normal file
17
proto/LateSkillsPassivModel.proto
Normal 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;
|
||||
}
|
|
@ -26,6 +26,8 @@ set(DataModel_PROTO_FILES
|
|||
../proto/AkkusativModel.proto
|
||||
../proto/DativModel.proto
|
||||
../proto/PluralModel.proto
|
||||
../proto/LateSkillsPassivModel.proto
|
||||
../proto/LateSkillsGenitivModel.proto
|
||||
)
|
||||
|
||||
protobuf_generate_cpp(DataModel_PROTO_SRCS DataModel_PROTO_HDRS
|
||||
|
|
|
@ -38,6 +38,8 @@ void DataModel::writeProtoBuf(std::ostream &outStream) const
|
|||
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);
|
||||
}
|
||||
|
@ -54,6 +56,8 @@ void DataModel::readProtoBuf(std::istream &inStream)
|
|||
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
|
||||
|
|
|
@ -54,6 +54,8 @@ void AkkusativModel::read(const ESGRAF48::AkkusativModel &model)
|
|||
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
|
||||
|
|
|
@ -54,6 +54,8 @@ void DativModel::read(const ESGRAF48::DativModel &model)
|
|||
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
|
||||
|
|
|
@ -48,6 +48,8 @@ void GenusModel::readProtoBuf(const ESGRAF48::GenusModel &model)
|
|||
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
|
||||
|
|
|
@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
|
|||
project(LateSkills LANGUAGES CXX)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Protobuf REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
|
@ -10,11 +11,22 @@ qt5_wrap_ui(UI_HEADERS
|
|||
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
|
||||
PassivModel.cpp
|
||||
GenitivModel.cpp
|
||||
${UI_HEADERS}
|
||||
${LateSkills_PROTO_SRCS}
|
||||
${LateSkills_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}
|
||||
)
|
||||
|
|
|
@ -5,12 +5,11 @@ GenitivModel::GenitivModel(QObject *parent)
|
|||
{
|
||||
m_tests = {
|
||||
{"Genitiv Präpositionen",
|
||||
{ "anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)",
|
||||
"mithilfe (1)", "mithilfe (2)" } },
|
||||
{"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)" } },
|
||||
{"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})
|
||||
|
@ -24,22 +23,87 @@ GenitivModel::GenitivModel(QObject *parent)
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -4,9 +4,8 @@ PassivModel::PassivModel(QObject *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)" } } };
|
||||
{"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})
|
||||
{
|
||||
|
@ -14,22 +13,55 @@ PassivModel::PassivModel(QObject *parent)
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -33,6 +33,8 @@ void PluralModel::read(const ESGRAF48::PluralModel &model)
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue