Print subtest 1
This commit is contained in:
parent
be3a3f453d
commit
a718113747
4 changed files with 134 additions and 53 deletions
|
@ -6,7 +6,7 @@ V2SvkModel::V2SvkModel(QObject *parent)
|
||||||
: CheckableTestModel(parent)
|
: CheckableTestModel(parent)
|
||||||
{
|
{
|
||||||
m_tests = {
|
m_tests = {
|
||||||
{"W-Frage",
|
{"W-Fragen",
|
||||||
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
|
||||||
"Gans", "Gans", "Gans"}},
|
"Gans", "Gans", "Gans"}},
|
||||||
{"Verbtrennung", {"", "Affe", "", "", "", "", "", "Schwein", "", "", "Gans", ""}},
|
{"Verbtrennung", {"", "Affe", "", "", "", "", "", "Schwein", "", "", "Gans", ""}},
|
||||||
|
@ -31,7 +31,7 @@ V2SvkModel::V2SvkModel(QObject *parent)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int V2SvkModel::getV2Points()
|
unsigned int V2SvkModel::getV2Points() const
|
||||||
{
|
{
|
||||||
unsigned int points = 0;
|
unsigned int points = 0;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ unsigned int V2SvkModel::getV2Points()
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int V2SvkModel::getSvkPoints()
|
unsigned int V2SvkModel::getSvkPoints() const
|
||||||
{
|
{
|
||||||
unsigned int points = 0;
|
unsigned int points = 0;
|
||||||
|
|
||||||
|
@ -209,11 +209,11 @@ std::string V2SvkModel::getName() const
|
||||||
|
|
||||||
void V2SvkModel::printTableTo(QTextCursor &cursor) const
|
void V2SvkModel::printTableTo(QTextCursor &cursor) const
|
||||||
{
|
{
|
||||||
QTextTableFormat tableFormat;
|
QTextTableFormat tableFormat12;
|
||||||
tableFormat.setCellPadding(2);
|
tableFormat12.setCellPadding(2);
|
||||||
tableFormat.setCellSpacing(0);
|
tableFormat12.setCellSpacing(0);
|
||||||
|
|
||||||
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 20),
|
tableFormat12.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),
|
||||||
|
@ -231,36 +231,119 @@ void V2SvkModel::printTableTo(QTextCursor &cursor) const
|
||||||
QTextLength(QTextLength::PercentageLength, 1),
|
QTextLength(QTextLength::PercentageLength, 1),
|
||||||
QTextLength(QTextLength::PercentageLength, 3)});
|
QTextLength(QTextLength::PercentageLength, 3)});
|
||||||
|
|
||||||
QTextTable *table = cursor.insertTable(2, 17, tableFormat);
|
QTextTableFormat tableFormat6;
|
||||||
|
tableFormat6.setCellPadding(2);
|
||||||
|
tableFormat6.setCellSpacing(0);
|
||||||
|
|
||||||
int currentRow = 0;
|
tableFormat6.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 20),
|
||||||
int currentTest = 0;
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
//for (const auto &test : m_tests)
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 10),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 13),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 3),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 1),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 3)});
|
||||||
|
|
||||||
|
auto writeHeader = [](QTextTable *table, const CheckableTest &test, int colSpan) {
|
||||||
|
table->mergeCells(0, 0, 2, 1);
|
||||||
|
|
||||||
|
int column = 1;
|
||||||
|
|
||||||
|
for (auto it = std::begin(test.items()); it != std::end(test.items());
|
||||||
|
std::advance(it, colSpan))
|
||||||
{
|
{
|
||||||
table->mergeCells(currentRow, 0, 2, 1);
|
table->mergeCells(0, column, 1, colSpan);
|
||||||
|
setCellText(*table, 0, column, it->getText().c_str());
|
||||||
|
|
||||||
int currentColumn = 0;
|
column += colSpan;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
setCellText(*table, currentRow, currentColumn, m_tests[0].name());
|
auto writeLine = [](QTextTable *table, const CheckableTest &test, int row, int resultColumn) {
|
||||||
currentColumn++;
|
int column = 0;
|
||||||
|
|
||||||
for (auto it = std::begin(m_tests[0].items()); it != std::end(m_tests[0].items()); std::advance(it, 4))
|
setCellText(*table, row, column, test.name());
|
||||||
|
for (const auto item : test.items())
|
||||||
{
|
{
|
||||||
table->mergeCells(currentRow, currentColumn, 1, 4);
|
column++;
|
||||||
|
|
||||||
auto itemName = it->getText();
|
if (!item.getText().empty())
|
||||||
|
{
|
||||||
setCellText(*table, currentRow, currentColumn, itemName.c_str());
|
setCellChecked(*table, row, column, item.isChecked());
|
||||||
setCellChecked(*table, currentRow + 1, currentColumn, it->isChecked());
|
}
|
||||||
setCellChecked(*table, currentRow + 1, currentColumn + 1, (it + 1)->isChecked());
|
|
||||||
setCellChecked(*table, currentRow + 1, currentColumn + 2, (it + 2)->isChecked());
|
|
||||||
setCellChecked(*table, currentRow + 1, currentColumn + 3, (it + 3)->isChecked());
|
|
||||||
|
|
||||||
currentColumn += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCellNumber(*table, currentRow + 1, 14, m_tests[0].getPoints());
|
setCellNumber(*table, row, resultColumn, test.getPoints());
|
||||||
|
};
|
||||||
|
|
||||||
currentRow += 2;
|
{
|
||||||
|
QTextTable *table = cursor.insertTable(4, 17, tableFormat12);
|
||||||
|
|
||||||
|
writeHeader(table, m_tests[0], 4);
|
||||||
|
writeLine(table, m_tests[0], 1, 14);
|
||||||
|
writeLine(table, m_tests[1], 2, 14);
|
||||||
|
writeLine(table, m_tests[2], 3, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::End);
|
||||||
|
cursor.insertBlock();
|
||||||
|
cursor.insertText("\n");
|
||||||
|
|
||||||
|
{
|
||||||
|
QTextTable *table = cursor.insertTable(3, 17, tableFormat12);
|
||||||
|
|
||||||
|
writeHeader(table, m_tests[3], 4);
|
||||||
|
writeLine(table, m_tests[3], 1, 14);
|
||||||
|
writeLine(table, m_tests[4], 2, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::End);
|
||||||
|
cursor.insertBlock();
|
||||||
|
cursor.insertText("\n");
|
||||||
|
|
||||||
|
{
|
||||||
|
QTextTable *table = cursor.insertTable(3, 11, tableFormat6);
|
||||||
|
|
||||||
|
writeHeader(table, m_tests[5], 2);
|
||||||
|
writeLine(table, m_tests[5], 1, 8);
|
||||||
|
writeLine(table, m_tests[6], 2, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::End);
|
||||||
|
cursor.insertBlock();
|
||||||
|
cursor.insertText("\n");
|
||||||
|
|
||||||
|
{
|
||||||
|
QTextTable *table = cursor.insertTable(5, 11, tableFormat6);
|
||||||
|
|
||||||
|
writeHeader(table, m_tests[7], 2);
|
||||||
|
writeLine(table, m_tests[7], 1, 8);
|
||||||
|
writeLine(table, m_tests[8], 2, 8);
|
||||||
|
writeLine(table, m_tests[9], 3, 10);
|
||||||
|
writeLine(table, m_tests[10], 4, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V2SvkModel::printSummaryTo(QTextCursor &cursor) const
|
||||||
|
{
|
||||||
|
QTextTableFormat tableFormat;
|
||||||
|
tableFormat.setCellPadding(2);
|
||||||
|
tableFormat.setCellSpacing(0);
|
||||||
|
|
||||||
|
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 72),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 20),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 1),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 3),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 1),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 3)});
|
||||||
|
|
||||||
|
QTextTable *table = cursor.insertTable(1, 6, tableFormat);
|
||||||
|
|
||||||
|
setCellText(*table, 0, 1, "Rohwertpunkte Total:");
|
||||||
|
setCellNumber(*table, 0, 3, getV2Points());
|
||||||
|
setCellNumber(*table, 0, 5, getSvkPoints());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ class V2SvkModel : public CheckableTestModel
|
||||||
public:
|
public:
|
||||||
V2SvkModel(QObject *parent);
|
V2SvkModel(QObject *parent);
|
||||||
|
|
||||||
unsigned int getV2Points();
|
unsigned int getV2Points() const;
|
||||||
unsigned int getSvkPoints();
|
unsigned int getSvkPoints() const;
|
||||||
|
|
||||||
void write(ESGRAF48::V2SvkModel &model) const;
|
void write(ESGRAF48::V2SvkModel &model) const;
|
||||||
void read(const ESGRAF48::V2SvkModel &model);
|
void read(const ESGRAF48::V2SvkModel &model);
|
||||||
|
@ -23,4 +23,5 @@ protected:
|
||||||
|
|
||||||
std::string getName() const override;
|
std::string getName() const override;
|
||||||
void printTableTo(QTextCursor &cursor) const override;
|
void printTableTo(QTextCursor &cursor) const override;
|
||||||
|
void printSummaryTo(QTextCursor &cursor) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -161,8 +161,6 @@ void MainWindow::print() const
|
||||||
QTextDocument printDoc;
|
QTextDocument printDoc;
|
||||||
QTextCursor printCursor(&printDoc);
|
QTextCursor printCursor(&printDoc);
|
||||||
m_dataModel.printTo(printCursor);
|
m_dataModel.printTo(printCursor);
|
||||||
|
|
||||||
printDoc.print(&printer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dataModelChanged()
|
void MainWindow::dataModelChanged()
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
class DataModel;
|
class DataModel;
|
||||||
class QDataWidgetMapper;
|
class QDataWidgetMapper;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue