Implemented plural-test printing
This commit is contained in:
parent
2570d5d5b5
commit
f6c2da5edc
5 changed files with 78 additions and 50 deletions
|
@ -1,6 +1,10 @@
|
|||
#include "PluralModel.h"
|
||||
|
||||
#include <QSize>
|
||||
#include <QTextTable>
|
||||
#include <QDebug>
|
||||
|
||||
#include <regex>
|
||||
|
||||
PluralModel::PluralModel(QObject *parent)
|
||||
: CheckableTestModel(parent)
|
||||
|
@ -56,3 +60,38 @@ std::string PluralModel::getName() const
|
|||
{
|
||||
return "Subtest 5: Plural";
|
||||
}
|
||||
|
||||
void PluralModel::printTableTo(QTextCursor &cursor) const
|
||||
{
|
||||
QTextTableFormat tableFormat;
|
||||
tableFormat.setCellPadding(2);
|
||||
tableFormat.setCellSpacing(0);
|
||||
|
||||
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10),
|
||||
QTextLength(QTextLength::PercentageLength, 10)});
|
||||
|
||||
QTextTable *table = cursor.insertTable(2, 10, tableFormat);
|
||||
|
||||
const auto &test = m_tests.front();
|
||||
|
||||
int currentColumn = 0;
|
||||
for (const auto &item : test.items())
|
||||
{
|
||||
std::string itemName = std::regex_replace(item.getText(), std::regex("\\s"), "\n",
|
||||
std::regex_constants::format_first_only);
|
||||
|
||||
setCellText(*table, 0, currentColumn, itemName.c_str());
|
||||
setCellChecked(*table, 1, currentColumn, item.isChecked());
|
||||
|
||||
currentColumn++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,6 @@ public:
|
|||
|
||||
protected:
|
||||
std::string getName() const override;
|
||||
|
||||
void printTableTo(QTextCursor &cursor) const override;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue