Print metadata and v2svk header
parent
458de36cbc
commit
bf963adeb5
|
@ -60,6 +60,16 @@ void DataModel::read(std::istream &inStream)
|
|||
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::stringstream out;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "ResultModel.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QTextCursor>
|
||||
|
||||
class DataModel : public QObject
|
||||
{
|
||||
|
@ -34,6 +35,7 @@ public:
|
|||
public:
|
||||
DataModel(QObject *parent);
|
||||
|
||||
void printTo(QTextCursor &cursor) const;
|
||||
std::string toHtml() const;
|
||||
|
||||
void write(std::ostream &outStream) const;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "MetaDataModel.h"
|
||||
|
||||
#include <QTextTable>
|
||||
#include <QDebug>
|
||||
|
||||
#include <sstream>
|
||||
|
@ -130,33 +131,68 @@ void MetaDataModel::write(ESGRAF48::MetaDataModel &model) const
|
|||
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::ostringstream out;
|
||||
|
||||
out << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" frame=\"box\" rules=\"all\">"
|
||||
<< std::endl;
|
||||
out << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" frame=\"box\" rules=\"all\">" << std::endl;
|
||||
out << "<tr>" << std::endl;
|
||||
out << "<td width=\"25%\">Name, Vorname</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 << "<td colspan=\"2\">Bemerkungen</td>" << std::endl;
|
||||
out << "</tr>" << std::endl;
|
||||
out << "<tr>" << std::endl;
|
||||
out << "<td>Geburtsdatum</td>" << std::endl;
|
||||
out << "<td>" << m_dateOfBirth.toString("dd.MM.yyyy").toHtmlEscaped().toStdString() << "</td>"
|
||||
<< std::endl;
|
||||
out << "<td colspan=\"2\">Bemerkungen</td>" << std::endl;
|
||||
out << "</tr>" << std::endl;
|
||||
out << "<tr>" << 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 << "<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 << "<td>Alter am Testtag</td>" << std::endl;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QString>
|
||||
#include <QDate>
|
||||
#include <QJsonObject>
|
||||
#include <QTextCursor>
|
||||
|
||||
class MetaDataModel : public QAbstractTableModel
|
||||
{
|
||||
|
@ -33,6 +34,7 @@ public:
|
|||
void read(const ESGRAF48::MetaDataModel &model);
|
||||
void write(ESGRAF48::MetaDataModel &model) const;
|
||||
|
||||
void printTo(QTextCursor &cursor) const;
|
||||
std::string toHtml() 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));
|
||||
}
|
||||
|
||||
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 "V2SvkModel.pb.h"
|
||||
|
||||
#include <QTextCursor>
|
||||
|
||||
class V2SvkModel : public CheckableTestModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -16,6 +18,8 @@ public:
|
|||
void write(ESGRAF48::V2SvkModel &model) const;
|
||||
void read(const ESGRAF48::V2SvkModel &model);
|
||||
|
||||
void printTo(QTextCursor &cursor) const;
|
||||
|
||||
protected:
|
||||
bool isValidIndex(const QModelIndex &index) const override;
|
||||
};
|
||||
|
|
|
@ -144,7 +144,8 @@ void MainWindow::print() const
|
|||
}
|
||||
|
||||
QTextDocument printDoc;
|
||||
printDoc.setHtml(QString::fromStdString(m_dataModel->toHtml()));
|
||||
QTextCursor printCursor(&printDoc);
|
||||
m_dataModel->printTo(printCursor);
|
||||
|
||||
printDoc.print(&printer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue