Implemented printing for late skills tests
This commit is contained in:
parent
f6c2da5edc
commit
98196e05d6
@ -172,7 +172,7 @@ void CheckableTestModel::printTableTo(QTextCursor &cursor) const
|
|||||||
currentColumn++;
|
currentColumn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCellText(*table, currentRow + 1, 12, QString::number(test.getPoints()));
|
setCellNumber(*table, currentRow + 1, 12, test.getPoints());
|
||||||
|
|
||||||
currentRow += 2;
|
currentRow += 2;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ void CheckableTestModel::printSummaryTo(QTextCursor &cursor) const
|
|||||||
QTextTable *table = cursor.insertTable(1, 4, tableFormat);
|
QTextTable *table = cursor.insertTable(1, 4, tableFormat);
|
||||||
|
|
||||||
setCellText(*table, 0, 1, "Rohwertpunkte Total:");
|
setCellText(*table, 0, 1, "Rohwertpunkte Total:");
|
||||||
setCellText(*table, 0, 3, QString::number(getPoints()));
|
setCellNumber(*table, 0, 3, getPoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckableTestModel::setCellText(QTextTable &table, int row, int column, const QString &text)
|
void CheckableTestModel::setCellText(QTextTable &table, int row, int column, const QString &text)
|
||||||
|
@ -41,6 +41,12 @@ protected:
|
|||||||
static void setCellText(QTextTable &table, int row, int column, const QString &text);
|
static void setCellText(QTextTable &table, int row, int column, const QString &text);
|
||||||
static void setCellChecked(QTextTable &table, int row, int column, bool check);
|
static void setCellChecked(QTextTable &table, int row, int column, bool check);
|
||||||
|
|
||||||
|
template <typename NumberType>
|
||||||
|
static void setCellNumber(QTextTable &table, int row, int column, const NumberType &number)
|
||||||
|
{
|
||||||
|
setCellText(table, row, column, QString::number(number));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CheckableItems &getItems(const QModelIndex &index);
|
CheckableItems &getItems(const QModelIndex &index);
|
||||||
const CheckableItems &getItems(const QModelIndex &index) const;
|
const CheckableItems &getItems(const QModelIndex &index) const;
|
||||||
|
@ -75,9 +75,10 @@ void DataModel::printTo(QTextCursor &cursor) const
|
|||||||
m_genus.printTo(cursor);
|
m_genus.printTo(cursor);
|
||||||
m_akkusativ.printTo(cursor);
|
m_akkusativ.printTo(cursor);
|
||||||
m_dativ.printTo(cursor);
|
m_dativ.printTo(cursor);
|
||||||
|
|
||||||
m_plural.printTo(cursor);
|
m_plural.printTo(cursor);
|
||||||
//m_genitiv.printTo(cursor);
|
m_passiv.printTo(cursor);
|
||||||
//m_passiv.printTo(cursor);
|
m_genitiv.printTo(cursor);
|
||||||
|
|
||||||
m_results.printTo(cursor);
|
m_results.printTo(cursor);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ protobuf_generate_cpp(LateSkills_PROTO_SRCS LateSkills_PROTO_HDRS
|
|||||||
|
|
||||||
add_library(${PROJECT_NAME}
|
add_library(${PROJECT_NAME}
|
||||||
LateSkillsWidget.cpp
|
LateSkillsWidget.cpp
|
||||||
|
LateSkillsModel.cpp
|
||||||
PassivModel.cpp
|
PassivModel.cpp
|
||||||
GenitivModel.cpp
|
GenitivModel.cpp
|
||||||
${UI_HEADERS}
|
${UI_HEADERS}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "GenitivModel.h"
|
#include "GenitivModel.h"
|
||||||
|
|
||||||
GenitivModel::GenitivModel(QObject *parent)
|
GenitivModel::GenitivModel(QObject *parent)
|
||||||
: CheckableTestModel(parent)
|
: LateSkillsModel(parent)
|
||||||
{
|
{
|
||||||
m_tests = {
|
m_tests = {
|
||||||
{"Genitiv Präpositionen",
|
{"Genitiv Präpositionen",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CheckableTestModel.h"
|
#include "LateSkillsModel.h"
|
||||||
#include "LateSkillsGenitivModel.pb.h"
|
#include "LateSkillsGenitivModel.pb.h"
|
||||||
|
|
||||||
class GenitivModel : public CheckableTestModel
|
class GenitivModel : public LateSkillsModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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"
|
#include "PassivModel.h"
|
||||||
|
|
||||||
PassivModel::PassivModel(QObject *parent)
|
PassivModel::PassivModel(QObject *parent)
|
||||||
: CheckableTestModel(parent)
|
: LateSkillsModel(parent)
|
||||||
{
|
{
|
||||||
m_tests = {{"Passiv",
|
m_tests = {{"Passiv",
|
||||||
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
|
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CheckableTestModel.h"
|
#include "LateSkillsModel.h"
|
||||||
#include "LateSkillsPassivModel.pb.h"
|
#include "LateSkillsPassivModel.pb.h"
|
||||||
|
|
||||||
class PassivModel : public CheckableTestModel
|
class PassivModel : public LateSkillsModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user