2019-02-03 18:53:51 +00:00
|
|
|
#include "V2SvkModel.h"
|
|
|
|
|
2019-02-07 19:03:22 +00:00
|
|
|
#include <regex>
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
V2SvkModel::V2SvkModel(QObject* parent)
|
2019-02-03 18:53:51 +00:00
|
|
|
: PrintableModel(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
void V2SvkModel::printTests(QPainter& painter) const
|
2019-02-03 18:53:51 +00:00
|
|
|
{
|
2019-10-05 14:14:45 +00:00
|
|
|
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 = headerWidthFactor() * width;
|
|
|
|
double resultCellWidth = (test.size() > 8 ? 0.5 : 1) * cellWidthFactor() * width;
|
|
|
|
double rowHeight = height;
|
|
|
|
|
|
|
|
QString testName = test.name();
|
|
|
|
if (testName.length() > 20)
|
|
|
|
{
|
|
|
|
testName = QString::fromStdString(
|
|
|
|
std::regex_replace(testName.toStdString(), std::regex("[\\s-]"), "\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testIndex == 0)
|
|
|
|
{
|
|
|
|
drawTextSquare(painter, {x, y, rowHeaderWidth, 2 * rowHeight}, testName);
|
|
|
|
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}, testName);
|
|
|
|
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);
|
2019-02-03 18:53:51 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
void V2SvkModel::printSummary(QPainter& painter, unsigned int v2Points, unsigned int svkPoints)
|
2019-02-03 18:53:51 +00:00
|
|
|
{
|
2019-10-05 14:14:45 +00:00
|
|
|
painter.setFont(PrintableModel::tableFont());
|
|
|
|
painter.setPen(PrintableModel::tablePen());
|
2019-02-03 18:53:51 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
auto width = painter.device()->width();
|
|
|
|
auto height = 1.5 * painter.fontMetrics().lineSpacing();
|
2019-02-03 18:53:51 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
painter.drawText(0, 0, 0.91 * width, height, Qt::AlignRight | Qt::AlignVCenter,
|
|
|
|
"Rohwertpunkte Total:");
|
2019-02-05 20:32:13 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
painter.setPen(resultPen());
|
|
|
|
drawNumberSquare(painter, 0.93 * width, 0, v2Points);
|
|
|
|
drawNumberSquare(painter, 0.97 * width, 0, svkPoints);
|
2019-02-03 18:53:51 +00:00
|
|
|
|
2019-10-05 14:14:45 +00:00
|
|
|
painter.translate(0, 3 * height);
|
2019-02-03 18:53:51 +00:00
|
|
|
}
|