Merge pull request #17 from mandlm/develop

Develop
feature/qt-as-conan-package
mandlm 2018-11-21 08:28:52 +01:00 committed by GitHub
commit a444551e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 41 additions and 30 deletions

View File

@ -2,4 +2,7 @@ cmake_minimum_required(VERSION 3.5)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_subdirectory(source)

8
conanfile.txt Normal file
View File

@ -0,0 +1,8 @@
[requires]
protobuf/3.6.1@bincrafters/stable
[generators]
cmake
[options]
protobuf:shared=True

View File

@ -27,14 +27,14 @@ DataModel::DataModel(QObject *parent)
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;
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_metaData.write(*dataModel.mutable_metadata());
m_v2Svk.write(*dataModel.mutable_v2svk());
m_verbEnd.write(*dataModel.mutable_verbend());
m_genus.write(*dataModel.mutable_genus());
m_akkusativ.write(*dataModel.mutable_akkusativ());
m_dativ.write(*dataModel.mutable_dativ());
m_plural.write(*dataModel.mutable_plural());
@ -44,15 +44,15 @@ void DataModel::writeProtoBuf(std::ostream &outStream) const
dataModel.SerializeToOstream(&outStream);
}
void DataModel::readProtoBuf(std::istream &inStream)
void DataModel::read(std::istream &inStream)
{
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_metaData.read(dataModel.metadata());
m_v2Svk.read(dataModel.v2svk());
m_verbEnd.read(dataModel.verbend());
m_genus.read(dataModel.genus());
m_akkusativ.read(dataModel.akkusativ());
m_dativ.read(dataModel.dativ());
m_plural.read(dataModel.plural());

View File

@ -36,8 +36,8 @@ public:
std::string toHtml() const;
void writeProtoBuf(std::ostream &outStream) const;
void readProtoBuf(std::istream &inStream);
void write(std::ostream &outStream) const;
void read(std::istream &inStream);
signals:
void modelChanged();

View File

@ -112,7 +112,7 @@ bool MetaDataModel::setData(const QModelIndex &modelIndex, const QVariant &value
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, 1), QString::fromStdString(model.instructorname()));
@ -121,7 +121,7 @@ void MetaDataModel::readProtoBuf(const ESGRAF48::MetaDataModel &model)
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_instructorname(m_instructor.toStdString());

View File

@ -30,8 +30,8 @@ public:
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
void readProtoBuf(const ESGRAF48::MetaDataModel &model);
void writeProtoBuf(ESGRAF48::MetaDataModel &model) const;
void read(const ESGRAF48::MetaDataModel &model);
void write(ESGRAF48::MetaDataModel &model) const;
std::string toHtml() const;

View File

@ -9,7 +9,7 @@ GenusModel::GenusModel(QObject *parent)
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
}
void GenusModel::readProtoBuf(const ESGRAF48::GenusModel &model)
void GenusModel::read(const ESGRAF48::GenusModel &model)
{
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));
}
void GenusModel::writeProtoBuf(ESGRAF48::GenusModel &model) const
void GenusModel::write(ESGRAF48::GenusModel &model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)

View File

@ -10,6 +10,6 @@ class GenusModel : public CheckableTestModel
public:
GenusModel(QObject *parent);
void readProtoBuf(const ESGRAF48::GenusModel &model);
void writeProtoBuf(ESGRAF48::GenusModel &model) const;
void read(const ESGRAF48::GenusModel &model);
void write(ESGRAF48::GenusModel &model) const;
};

View File

@ -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) {
if (modelData != nullptr)
@ -147,7 +147,7 @@ void V2SvkModel::writeProtoBuf(ESGRAF48::V2SvkModel &model) const
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 &testItems = m_tests.at(testIndex).items();

View File

@ -13,8 +13,8 @@ public:
unsigned int getV2Points();
unsigned int getSvkPoints();
void writeProtoBuf(ESGRAF48::V2SvkModel &model) const;
void readProtoBuf(const ESGRAF48::V2SvkModel &model);
void write(ESGRAF48::V2SvkModel &model) const;
void read(const ESGRAF48::V2SvkModel &model);
protected:
bool isValidIndex(const QModelIndex &index) const override;

View File

@ -12,7 +12,7 @@ VerbEndModel::VerbEndModel(QObject *parent)
"Temporal", "Relativ" } } };
}
void VerbEndModel::writeProtoBuf(ESGRAF48::VerbEndModel &model) const
void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const
{
auto *telefonatModel = model.mutable_telefonat();
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();
{

View File

@ -10,6 +10,6 @@ class VerbEndModel : public CheckableTestModel
public:
VerbEndModel(QObject *parent);
void writeProtoBuf(ESGRAF48::VerbEndModel &model) const;
void readProtoBuf(const ESGRAF48::VerbEndModel &model);
void write(ESGRAF48::VerbEndModel &model) const;
void read(const ESGRAF48::VerbEndModel &model);
};

View File

@ -75,7 +75,7 @@ void MainWindow::openFile()
closeFile();
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
m_dataModel->readProtoBuf(protoInFile);
m_dataModel->read(protoInFile);
setWindowModified(false);
setWindowTitle(filename + "[*]");
@ -160,7 +160,7 @@ void MainWindow::saveFile(const QString &filename)
{
std::fstream protoOutFile(filename.toStdString(),
std::ios::out | std::ios::trunc | std::ios::binary);
m_dataModel->writeProtoBuf(protoOutFile);
m_dataModel->write(protoOutFile);
qDebug() << "Wrote" << filename;