Implemented printing for late skills tests
This commit is contained in:
parent
f6c2da5edc
commit
98196e05d6
11 changed files with 100 additions and 11 deletions
|
@ -22,6 +22,7 @@ protobuf_generate_cpp(LateSkills_PROTO_SRCS LateSkills_PROTO_HDRS
|
|||
|
||||
add_library(${PROJECT_NAME}
|
||||
LateSkillsWidget.cpp
|
||||
LateSkillsModel.cpp
|
||||
PassivModel.cpp
|
||||
GenitivModel.cpp
|
||||
${UI_HEADERS}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "GenitivModel.h"
|
||||
|
||||
GenitivModel::GenitivModel(QObject *parent)
|
||||
: CheckableTestModel(parent)
|
||||
: LateSkillsModel(parent)
|
||||
{
|
||||
m_tests = {
|
||||
{"Genitiv Präpositionen",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "CheckableTestModel.h"
|
||||
#include "LateSkillsModel.h"
|
||||
#include "LateSkillsGenitivModel.pb.h"
|
||||
|
||||
class GenitivModel : public CheckableTestModel
|
||||
class GenitivModel : public LateSkillsModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
67
source/SubTests/LateSkills/LateSkillsModel.cpp
Normal file
67
source/SubTests/LateSkills/LateSkillsModel.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
#include "LateSkillsModel.h"
|
||||
|
||||
#include <QTextTable>
|
||||
|
||||
#include <regex>
|
||||
|
||||
LateSkillsModel::LateSkillsModel(QObject *parent)
|
||||
: CheckableTestModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LateSkillsModel::printTableTo(QTextCursor &cursor) const
|
||||
{
|
||||
QTextTableFormat tableFormat;
|
||||
tableFormat.setCellPadding(2);
|
||||
tableFormat.setCellSpacing(0);
|
||||
|
||||
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 20),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 5),
|
||||
QTextLength(QTextLength::PercentageLength, 26),
|
||||
QTextLength(QTextLength::PercentageLength, 1),
|
||||
QTextLength(QTextLength::PercentageLength, 3)});
|
||||
|
||||
QTextTable *table = cursor.insertTable(m_tests.size() * 3, 14, tableFormat);
|
||||
|
||||
int currentRow = 0;
|
||||
for (const auto &test : m_tests)
|
||||
{
|
||||
table->mergeCells(currentRow, 0, 3, 1);
|
||||
|
||||
int currentColumn = 0;
|
||||
|
||||
setCellText(*table, currentRow, currentColumn, test.name());
|
||||
currentColumn++;
|
||||
|
||||
for (auto it = std::begin(test.items()); it != std::end(test.items()); std::advance(it, 2))
|
||||
{
|
||||
const auto &item = *it;
|
||||
const auto &nextItem = *std::next(it);
|
||||
|
||||
table->mergeCells(currentRow, currentColumn, 1, 2);
|
||||
|
||||
auto itemName = std::regex_replace(item.getText(), std::regex(R"((\S+).*)"), "$1");
|
||||
|
||||
setCellText(*table, currentRow, currentColumn, itemName.c_str());
|
||||
setCellText(*table, currentRow + 1, currentColumn, "1");
|
||||
setCellText(*table, currentRow + 1, currentColumn + 1, "2");
|
||||
setCellChecked(*table, currentRow + 2, currentColumn, item.isChecked());
|
||||
setCellChecked(*table, currentRow + 2, currentColumn + 1, nextItem.isChecked());
|
||||
|
||||
currentColumn += 2;
|
||||
}
|
||||
|
||||
setCellNumber(*table, currentRow + 2, 13, test.getPoints());
|
||||
|
||||
currentRow += 3;
|
||||
}
|
||||
}
|
14
source/SubTests/LateSkills/LateSkillsModel.h
Normal file
14
source/SubTests/LateSkills/LateSkillsModel.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "CheckableTestModel.h"
|
||||
|
||||
class LateSkillsModel : public CheckableTestModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LateSkillsModel(QObject *parent);
|
||||
|
||||
protected:
|
||||
void printTableTo(QTextCursor &cursor) const override;
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
#include "PassivModel.h"
|
||||
|
||||
PassivModel::PassivModel(QObject *parent)
|
||||
: CheckableTestModel(parent)
|
||||
: LateSkillsModel(parent)
|
||||
{
|
||||
m_tests = {{"Passiv",
|
||||
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "CheckableTestModel.h"
|
||||
#include "LateSkillsModel.h"
|
||||
#include "LateSkillsPassivModel.pb.h"
|
||||
|
||||
class PassivModel : public CheckableTestModel
|
||||
class PassivModel : public LateSkillsModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ std::string PluralModel::getName() const
|
|||
{
|
||||
return "Subtest 5: Plural";
|
||||
}
|
||||
|
||||
|
||||
void PluralModel::printTableTo(QTextCursor &cursor) const
|
||||
{
|
||||
QTextTableFormat tableFormat;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue