Print metadata and v2svk header
This commit is contained in:
parent
458de36cbc
commit
bf963adeb5
7 changed files with 88 additions and 21 deletions
|
@ -60,6 +60,16 @@ void DataModel::read(std::istream &inStream)
|
||||||
m_passiv.read(dataModel.lateskillspassiv());
|
m_passiv.read(dataModel.lateskillspassiv());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataModel::printTo(QTextCursor &cursor) const
|
||||||
|
{
|
||||||
|
QTextCharFormat titleFormat;
|
||||||
|
titleFormat.setFontPointSize(18);
|
||||||
|
cursor.insertText("ESGRAF 4-8 Auswertungsbogen", titleFormat);
|
||||||
|
|
||||||
|
m_metaData.printTo(cursor);
|
||||||
|
m_v2Svk.printTo(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
std::string DataModel::toHtml() const
|
std::string DataModel::toHtml() const
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "ResultModel.h"
|
#include "ResultModel.h"
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QTextCursor>
|
||||||
|
|
||||||
class DataModel : public QObject
|
class DataModel : public QObject
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,7 @@ public:
|
||||||
public:
|
public:
|
||||||
DataModel(QObject *parent);
|
DataModel(QObject *parent);
|
||||||
|
|
||||||
|
void printTo(QTextCursor &cursor) const;
|
||||||
std::string toHtml() const;
|
std::string toHtml() const;
|
||||||
|
|
||||||
void write(std::ostream &outStream) const;
|
void write(std::ostream &outStream) const;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "MetaDataModel.h"
|
#include "MetaDataModel.h"
|
||||||
|
|
||||||
|
#include <QTextTable>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -130,33 +131,68 @@ void MetaDataModel::write(ESGRAF48::MetaDataModel &model) const
|
||||||
model.set_remarks(m_remarks.toStdString());
|
model.set_remarks(m_remarks.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetaDataModel::printTo(QTextCursor &cursor) const
|
||||||
|
{
|
||||||
|
cursor.insertBlock();
|
||||||
|
|
||||||
|
QTextTableFormat tableFormat;
|
||||||
|
tableFormat.setCellPadding(2);
|
||||||
|
tableFormat.setCellSpacing(0);
|
||||||
|
|
||||||
|
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::PercentageLength, 25),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 25),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 25),
|
||||||
|
QTextLength(QTextLength::PercentageLength, 25)});
|
||||||
|
|
||||||
|
QTextTable *table = cursor.insertTable(4, 4, tableFormat);
|
||||||
|
table->mergeCells(1, 2, 1, 2);
|
||||||
|
table->mergeCells(2, 2, 2, 2);
|
||||||
|
|
||||||
|
cursor.insertText("Name, Vorname");
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(m_participant);
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText("Untersucher(in)");
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(m_instructor);
|
||||||
|
cursor.movePosition(QTextCursor::NextRow);
|
||||||
|
|
||||||
|
cursor.insertText("Geburtsdatum");
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(m_dateOfBirth.toString("dd.MM.yyyy"));
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText("Bemerkungen:");
|
||||||
|
cursor.movePosition(QTextCursor::NextRow);
|
||||||
|
|
||||||
|
cursor.insertText("Untersuchungsdatum");
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(m_dateOfTest.toString("dd.MM.yyyy"));
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(m_remarks.trimmed());
|
||||||
|
cursor.movePosition(QTextCursor::NextRow);
|
||||||
|
|
||||||
|
cursor.insertText("Alter am Testtag");
|
||||||
|
cursor.movePosition(QTextCursor::NextCell);
|
||||||
|
cursor.insertText(getAge().toString().c_str());
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::NextBlock);
|
||||||
|
}
|
||||||
|
|
||||||
std::string MetaDataModel::toHtml() const
|
std::string MetaDataModel::toHtml() const
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
out << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" frame=\"box\" rules=\"all\">"
|
out << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" frame=\"box\" rules=\"all\">" << std::endl;
|
||||||
<< std::endl;
|
|
||||||
out << "<tr>" << std::endl;
|
out << "<tr>" << std::endl;
|
||||||
out << "<td width=\"25%\">Name, Vorname</td>" << std::endl;
|
out << "<td colspan=\"2\">Bemerkungen</td>" << std::endl;
|
||||||
out << "<td width=\"25%\">" << m_participant.toHtmlEscaped().toStdString() << "</td>"
|
|
||||||
<< std::endl;
|
|
||||||
out << "<td width=\"25%\">Untersucher(in)</td>" << std::endl;
|
|
||||||
out << "<td width=\"25%\">" << m_instructor.toHtmlEscaped().toStdString() << "</td>"
|
|
||||||
<< std::endl;
|
|
||||||
out << "</tr>" << std::endl;
|
out << "</tr>" << std::endl;
|
||||||
out << "<tr>" << std::endl;
|
out << "<tr>" << std::endl;
|
||||||
out << "<td>Geburtsdatum</td>" << std::endl;
|
out << "<td>Untersuchungsdatum</td>" << std::endl;
|
||||||
out << "<td>" << m_dateOfBirth.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
|
out << "<td>" << m_dateOfTest.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
out << "<td colspan=\"2\">Bemerkungen</td>" << std::endl;
|
out << "<td colspan=\"2\" rowspan=\"2\">"
|
||||||
out << "</tr>" << std::endl;
|
<< m_remarks.trimmed().toHtmlEscaped().replace("\n", "<br>").toStdString() << "</td>"
|
||||||
out << "<tr>" << std::endl;
|
<< std::endl;
|
||||||
out << "<td>Untersuchungsdatum</td>" << std::endl;
|
|
||||||
out << "<td>" << m_dateOfTest.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
|
|
||||||
<< std::endl;
|
|
||||||
out << "<td colspan=\"2\" rowspan=\"2\">"
|
|
||||||
<< m_remarks.trimmed().toHtmlEscaped().replace("\n", "<br>").toStdString() << "</td>"
|
|
||||||
<< std::endl;
|
|
||||||
out << "</tr>" << std::endl;
|
out << "</tr>" << std::endl;
|
||||||
out << "<tr>" << std::endl;
|
out << "<tr>" << std::endl;
|
||||||
out << "<td>Alter am Testtag</td>" << std::endl;
|
out << "<td>Alter am Testtag</td>" << std::endl;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QTextCursor>
|
||||||
|
|
||||||
class MetaDataModel : public QAbstractTableModel
|
class MetaDataModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
|
@ -33,6 +34,7 @@ public:
|
||||||
void read(const ESGRAF48::MetaDataModel &model);
|
void read(const ESGRAF48::MetaDataModel &model);
|
||||||
void write(ESGRAF48::MetaDataModel &model) const;
|
void write(ESGRAF48::MetaDataModel &model) const;
|
||||||
|
|
||||||
|
void printTo(QTextCursor &cursor) const;
|
||||||
std::string toHtml() const;
|
std::string toHtml() const;
|
||||||
|
|
||||||
Age getAge() const
|
Age getAge() const
|
||||||
|
|
|
@ -199,3 +199,15 @@ void V2SvkModel::read(const ESGRAF48::V2SvkModel &model)
|
||||||
|
|
||||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V2SvkModel::printTo(QTextCursor &cursor) const
|
||||||
|
{
|
||||||
|
cursor.insertBlock();
|
||||||
|
|
||||||
|
QTextCharFormat headerFormat;
|
||||||
|
headerFormat.setFontPointSize(12);
|
||||||
|
cursor.insertText("Subtest 1: Verbzweitstellungsregel (V2) und Subjekt-Verb-Kontrollregel (SVK)", headerFormat);
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::NextBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "CheckableTestModel.h"
|
#include "CheckableTestModel.h"
|
||||||
#include "V2SvkModel.pb.h"
|
#include "V2SvkModel.pb.h"
|
||||||
|
|
||||||
|
#include <QTextCursor>
|
||||||
|
|
||||||
class V2SvkModel : public CheckableTestModel
|
class V2SvkModel : public CheckableTestModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -16,6 +18,8 @@ public:
|
||||||
void write(ESGRAF48::V2SvkModel &model) const;
|
void write(ESGRAF48::V2SvkModel &model) const;
|
||||||
void read(const ESGRAF48::V2SvkModel &model);
|
void read(const ESGRAF48::V2SvkModel &model);
|
||||||
|
|
||||||
|
void printTo(QTextCursor &cursor) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isValidIndex(const QModelIndex &index) const override;
|
bool isValidIndex(const QModelIndex &index) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -144,7 +144,8 @@ void MainWindow::print() const
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument printDoc;
|
QTextDocument printDoc;
|
||||||
printDoc.setHtml(QString::fromStdString(m_dataModel->toHtml()));
|
QTextCursor printCursor(&printDoc);
|
||||||
|
m_dataModel->printTo(printCursor);
|
||||||
|
|
||||||
printDoc.print(&printer);
|
printDoc.print(&printer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue