Finished V2Svk model protobuf serialization
This commit is contained in:
parent
221368b3ca
commit
ff615ec084
2 changed files with 123 additions and 85 deletions
|
@ -63,10 +63,6 @@ void DataModel::writeProtoBuf(std::ostream &outStream) const
|
||||||
//m_metaData.writeProtoBuf(dataModel.mutable_metadata);
|
//m_metaData.writeProtoBuf(dataModel.mutable_metadata);
|
||||||
m_v2Svk.writeProtoBuf(*dataModel.mutable_v2svk());
|
m_v2Svk.writeProtoBuf(*dataModel.mutable_v2svk());
|
||||||
dataModel.SerializeToOstream(&outStream);
|
dataModel.SerializeToOstream(&outStream);
|
||||||
|
|
||||||
std::string saveData;
|
|
||||||
google::protobuf::TextFormat::PrintToString(dataModel, &saveData);
|
|
||||||
qDebug() << "Wrote:" << QString::fromStdString(saveData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModel::readProtoBuf(std::istream &inStream)
|
void DataModel::readProtoBuf(std::istream &inStream)
|
||||||
|
|
|
@ -5,34 +5,27 @@ V2SvkModel::V2SvkModel(QObject *parent)
|
||||||
{
|
{
|
||||||
m_tests = {
|
m_tests = {
|
||||||
{"W-Frage",
|
{"W-Frage",
|
||||||
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
|
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
||||||
"Gans" , "Gans", "Gans", "Gans"} },
|
"Gans", "Gans", "Gans"}},
|
||||||
{ "Verbtrennung",
|
{"Verbtrennung", {"", "Affe", "", "", "", "", "", "Schwein", "", "", "Gans", ""}},
|
||||||
{ "", "Affe", "", "", "", "", "", "Schwein", "" , "", "Gans", ""} },
|
|
||||||
{"SVK: /-st/",
|
{"SVK: /-st/",
|
||||||
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
|
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
||||||
"Gans" , "Gans", "Gans", "Gans"} },
|
"Gans", "Gans", "Gans"}},
|
||||||
|
|
||||||
{"Objekt-Topikalisierung",
|
{"Objekt-Topikalisierung",
|
||||||
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
|
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
||||||
"Gans" , "Gans", "Gans", "Gans"} },
|
"Gans", "Gans", "Gans"}},
|
||||||
{"SVK: Stamm",
|
{"SVK: Stamm",
|
||||||
{ "Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein",
|
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
||||||
"Gans" , "Gans", "Gans", "Gans"} },
|
"Gans", "Gans", "Gans"}},
|
||||||
|
|
||||||
{ "Temporaladverb Präsens",
|
{"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
{"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "SKV: /-e/ o. Stamm",
|
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
|
||||||
|
|
||||||
{ "Temporaladverb Perfekt",
|
{"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
{"Verbtrennung", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "Verbtrennung",
|
{"SVK: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
{"Partizip", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
|
||||||
{ "SVK: /-e/ o. Stamm",
|
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
|
||||||
{ "Partizip",
|
|
||||||
{ "Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans" } },
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,64 +71,113 @@ unsigned int V2SvkModel::getSvkPoints()
|
||||||
|
|
||||||
void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
|
void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
|
||||||
{
|
{
|
||||||
auto *wfrage = model.mutable_wfrage();
|
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) {
|
||||||
if (wfrage != nullptr)
|
if (modelData != nullptr)
|
||||||
{
|
{
|
||||||
const auto &items = m_tests.at(0).items();
|
const auto &testItems = m_tests.at(testIndex).items();
|
||||||
|
|
||||||
wfrage->set_affe1(items[0].isChecked());
|
modelData->set_affe(testItems[1].isChecked());
|
||||||
wfrage->set_affe2(items[1].isChecked());
|
modelData->set_schwein(testItems[7].isChecked());
|
||||||
wfrage->set_affe3(items[2].isChecked());
|
modelData->set_gans(testItems[10].isChecked());
|
||||||
wfrage->set_affe4(items[3].isChecked());
|
|
||||||
wfrage->set_schwein1(items[4].isChecked());
|
|
||||||
wfrage->set_schwein2(items[5].isChecked());
|
|
||||||
wfrage->set_schwein3(items[6].isChecked());
|
|
||||||
wfrage->set_schwein4(items[7].isChecked());
|
|
||||||
wfrage->set_gans1(items[8].isChecked());
|
|
||||||
wfrage->set_gans2(items[9].isChecked());
|
|
||||||
wfrage->set_gans3(items[10].isChecked());
|
|
||||||
wfrage->set_gans4(items[11].isChecked());
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto *verbtrennung = model.mutable_verbtrennung1();
|
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach *modelData, int testIndex) {
|
||||||
if (verbtrennung != nullptr)
|
if (modelData != nullptr)
|
||||||
{
|
{
|
||||||
const auto &testItems = m_tests.at(1).items();
|
const auto &testItems = m_tests.at(testIndex).items();
|
||||||
|
|
||||||
verbtrennung->set_affe(testItems[1].isChecked());
|
modelData->set_affe1(testItems[0].isChecked());
|
||||||
verbtrennung->set_schwein(testItems[7].isChecked());
|
modelData->set_affe2(testItems[1].isChecked());
|
||||||
verbtrennung->set_gans(testItems[10].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)
|
void V2SvkModel::readProtoBuf(const ESGRAF48::V2SvkModel &model)
|
||||||
{
|
{
|
||||||
const auto &wfrage = model.wfrage();
|
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) {
|
||||||
{
|
auto &testItems = m_tests.at(testIndex).items();
|
||||||
auto &testItems = m_tests.at(0).items();
|
|
||||||
|
|
||||||
testItems[0].setState(wfrage.affe1());
|
testItems[1].setState(modelData.affe());
|
||||||
testItems[1].setState(wfrage.affe2());
|
testItems[7].setState(modelData.schwein());
|
||||||
testItems[2].setState(wfrage.affe3());
|
testItems[10].setState(modelData.gans());
|
||||||
testItems[3].setState(wfrage.affe4());
|
};
|
||||||
testItems[4].setState(wfrage.schwein1());
|
|
||||||
testItems[5].setState(wfrage.schwein2());
|
|
||||||
testItems[6].setState(wfrage.schwein3());
|
|
||||||
testItems[7].setState(wfrage.schwein4());
|
|
||||||
testItems[8].setState(wfrage.gans1());
|
|
||||||
testItems[9].setState(wfrage.gans2());
|
|
||||||
testItems[10].setState(wfrage.gans3());
|
|
||||||
testItems[11].setState(wfrage.gans4());
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &verbtrennung = model.verbtrennung1();
|
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) {
|
||||||
{
|
auto &testItems = m_tests.at(testIndex).items();
|
||||||
auto &testItems = m_tests.at(1).items();
|
|
||||||
|
|
||||||
testItems[1].setState(verbtrennung.affe());
|
testItems[0].setState(modelData.affe1());
|
||||||
testItems[7].setState(verbtrennung.schwein());
|
testItems[1].setState(modelData.affe2());
|
||||||
testItems[10].setState(verbtrennung.gans());
|
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));
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue