Added fat lines around summary squares
This commit is contained in:
parent
ab862aeaf1
commit
1695174303
5 changed files with 67 additions and 15 deletions
|
@ -32,6 +32,11 @@ QPen PrintableModel::tablePen()
|
|||
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)
|
||||
{
|
||||
auto prevPen = painter.pen();
|
||||
|
@ -47,6 +52,19 @@ void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const
|
|||
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,
|
||||
bool checked)
|
||||
{
|
||||
|
@ -138,14 +156,14 @@ void PrintableModel::printTests(QPainter &painter) const
|
|||
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,
|
||||
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
|
||||
"Rohwertpunkte Total:");
|
||||
drawResultSquare(painter, 0, true, getPoints());
|
||||
painter.setPen(resultPen());
|
||||
drawNumberSquare(painter, 0.97 * width, 0, getPoints());
|
||||
|
||||
painter.translate(0, 3 * height);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ public:
|
|||
static QFont tableFont();
|
||||
|
||||
static QPen tablePen();
|
||||
static QPen resultPen();
|
||||
|
||||
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 drawResultSquare(QPainter &painter, double y, bool rightCell, unsigned int value);
|
||||
static void drawGreySquare(QPainter &painter, const QRectF &cell);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue