Added fat lines around summary squares

This commit is contained in:
Michael Mandl 2019-02-05 21:32:13 +01:00
parent ab862aeaf1
commit 1695174303
5 changed files with 67 additions and 15 deletions

View file

@ -32,6 +32,11 @@ QPen PrintableModel::tablePen()
return QPen(Qt::black, 1, Qt::SolidLine); return QPen(Qt::black, 1, Qt::SolidLine);
} }
QPen PrintableModel::resultPen()
{
return QPen(Qt::black, 2, Qt::SolidLine);
}
void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text) void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text)
{ {
auto prevPen = painter.pen(); auto prevPen = painter.pen();
@ -47,6 +52,19 @@ void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const
painter.setPen(prevPen); painter.setPen(prevPen);
} }
void PrintableModel::drawNumberSquare(QPainter &painter, double x, double y, int number)
{
QRectF cell = {x, y, 0.03 * painter.device()->width(),
1.5 * painter.fontMetrics().lineSpacing()};
painter.drawText(cell, Qt::AlignCenter, QString::number(number));
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
}
void PrintableModel::PrintableModel::drawCheckSquare(QPainter &painter, const QRectF &cell, void PrintableModel::PrintableModel::drawCheckSquare(QPainter &painter, const QRectF &cell,
bool checked) bool checked)
{ {
@ -138,14 +156,14 @@ void PrintableModel::printTests(QPainter &painter) const
void PrintableModel::printSummary(QPainter &painter) const void PrintableModel::printSummary(QPainter &painter) const
{ {
painter.setFont(tableFont()); painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width(); auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing(); auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.85 * width, height, Qt::AlignRight | Qt::AlignVCenter, painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:"); "Rohwertpunkte Total:");
drawResultSquare(painter, 0, true, getPoints()); painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getPoints());
painter.translate(0, 3 * height); painter.translate(0, 3 * height);
} }

View file

@ -22,8 +22,10 @@ public:
static QFont tableFont(); static QFont tableFont();
static QPen tablePen(); static QPen tablePen();
static QPen resultPen();
static void drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text); static void drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text);
static void drawNumberSquare(QPainter &painter, double x, double y, int number);
static void drawCheckSquare(QPainter &painter, const QRectF &cell, bool checked); static void drawCheckSquare(QPainter &painter, const QRectF &cell, bool checked);
static void drawResultSquare(QPainter &painter, double y, bool rightCell, unsigned int value); static void drawResultSquare(QPainter &painter, double y, bool rightCell, unsigned int value);
static void drawGreySquare(QPainter &painter, const QRectF &cell); static void drawGreySquare(QPainter &painter, const QRectF &cell);

View file

@ -116,10 +116,12 @@ void V2SvkModel::printSummary(QPainter &painter, unsigned int v2Points, unsigned
auto width = painter.device()->width(); auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing(); auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.85 * width, height, Qt::AlignRight | Qt::AlignVCenter, painter.drawText(0, 0, 0.91 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:"); "Rohwertpunkte Total:");
PrintableModel::drawResultSquare(painter, 0, false, v2Points);
PrintableModel::drawResultSquare(painter, 0, true, svkPoints); painter.setPen(resultPen());
drawNumberSquare(painter, 0.93 * width, 0, v2Points);
drawNumberSquare(painter, 0.97 * width, 0, svkPoints);
painter.translate(0, 3 * height); painter.translate(0, 3 * height);
} }

View file

@ -1,17 +1,14 @@
#include "VerbEndModel.h" #include "VerbEndModel.h"
VerbEndModel::VerbEndModel(QObject *parent) VerbEndModel::VerbEndModel(QObject *parent)
: PrintableModel(parent) : PrintableModel(parent)
{ {
m_title = "Subtest 2: Verbendstellungsregel (VE)"; m_title = "Subtest 2: Verbendstellungsregel (VE)";
m_tests = { { "Telefonat", m_tests = {
{ "Kausal", "Kausal", "Relativ", "Kausal", {"Telefonat", {"Kausal", "Kausal", "Relativ", "Kausal", "Final", "Temporal", "Temporal"}},
"Final", "Temporal", "Temporal" } }, {"Zaubertrick", {"Relativ", "Final", "Kausal", "Final", "Temporal", "Kausal", "Temporal"}},
{ "Zaubertrick", { "Relativ", "Final", "Kausal", "Final", {"Zauberregel", {"Temporal", "Kausal", "Final", "Relativ", "Temporal", "Relativ"}}};
"Temporal", "Kausal", "Temporal" } },
{ "Zauberregel", { "Temporal", "Kausal", "Final", "Relativ",
"Temporal", "Relativ" } } };
} }
void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const
@ -100,4 +97,32 @@ void VerbEndModel::read(const ESGRAF48::VerbEndModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
} }
unsigned int VerbEndModel::getKausalPoints() const
{
auto points = [&](unsigned int testId, unsigned int itemId) {
return m_tests.at(testId).items().at(itemId).points();
};
return points(0, 0) + points(0, 1) + points(0, 3) + points(1, 2) + points(1, 5) + points(2, 1);
}
void VerbEndModel::printSummary(QPainter &painter) const
{
painter.setFont(tableFont());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.71 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Kausalsätze:");
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
drawNumberSquare(painter, 0.73 * width, 0, getKausalPoints());
painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getKausalPoints());
painter.translate(0, 3 * height);
}

View file

@ -12,4 +12,9 @@ public:
void write(ESGRAF48::VerbEndModel &model) const; void write(ESGRAF48::VerbEndModel &model) const;
void read(const ESGRAF48::VerbEndModel &model); void read(const ESGRAF48::VerbEndModel &model);
unsigned int getKausalPoints() const;
protected:
void printSummary(QPainter &painter) const override;
}; };