Renamed read/writeProtoBuf to read/write
This commit is contained in:
parent
6f35ffda7f
commit
ef5686e83e
11 changed files with 30 additions and 30 deletions
|
@ -27,14 +27,14 @@ DataModel::DataModel(QObject *parent)
|
||||||
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
|
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModel::writeProtoBuf(std::ostream &outStream) const
|
void DataModel::write(std::ostream &outStream) const
|
||||||
{
|
{
|
||||||
ESGRAF48::DataModel dataModel;
|
ESGRAF48::DataModel dataModel;
|
||||||
|
|
||||||
m_metaData.writeProtoBuf(*dataModel.mutable_metadata());
|
m_metaData.write(*dataModel.mutable_metadata());
|
||||||
m_v2Svk.writeProtoBuf(*dataModel.mutable_v2svk());
|
m_v2Svk.write(*dataModel.mutable_v2svk());
|
||||||
m_verbEnd.writeProtoBuf(*dataModel.mutable_verbend());
|
u_verbEnd.write(*dataModel.mutable_verbend());
|
||||||
m_genus.writeProtoBuf(*dataModel.mutable_genus());
|
m_genus.write(*dataModel.mutable_genus());
|
||||||
m_akkusativ.write(*dataModel.mutable_akkusativ());
|
m_akkusativ.write(*dataModel.mutable_akkusativ());
|
||||||
m_dativ.write(*dataModel.mutable_dativ());
|
m_dativ.write(*dataModel.mutable_dativ());
|
||||||
m_plural.write(*dataModel.mutable_plural());
|
m_plural.write(*dataModel.mutable_plural());
|
||||||
|
@ -44,15 +44,15 @@ void DataModel::writeProtoBuf(std::ostream &outStream) const
|
||||||
dataModel.SerializeToOstream(&outStream);
|
dataModel.SerializeToOstream(&outStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModel::readProtoBuf(std::istream &inStream)
|
void DataModel::read(std::istream &inStream)
|
||||||
{
|
{
|
||||||
ESGRAF48::DataModel dataModel;
|
ESGRAF48::DataModel dataModel;
|
||||||
dataModel.ParseFromIstream(&inStream);
|
dataModel.ParseFromIstream(&inStream);
|
||||||
|
|
||||||
m_metaData.readProtoBuf(dataModel.metadata());
|
m_metaData.read(dataModel.metadata());
|
||||||
m_v2Svk.readProtoBuf(dataModel.v2svk());
|
m_v2Svk.read(dataModel.v2svk());
|
||||||
m_verbEnd.readProtoBuf(dataModel.verbend());
|
m_verbEnd.read(dataModel.verbend());
|
||||||
m_genus.readProtoBuf(dataModel.genus());
|
m_genus.read(dataModel.genus());
|
||||||
m_akkusativ.read(dataModel.akkusativ());
|
m_akkusativ.read(dataModel.akkusativ());
|
||||||
m_dativ.read(dataModel.dativ());
|
m_dativ.read(dataModel.dativ());
|
||||||
m_plural.read(dataModel.plural());
|
m_plural.read(dataModel.plural());
|
||||||
|
|
|
@ -36,8 +36,8 @@ public:
|
||||||
|
|
||||||
std::string toHtml() const;
|
std::string toHtml() const;
|
||||||
|
|
||||||
void writeProtoBuf(std::ostream &outStream) const;
|
void write(std::ostream &outStream) const;
|
||||||
void readProtoBuf(std::istream &inStream);
|
void read(std::istream &inStream);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modelChanged();
|
void modelChanged();
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool MetaDataModel::setData(const QModelIndex &modelIndex, const QVariant &value
|
||||||
return valueChanged;
|
return valueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaDataModel::readProtoBuf(const ESGRAF48::MetaDataModel &model)
|
void MetaDataModel::read(const ESGRAF48::MetaDataModel &model)
|
||||||
{
|
{
|
||||||
setData(index(0, 0), QString::fromStdString(model.participantname()));
|
setData(index(0, 0), QString::fromStdString(model.participantname()));
|
||||||
setData(index(0, 1), QString::fromStdString(model.instructorname()));
|
setData(index(0, 1), QString::fromStdString(model.instructorname()));
|
||||||
|
@ -121,7 +121,7 @@ void MetaDataModel::readProtoBuf(const ESGRAF48::MetaDataModel &model)
|
||||||
setData(index(0, 4), QString::fromStdString(model.remarks()));
|
setData(index(0, 4), QString::fromStdString(model.remarks()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaDataModel::writeProtoBuf(ESGRAF48::MetaDataModel &model) const
|
void MetaDataModel::write(ESGRAF48::MetaDataModel &model) const
|
||||||
{
|
{
|
||||||
model.set_participantname(m_participant.toStdString());
|
model.set_participantname(m_participant.toStdString());
|
||||||
model.set_instructorname(m_instructor.toStdString());
|
model.set_instructorname(m_instructor.toStdString());
|
||||||
|
|
|
@ -30,8 +30,8 @@ public:
|
||||||
bool setData(const QModelIndex &index, const QVariant &value,
|
bool setData(const QModelIndex &index, const QVariant &value,
|
||||||
int role = Qt::EditRole) override;
|
int role = Qt::EditRole) override;
|
||||||
|
|
||||||
void readProtoBuf(const ESGRAF48::MetaDataModel &model);
|
void read(const ESGRAF48::MetaDataModel &model);
|
||||||
void writeProtoBuf(ESGRAF48::MetaDataModel &model) const;
|
void write(ESGRAF48::MetaDataModel &model) const;
|
||||||
|
|
||||||
std::string toHtml() const;
|
std::string toHtml() const;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ GenusModel::GenusModel(QObject *parent)
|
||||||
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
|
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenusModel::readProtoBuf(const ESGRAF48::GenusModel &model)
|
void GenusModel::read(const ESGRAF48::GenusModel &model)
|
||||||
{
|
{
|
||||||
const auto &tiereModel = model.tiere();
|
const auto &tiereModel = model.tiere();
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ void GenusModel::readProtoBuf(const ESGRAF48::GenusModel &model)
|
||||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenusModel::writeProtoBuf(ESGRAF48::GenusModel &model) const
|
void GenusModel::write(ESGRAF48::GenusModel &model) const
|
||||||
{
|
{
|
||||||
auto *tiereModel = model.mutable_tiere();
|
auto *tiereModel = model.mutable_tiere();
|
||||||
if (tiereModel != nullptr)
|
if (tiereModel != nullptr)
|
||||||
|
|
|
@ -10,6 +10,6 @@ class GenusModel : public CheckableTestModel
|
||||||
public:
|
public:
|
||||||
GenusModel(QObject *parent);
|
GenusModel(QObject *parent);
|
||||||
|
|
||||||
void readProtoBuf(const ESGRAF48::GenusModel &model);
|
void read(const ESGRAF48::GenusModel &model);
|
||||||
void writeProtoBuf(ESGRAF48::GenusModel &model) const;
|
void write(ESGRAF48::GenusModel &model) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool V2SvkModel::isValidIndex(const QModelIndex &index) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
|
void V2SvkModel::write(ESGRAF48::V2SvkModel &model) const
|
||||||
{
|
{
|
||||||
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) {
|
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) {
|
||||||
if (modelData != nullptr)
|
if (modelData != nullptr)
|
||||||
|
@ -147,7 +147,7 @@ void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
|
||||||
writeTwoVals(model.mutable_partizip(), 10);
|
writeTwoVals(model.mutable_partizip(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V2SvkModel::readProtoBuf(const ESGRAF48::V2SvkModel &model)
|
void V2SvkModel::read(const ESGRAF48::V2SvkModel &model)
|
||||||
{
|
{
|
||||||
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) {
|
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) {
|
||||||
auto &testItems = m_tests.at(testIndex).items();
|
auto &testItems = m_tests.at(testIndex).items();
|
||||||
|
|
|
@ -13,8 +13,8 @@ public:
|
||||||
unsigned int getV2Points();
|
unsigned int getV2Points();
|
||||||
unsigned int getSvkPoints();
|
unsigned int getSvkPoints();
|
||||||
|
|
||||||
void writeProtoBuf(ESGRAF48::V2SvkModel &model) const;
|
void write(ESGRAF48::V2SvkModel &model) const;
|
||||||
void readProtoBuf(const ESGRAF48::V2SvkModel &model);
|
void read(const ESGRAF48::V2SvkModel &model);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isValidIndex(const QModelIndex &index) const override;
|
bool isValidIndex(const QModelIndex &index) const override;
|
||||||
|
|
|
@ -12,7 +12,7 @@ VerbEndModel::VerbEndModel(QObject *parent)
|
||||||
"Temporal", "Relativ" } } };
|
"Temporal", "Relativ" } } };
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerbEndModel::writeProtoBuf(ESGRAF48::VerbEndModel &model) const
|
void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const
|
||||||
{
|
{
|
||||||
auto *telefonatModel = model.mutable_telefonat();
|
auto *telefonatModel = model.mutable_telefonat();
|
||||||
if (telefonatModel != nullptr)
|
if (telefonatModel != nullptr)
|
||||||
|
@ -56,7 +56,7 @@ void VerbEndModel::writeProtoBuf(ESGRAF48::VerbEndModel &model) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerbEndModel::readProtoBuf(const ESGRAF48::VerbEndModel &model)
|
void VerbEndModel::read(const ESGRAF48::VerbEndModel &model)
|
||||||
{
|
{
|
||||||
const auto &telefonatModel = model.telefonat();
|
const auto &telefonatModel = model.telefonat();
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,6 @@ class VerbEndModel : public CheckableTestModel
|
||||||
public:
|
public:
|
||||||
VerbEndModel(QObject *parent);
|
VerbEndModel(QObject *parent);
|
||||||
|
|
||||||
void writeProtoBuf(ESGRAF48::VerbEndModel &model) const;
|
void write(ESGRAF48::VerbEndModel &model) const;
|
||||||
void readProtoBuf(const ESGRAF48::VerbEndModel &model);
|
void read(const ESGRAF48::VerbEndModel &model);
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,7 +75,7 @@ void MainWindow::openFile()
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
||||||
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||||
m_dataModel->readProtoBuf(protoInFile);
|
m_dataModel->read(protoInFile);
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle(filename + "[*]");
|
setWindowTitle(filename + "[*]");
|
||||||
|
@ -160,7 +160,7 @@ void MainWindow::saveFile(const QString &filename)
|
||||||
{
|
{
|
||||||
std::fstream protoOutFile(filename.toStdString(),
|
std::fstream protoOutFile(filename.toStdString(),
|
||||||
std::ios::out | std::ios::trunc | std::ios::binary);
|
std::ios::out | std::ios::trunc | std::ios::binary);
|
||||||
m_dataModel->writeProtoBuf(protoOutFile);
|
m_dataModel->write(protoOutFile);
|
||||||
|
|
||||||
qDebug() << "Wrote" << filename;
|
qDebug() << "Wrote" << filename;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue