Wrap long row headers
This commit is contained in:
parent
1f5c0de80a
commit
189c24cf61
5 changed files with 72 additions and 6 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <QSize>
|
||||
|
||||
#include <regex>
|
||||
|
||||
PluralModel::PluralModel(QObject *parent)
|
||||
: PrintableModel(parent)
|
||||
{
|
||||
|
@ -43,3 +45,42 @@ void PluralModel::write(ESGRAF48::PluralModel &model) const
|
|||
model.set_baer(testItems[7].isChecked());
|
||||
model.set_apfel(testItems[8].isChecked());
|
||||
}
|
||||
|
||||
void PluralModel::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 cellWidth = cellWidthFactor() * width;
|
||||
double rowHeight = height;
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
for (const auto &test : m_tests)
|
||||
{
|
||||
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, test.name());
|
||||
x = headerWidth;
|
||||
|
||||
for (const auto &item : test.items())
|
||||
{
|
||||
QString itemText =
|
||||
QString::fromStdString(std::regex_replace(item.getText(), std::regex("\\s"), "\n"));
|
||||
|
||||
drawTextSquare(painter, {x, y, cellWidth, 2 * rowHeight}, itemText);
|
||||
drawCheckSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
|
||||
item.isChecked());
|
||||
|
||||
x += cellWidth;
|
||||
}
|
||||
y += rowHeight;
|
||||
|
||||
drawResultSquare(painter, y, true, test.getPoints());
|
||||
y += rowHeight;
|
||||
}
|
||||
|
||||
painter.translate(0, y + 2 * rowHeight);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,7 @@ public:
|
|||
|
||||
void read(const ESGRAF48::PluralModel &model);
|
||||
void write(ESGRAF48::PluralModel &model) const;
|
||||
|
||||
protected:
|
||||
virtual void printTests(QPainter &painter) const;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue