Print most of the table structures

feature/qt-as-conan-package
mandlm 2019-02-03 19:53:51 +01:00
parent f895ec0c1c
commit ab862aeaf1
31 changed files with 411 additions and 203 deletions

View File

@ -18,8 +18,9 @@ target_include_directories(${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
PUBLIC
CheckableItem
CheckableTest
PRIVATE
Qt5::Core
)

View File

@ -187,3 +187,8 @@ unsigned int CheckableTestModel::getPoints() const
return points;
}
QString CheckableTestModel::getTitle() const
{
return m_title;
}

View File

@ -8,6 +8,7 @@ class CheckableTestModel : public QAbstractTableModel
Q_OBJECT
protected:
QString m_title;
CheckableTests m_tests;
public:
@ -16,17 +17,17 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(
const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
int role = Qt::DisplayRole) const override;
unsigned int getPoints() const;
QString getTitle() const;
protected:
virtual bool isValidIndex(const QModelIndex &index) const;

View File

@ -99,15 +99,38 @@ void DataModel::read(const QString &filename)
m_genitiv.read(dataModel.lateskillsgenitiv());
m_passiv.read(dataModel.lateskillspassiv());
}
void DataModel::printTo(QPainter &painter) const
void DataModel::printTo(QPrinter &printer) const
{
painter.setFont(h1Font());
QPainter painter;
painter.begin(&printer);
painter.setFont(PrintableModel::h1Font());
painter.drawText(0, painter.fontMetrics().lineSpacing(), "ESGRAF 4-8 Auswertungsbogen");
painter.translate(0, 3 * painter.fontMetrics().lineSpacing());
m_metaData.printTo(painter);
m_wfModel.printTo(painter);
m_otModel.printTo(painter);
m_tPrModel.printTo(painter);
m_tPeModel.printTo(painter);
V2SvkModel::printSummary(painter,
m_wfModel.getV2Points() + m_otModel.getV2Points()
+ m_tPrModel.getV2Points() + m_tPeModel.getV2Points(),
m_wfModel.getSvkPoints() + m_otModel.getSvkPoints()
+ m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints());
m_verbEnd.printTo(painter);
m_genus.printTo(painter);
printer.newPage();
painter.resetTransform();
m_plural.printTo(painter);
painter.end();
}
void DataModel::pluralModelChanged()

View File

@ -19,9 +19,9 @@
#include "ResultModel.h"
#include <QPainter>
#include <QPrinter>
class DataModel : public QObject, public PrintableModel
class DataModel : public QObject
{
Q_OBJECT
@ -49,7 +49,7 @@ public:
void write(const QString &filename) const;
void read(const QString &filename);
void printTo(QPainter &painter) const override;
void printTo(QPrinter &printer) const;
signals:
void modelChanged();

View File

@ -5,7 +5,7 @@
#include <sstream>
MetaDataModel::MetaDataModel(QObject *parent)
: QAbstractTableModel(parent)
: PrintableModel(parent)
{
m_dateOfBirth = QDate::currentDate().addYears(-9);
m_dateOfTest = QDate::currentDate();

View File

@ -10,7 +10,7 @@
#include <QString>
#include <QDate>
class MetaDataModel : public QAbstractTableModel, public PrintableModel
class MetaDataModel : public PrintableModel
{
Q_OBJECT

View File

@ -19,6 +19,8 @@ target_include_directories(${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
CheckableTestModel
PRIVATE
Qt5::Core
Qt5::Widgets

View File

@ -1,5 +1,17 @@
#include "PrintableModel.h"
PrintableModel::PrintableModel(QObject *parent)
: CheckableTestModel(parent)
{
}
void PrintableModel::printTo(QPainter &painter) const
{
printHeader(painter);
printTests(painter);
printSummary(painter);
}
QFont PrintableModel::h1Font()
{
return QFont("Helvetica", 16);
@ -7,7 +19,7 @@ QFont PrintableModel::h1Font()
QFont PrintableModel::h2Font()
{
return QFont("Helvetica", 12);
return QFont("Helvetica", 10);
}
QFont PrintableModel::tableFont()
@ -44,17 +56,12 @@ void PrintableModel::PrintableModel::drawCheckSquare(QPainter &painter, const QR
void PrintableModel::drawResultSquare(QPainter &painter, double y, bool rightCell,
unsigned int value)
{
auto prevPen = painter.pen();
painter.setPen(tablePen());
double pageWidth = painter.device()->width();
double cellWidth = 0.03 * pageWidth;
double cellHeight = painter.fontMetrics().lineSpacing();
double cellHeight = 1.5 * painter.fontMetrics().lineSpacing();
double x = pageWidth - cellWidth - (rightCell ? 0 : 0.04 * pageWidth);
drawTextSquare(painter, {x, y, cellWidth, cellHeight}, QString::number(value));
painter.setPen(prevPen);
}
void PrintableModel::drawGreySquare(QPainter &painter, const QRectF &cell)
@ -76,3 +83,69 @@ void PrintableModel::drawGreySquare(QPainter &painter, const QRectF &cell)
painter.setBrush(prevBrush);
painter.setPen(prevPen);
}
void PrintableModel::drawHeader2(QPainter &painter, const QString &text)
{
painter.setFont(h2Font());
painter.drawText(0, 0, text);
painter.translate(0, 0.5 * painter.fontMetrics().lineSpacing());
}
void PrintableModel::printHeader(QPainter &painter) const
{
auto title = getTitle();
if (!title.isEmpty())
{
drawHeader2(painter, getTitle());
}
}
void PrintableModel::printTests(QPainter &painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double headerWidth = 0.2 * width;
double cellWidth = 0.08 * width;
double rowHeight = height;
double x = 0;
double y = 0;
for (const auto &test : m_tests)
{
drawTextSquare(painter, {0, y, headerWidth, 2 * rowHeight}, test.name());
x = headerWidth;
for (const auto &item : test.items())
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, item.getText().c_str());
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
x += cellWidth;
}
y += rowHeight;
drawResultSquare(painter, y, true, test.getPoints());
y += rowHeight;
}
painter.translate(0, y + rowHeight);
}
void PrintableModel::printSummary(QPainter &painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.85 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
drawResultSquare(painter, 0, true, getPoints());
painter.translate(0, 3 * height);
}

View File

@ -1,17 +1,22 @@
#pragma once
#include "CheckableTestModel.h"
#include <QPainter>
#include <QFont>
#include <QPen>
#include <QRect>
#include <QString>
class PrintableModel
class PrintableModel : public CheckableTestModel
{
public:
virtual void printTo(QPainter &painter) const = 0;
Q_OBJECT
public:
PrintableModel(QObject *parent);
virtual void printTo(QPainter &painter) const;
protected:
static QFont h1Font();
static QFont h2Font();
static QFont tableFont();
@ -22,4 +27,11 @@ protected:
static void drawCheckSquare(QPainter &painter, const QRectF &cell, bool checked);
static void drawResultSquare(QPainter &painter, double y, bool rightCell, unsigned int value);
static void drawGreySquare(QPainter &painter, const QRectF &cell);
protected:
static void drawHeader2(QPainter &painter, const QString &text);
virtual void printHeader(QPainter &painter) const;
virtual void printTests(QPainter &painter) const;
virtual void printSummary(QPainter &painter) const;
};

View File

@ -39,9 +39,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
PrintableModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,8 +1,10 @@
#include "GenusModel.h"
GenusModel::GenusModel(QObject *parent)
: CheckableTestModel(parent)
: PrintableModel(parent)
{
m_title = "Subtest 3: Genus";
m_tests = {{"Tiere", {"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Affe", "Hund"}},
{"Futter",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}},

View File

@ -1,9 +1,9 @@
#pragma once
#include "CheckableTestModel.h"
#include "PrintableModel.h"
#include "GenusModel.pb.h"
class GenusModel : public CheckableTestModel
class GenusModel : public PrintableModel
{
Q_OBJECT

View File

@ -39,9 +39,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
PrintableModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -3,8 +3,10 @@
#include <QSize>
PluralModel::PluralModel(QObject *parent)
: CheckableTestModel(parent)
: PrintableModel(parent)
{
m_title = "Subtest 5: Plural";
m_tests = {{"Plural",
{"Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML"}}};

View File

@ -1,9 +1,9 @@
#pragma once
#include "CheckableTestModel.h"
#include "PrintableModel.h"
#include "PluralModel.pb.h"
class PluralModel : public CheckableTestModel
class PluralModel : public PrintableModel
{
Q_OBJECT

View File

@ -19,6 +19,7 @@ protobuf_generate_cpp(V2Svk_PROTO_SRCS V2Svk_PROTO_HDRS ${V2Svk_PROTO_FILES})
add_library(${PROJECT_NAME}
V2SvkWidget.cpp
V2SvkModel.cpp
WFModel.cpp
OTModel.cpp
TPrModel.cpp
@ -42,9 +43,6 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
PrintableModel
Qt5::Widgets
${Protobuf_LIBRARIES}

View File

@ -1,7 +1,7 @@
#include "OTModel.h"
OTModel::OTModel(QObject *parent)
: CheckableTestModel(parent)
: V2SvkModel(parent)
{
m_tests = {
{"Objekt-Topikalisierung",
@ -13,7 +13,7 @@ OTModel::OTModel(QObject *parent)
};
}
unsigned int OTModel::getV2Points()
unsigned int OTModel::getV2Points() const
{
unsigned int points = 0;
@ -33,7 +33,7 @@ unsigned int OTModel::getV2Points()
return points;
}
unsigned int OTModel::getSvkPoints()
unsigned int OTModel::getSvkPoints() const
{
unsigned int points = 0;
@ -103,3 +103,13 @@ void OTModel::read(const ESGRAF48::V2SvkModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> OTModel::v2Tests() const
{
return {0};
};
std::set<int> OTModel::svkTests() const
{
return {1};
};

View File

@ -1,18 +1,24 @@
#pragma once
#include "CheckableTestModel.h"
#include "V2SvkModel.h"
#include "V2SvkModel.pb.h"
class OTModel : public CheckableTestModel
class OTModel : public V2SvkModel
{
Q_OBJECT
public:
OTModel(QObject *parent);
unsigned int getV2Points();
unsigned int getSvkPoints();
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const;
void read(const ESGRAF48::V2SvkModel &model);
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
protected:
void printHeader(QPainter &) const override {};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View File

@ -1,7 +1,7 @@
#include "TPeModel.h"
TPeModel::TPeModel(QObject *parent)
: CheckableTestModel(parent)
: V2SvkModel(parent)
{
m_tests = {
{"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
@ -11,7 +11,7 @@ TPeModel::TPeModel(QObject *parent)
};
}
unsigned int TPeModel::getV2Points()
unsigned int TPeModel::getV2Points() const
{
unsigned int points = 0;
@ -31,7 +31,7 @@ unsigned int TPeModel::getV2Points()
return points;
}
unsigned int TPeModel::getSvkPoints()
unsigned int TPeModel::getSvkPoints() const
{
unsigned int points = 0;
@ -93,3 +93,13 @@ void TPeModel::read(const ESGRAF48::V2SvkModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> TPeModel::v2Tests() const
{
return {0, 1};
};
std::set<int> TPeModel::svkTests() const
{
return {2, 3};
};

View File

@ -1,18 +1,24 @@
#pragma once
#include "CheckableTestModel.h"
#include "V2SvkModel.h"
#include "V2SvkModel.pb.h"
class TPeModel : public CheckableTestModel
class TPeModel : public V2SvkModel
{
Q_OBJECT
public:
TPeModel(QObject *parent);
unsigned int getV2Points();
unsigned int getSvkPoints();
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const;
void read(const ESGRAF48::V2SvkModel &model);
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
protected:
void printHeader(QPainter &) const override {};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View File

@ -1,7 +1,7 @@
#include "TPrModel.h"
TPrModel::TPrModel(QObject *parent)
: CheckableTestModel(parent)
: V2SvkModel(parent)
{
m_tests = {
{"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
@ -9,7 +9,7 @@ TPrModel::TPrModel(QObject *parent)
};
}
unsigned int TPrModel::getV2Points()
unsigned int TPrModel::getV2Points() const
{
unsigned int points = 0;
@ -29,7 +29,7 @@ unsigned int TPrModel::getV2Points()
return points;
}
unsigned int TPrModel::getSvkPoints()
unsigned int TPrModel::getSvkPoints() const
{
unsigned int points = 0;
@ -87,3 +87,13 @@ void TPrModel::read(const ESGRAF48::V2SvkModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> TPrModel::v2Tests() const
{
return {0};
};
std::set<int> TPrModel::svkTests() const
{
return {1};
};

View File

@ -1,18 +1,24 @@
#pragma once
#include "CheckableTestModel.h"
#include "V2SvkModel.h"
#include "V2SvkModel.pb.h"
class TPrModel : public CheckableTestModel
class TPrModel : public V2SvkModel
{
Q_OBJECT
public:
TPrModel(QObject *parent);
unsigned int getV2Points();
unsigned int getSvkPoints();
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const;
void read(const ESGRAF48::V2SvkModel &model);
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
protected:
void printHeader(QPainter &) const override{};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View File

@ -0,0 +1,126 @@
#include "V2SvkModel.h"
V2SvkModel::V2SvkModel(QObject *parent)
: PrintableModel(parent)
{
}
void V2SvkModel::printTests(QPainter &painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto v2TestIndices = v2Tests();
auto svkTestIndices = svkTests();
double x = 0;
double y = 0;
auto testIndex = 0;
for (const auto &test : m_tests)
{
double rowHeaderWidth = 0.2 * width;
double resultCellWidth = test.size() > 8 ? 0.04 * width : 0.08 * width;
double rowHeight = height;
if (testIndex == 0)
{
drawTextSquare(painter, {x, y, rowHeaderWidth, 2 * rowHeight}, test.name());
x += rowHeaderWidth;
std::vector<std::pair<std::string, unsigned int>> columnHeaders;
for (const auto &item : test.items())
{
const auto &itemText = item.getText();
if (!columnHeaders.empty() && columnHeaders.back().first == itemText)
{
columnHeaders.back().second++;
}
else
{
columnHeaders.emplace_back(itemText, 1);
}
}
for (const auto &columnHeader : columnHeaders)
{
double cellWidth = columnHeader.second * resultCellWidth;
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, columnHeader.first.c_str());
x += cellWidth;
}
x = rowHeaderWidth;
y += rowHeight;
}
else
{
drawTextSquare(painter, {x, y, rowHeaderWidth, rowHeight}, test.name());
x += rowHeaderWidth;
}
unsigned int emptyItemsStack = 0;
for (const auto &item : test.items())
{
if (item.getText().empty())
{
emptyItemsStack++;
}
else
{
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
drawCheckSquare(painter, {x, y, resultCellWidth, rowHeight}, item.isChecked());
}
x += resultCellWidth;
}
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
if (v2TestIndices.find(testIndex) != v2TestIndices.end())
{
drawResultSquare(painter, y, false, test.getPoints());
}
if (svkTestIndices.find(testIndex) != svkTestIndices.end())
{
drawResultSquare(painter, y, true, test.getPoints());
}
x = 0;
y += rowHeight;
testIndex++;
}
x = 0;
y += height;
painter.translate(0, y);
}
void V2SvkModel::printSummary(QPainter &painter, unsigned int v2Points, unsigned int svkPoints)
{
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.85 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
PrintableModel::drawResultSquare(painter, 0, false, v2Points);
PrintableModel::drawResultSquare(painter, 0, true, svkPoints);
painter.translate(0, 3 * height);
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "PrintableModel.h"
#include "V2SvkModel.pb.h"
class V2SvkModel : public PrintableModel
{
Q_OBJECT
public:
V2SvkModel(QObject *parent);
virtual unsigned int getV2Points() const = 0;
virtual unsigned int getSvkPoints() const = 0;
virtual void write(ESGRAF48::V2SvkModel &model) const = 0;
virtual void read(const ESGRAF48::V2SvkModel &model) = 0;
static void printSummary(QPainter &painter, unsigned int v2Points, unsigned int svkPoints);
protected:
void printTests(QPainter &painter) const override;
void printSummary(QPainter &painter) const override {};
virtual std::set<int> v2Tests() const = 0;
virtual std::set<int> svkTests() const = 0;
};

View File

@ -1,8 +1,10 @@
#include "WFModel.h"
WFModel::WFModel(QObject *parent)
: CheckableTestModel(parent)
: V2SvkModel(parent)
{
m_title = "Subtest 1: Verbzweitstellungsregel (V2) und Subjekt-Verb-Kontrollregel (SVK)";
m_tests = {
{"W-Frage",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
@ -134,115 +136,12 @@ void WFModel::read(const ESGRAF48::V2SvkModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void WFModel::printTo(QPainter &painter) const
std::set<int> WFModel::v2Tests() const
{
painter.setFont(h2Font());
return {0, 1};
};
painter.drawText(
0, 0, "Subtest 1: Verbzweitstellungsregel (V2) und Subjekt-Verb-Kontrollregel (SVK)");
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
std::set<unsigned int> blockStarters = {0, 3, 5, 7};
std::set<unsigned int> v2Tests = {0, 1, 3, 5, 7, 8};
std::set<unsigned int> svkTests = {2, 4, 6, 9, 10};
double x = 0;
double y = 0;
auto testIndex = 0;
for (const auto &test : m_tests)
{
double rowHeaderWidth = 0.2 * width;
double resultCellWidth = test.size() > 8 ? 0.05 * width : 0.1 * width;
double rowHeight = height;
if (blockStarters.find(testIndex) != blockStarters.end())
{
y += rowHeight;
drawTextSquare(painter, {x, y, rowHeaderWidth, 2 * rowHeight}, test.name());
x += rowHeaderWidth;
std::vector<std::pair<std::string, unsigned int>> columnHeaders;
for (const auto &item : test.items())
{
const auto &itemText = item.getText();
if (!columnHeaders.empty() && columnHeaders.back().first == itemText)
{
columnHeaders.back().second++;
}
else
{
columnHeaders.emplace_back(itemText, 1);
}
}
for (const auto &columnHeader : columnHeaders)
{
double cellWidth = columnHeader.second * resultCellWidth;
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, columnHeader.first.c_str());
x += cellWidth;
}
x = rowHeaderWidth;
y += rowHeight;
}
else
{
drawTextSquare(painter, {x, y, rowHeaderWidth, rowHeight}, test.name());
x += rowHeaderWidth;
}
unsigned int emptyItemsStack = 0;
for (const auto &item : test.items())
{
if (item.getText().empty())
{
emptyItemsStack++;
}
else
{
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
drawCheckSquare(painter, {x, y, resultCellWidth, rowHeight}, item.isChecked());
}
x += resultCellWidth;
}
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
if (v2Tests.find(testIndex) != v2Tests.end())
{
drawResultSquare(painter, y, false, test.getPoints());
}
if (svkTests.find(testIndex) != svkTests.end())
{
drawResultSquare(painter, y, true, test.getPoints());
}
x = 0;
y += rowHeight;
testIndex++;
}
x = 0;
y += height;
painter.drawText(x, y, 0.85 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
drawResultSquare(painter, y, false, getV2Points());
drawResultSquare(painter, y, true, getSvkPoints());
}
std::set<int> WFModel::svkTests() const
{
return {2};
};

View File

@ -1,25 +1,24 @@
#pragma once
#include "PrintableModel.h"
#include "CheckableTestModel.h"
#include "V2SvkModel.h"
#include "V2SvkModel.pb.h"
class WFModel : public CheckableTestModel, public PrintableModel
class WFModel : public V2SvkModel
{
Q_OBJECT
public:
WFModel(QObject *parent);
unsigned int getV2Points() const;
unsigned int getSvkPoints() const;
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const;
void read(const ESGRAF48::V2SvkModel &model);
void printTo(QPainter &painter) const override;
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
protected:
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
bool isValidIndex(const QModelIndex &index) const override;
};

View File

@ -42,6 +42,7 @@ target_link_libraries(${PROJECT_NAME}
CheckableItem
CheckableTest
CheckableTestModel
PrintableModel
Qt5::Widgets
${Protobuf_LIBRARIES}
)

View File

@ -1,8 +1,10 @@
#include "VerbEndModel.h"
VerbEndModel::VerbEndModel(QObject *parent)
: CheckableTestModel(parent)
: PrintableModel(parent)
{
m_title = "Subtest 2: Verbendstellungsregel (VE)";
m_tests = { { "Telefonat",
{ "Kausal", "Kausal", "Relativ", "Kausal",
"Final", "Temporal", "Temporal" } },
@ -98,3 +100,4 @@ void VerbEndModel::read(const ESGRAF48::VerbEndModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}

View File

@ -1,9 +1,9 @@
#pragma once
#include "CheckableTestModel.h"
#include "PrintableModel.h"
#include "VerbEndModel.pb.h"
class VerbEndModel : public CheckableTestModel
class VerbEndModel : public PrintableModel
{
Q_OBJECT

View File

@ -178,12 +178,7 @@ void MainWindow::print() const
return;
}
QPainter painter;
painter.begin(&printer);
m_dataModel.printTo(painter);
painter.end();
m_dataModel.printTo(printer);
}
void MainWindow::dataModelChanged()
@ -242,12 +237,7 @@ void MainWindow::savePdf(const QString &filename)
printer.setPageMargins(20, 20, 20, 20, QPrinter::Millimeter);
printer.setOutputFileName(filename);
QPainter painter;
painter.begin(&printer);
m_dataModel.printTo(painter);
painter.end();
m_dataModel.printTo(printer);
}
void MainWindow::aboutDialog()