Print subtest 6 and results

This commit is contained in:
Michael Mandl 2019-02-07 22:36:39 +01:00
parent 189c24cf61
commit 51271e9595
16 changed files with 187 additions and 37 deletions

View file

@ -105,7 +105,6 @@ void DataModel::printTo(QPrinter &printer) const
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());
@ -132,6 +131,11 @@ void DataModel::printTo(QPrinter &printer) const
m_dativ.printTo(painter);
m_plural.printTo(painter);
m_passiv.printTo(painter);
m_genitiv.printTo(painter);
m_results.printTo(painter);
painter.end();
}

View file

@ -46,7 +46,7 @@ double PrintableModel::headerWidthFactor()
double PrintableModel::cellWidthFactor()
{
return 0.085;
return headerWidthFactor() / 2;
}
void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text)

View file

@ -33,9 +33,9 @@ public:
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);
protected:
virtual void printHeader(QPainter &painter) const;
virtual void printTests(QPainter &painter) const;
virtual void printSummary(QPainter &painter) const;

View file

@ -30,6 +30,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
PrintableModel
Age
Qt5::Widgets
)

View file

@ -10,13 +10,14 @@
#include "PassivPR.h"
#include "GenitivPR.h"
#include "PrintableModel.h"
#include <QDebug>
ResultModel::ResultModel(QObject *parent)
: QAbstractTableModel(parent)
: QAbstractTableModel(parent)
{
m_results = { { "V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ",
"Genitiv", "Plural" } };
m_results = {{"V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ", "Genitiv", "Plural"}};
}
int ResultModel::rowCount(const QModelIndex &parent) const
@ -81,8 +82,7 @@ QVariant ResultModel::data(const QModelIndex &index, int role) const
return {};
}
QVariant ResultModel::headerData(
int section, Qt::Orientation orientation, int role) const
QVariant ResultModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
{
@ -193,20 +193,66 @@ void ResultModel::setSvkResult(unsigned int points)
void ResultModel::setPassivResult(unsigned int points)
{
if (m_results[3].points() != points)
{
m_results[3].setPoints(points);
m_results[3].setPR(PassivPR().lookup(m_age, points));
emit dataChanged(index(0, 3), index(4, 3));
}
if (m_results[3].points() != points)
{
m_results[3].setPoints(points);
m_results[3].setPR(PassivPR().lookup(m_age, points));
emit dataChanged(index(0, 3), index(4, 3));
}
}
void ResultModel::setGenitivResult(unsigned int points)
{
if (m_results[7].points() != points)
{
m_results[7].setPoints(points);
m_results[7].setPR(GenitivPR().lookup(m_age, points));
emit dataChanged(index(0, 7), index(4, 7));
}
if (m_results[7].points() != points)
{
m_results[7].setPoints(points);
m_results[7].setPR(GenitivPR().lookup(m_age, points));
emit dataChanged(index(0, 7), index(4, 7));
}
}
void ResultModel::printTo(QPainter &painter) const
{
PrintableModel::drawHeader2(painter, "Prozentränge (PR)");
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double cellWidth = width / (m_results.size() + 1);
double rowHeight = 2 * height;
double x = 0;
double y = 0;
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight}, "");
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
"\u2265 PR 84");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
"< PR 84");
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
"\u2264 PR 16");
x += cellWidth;
for (const auto &result : m_results)
{
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight},
result.name());
const auto pr = result.pr();
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
pr >= 84 ? QString::number(pr) : "-");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
pr < 84 && pr > 16 ? QString::number(pr) : "-");
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
pr <= 16 ? QString::number(pr) : "-");
x += cellWidth;
}
}

View file

@ -1,7 +1,9 @@
#pragma once
#include "Age.h"
#include <QAbstractTableModel>
#include <QPainter>
class TestResult
{
@ -72,4 +74,6 @@ public:
void setSvkResult(unsigned int points);
void setPassivResult(unsigned int points);
void setGenitivResult(unsigned int points);
void printTo(QPainter &painter) const;
};

View file

@ -105,3 +105,8 @@ void DativModel::write(ESGRAF48::DativModel &model) const
nomTiereModel->set_katze(testItems[7].isChecked());
}
}
void DativModel::printHeader(QPainter &painter) const
{
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
}

View file

@ -14,5 +14,5 @@ public:
void write(ESGRAF48::DativModel &model) const;
protected:
void printHeader(QPainter &) const override {};
void printHeader(QPainter &painter) const override;
};

View file

@ -22,6 +22,7 @@ protobuf_generate_cpp(LateSkills_PROTO_SRCS LateSkills_PROTO_HDRS
add_library(${PROJECT_NAME}
LateSkillsWidget.cpp
LateSkillsModel.cpp
PassivModel.cpp
GenitivModel.cpp
${UI_HEADERS}
@ -43,9 +44,7 @@ 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 "GenitivModel.h"
GenitivModel::GenitivModel(QObject *parent)
: CheckableTestModel(parent)
: LateSkillsModel(parent)
{
m_tests = {
{"Genitiv Präpositionen",
@ -107,3 +107,8 @@ void GenitivModel::write(ESGRAF48::LateSkillsGenitivModel &model) const
attributierungModel->set_guertel2(testItems[9].isChecked());
}
}
void GenitivModel::printHeader(QPainter &painter) const
{
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
}

View file

@ -1,9 +1,9 @@
#pragma once
#include "CheckableTestModel.h"
#include "LateSkillsModel.h"
#include "LateSkillsGenitivModel.pb.h"
class GenitivModel : public CheckableTestModel
class GenitivModel : public LateSkillsModel
{
Q_OBJECT
@ -14,4 +14,7 @@ public:
void read(const ESGRAF48::LateSkillsGenitivModel &model);
void write(ESGRAF48::LateSkillsGenitivModel &model) const;
protected:
void printHeader(QPainter &painter) const override;
};

View file

@ -0,0 +1,64 @@
#include "LateSkillsModel.h"
#include <regex>
LateSkillsModel::LateSkillsModel(QObject *parent)
: PrintableModel(parent)
{
}
void LateSkillsModel::printTests(QPainter &painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double headerWidth = headerWidthFactor() * width;
double cellHeaderWidth = cellWidthFactor() * width;
double cellWidth = 0.5 * cellHeaderWidth;
double rowHeight = height;
double x = 0;
double y = 0;
for (const auto &test : m_tests)
{
QString testName = QString::fromStdString(
std::regex_replace(test.name().toStdString(), std::regex("\\s"), "\n"));
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, testName);
const auto &items = test.items();
x = headerWidth;
for (unsigned int i = 0; i < items.size(); i += 2)
{
const auto &item = test.items().at(i);
QString itemText = QString::fromStdString(item.getText()).split(" ").at(0);
drawTextSquare(painter, {x, y, cellHeaderWidth, rowHeight}, itemText);
x += cellHeaderWidth;
}
y += rowHeight;
x = headerWidth;
for (const auto &item : items)
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, QString::number(item.value()));
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
x += cellWidth;
}
if (m_tests.size() > 1)
{
drawResultSquare(painter, y + rowHeight, true, test.getPoints());
}
y += 2 * rowHeight;
}
painter.translate(0, y + rowHeight);
}

View file

@ -0,0 +1,15 @@
#pragma once
#include "PrintableModel.h"
#include "LateSkillsPassivModel.pb.h"
class LateSkillsModel : public PrintableModel
{
Q_OBJECT
public:
LateSkillsModel(QObject *parent);
protected:
void printTests(QPainter &painter) const override;
};

View file

@ -1,7 +1,7 @@
#include "PassivModel.h"
PassivModel::PassivModel(QObject *parent)
: CheckableTestModel(parent)
: LateSkillsModel(parent)
{
m_tests = {{"Passiv",
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
@ -65,3 +65,8 @@ void PassivModel::write(ESGRAF48::LateSkillsPassivModel &model) const
model.set_fleisch1(testItems[8].isChecked());
model.set_fleisch2(testItems[9].isChecked());
}
void PassivModel::printHeader(QPainter &painter) const
{
drawHeader2(painter, "Subtest 6: Späte Fähigkeiten (7;0-8;11)");
}

View file

@ -1,17 +1,19 @@
#pragma once
#include "CheckableTestModel.h"
#include "LateSkillsModel.h"
#include "LateSkillsPassivModel.pb.h"
class PassivModel : public CheckableTestModel
class PassivModel : public LateSkillsModel
{
Q_OBJECT
public:
PassivModel(QObject *parent);
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;
void read(const ESGRAF48::LateSkillsPassivModel &model);
void write(ESGRAF48::LateSkillsPassivModel &model) const;
protected:
void printHeader(QPainter &painter) const override;
};

View file

@ -76,10 +76,7 @@ void PluralModel::printTests(QPainter &painter) const
x += cellWidth;
}
y += rowHeight;
drawResultSquare(painter, y, true, test.getPoints());
y += rowHeight;
y += 2 * rowHeight;
}
painter.translate(0, y + 2 * rowHeight);