Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+347
-391
@@ -1,430 +1,386 @@
|
||||
|
||||
|
||||
|
||||
#include "printing.h"
|
||||
|
||||
#include "printing_base.h"
|
||||
|
||||
#include <KDReports/KDReportsReport>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <KDReports/KDReportsReport>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
#include <QTreeView>
|
||||
#include <QListView>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QTextDocument>
|
||||
#include <QTextCursor>
|
||||
|
||||
#include <QPrinter>
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QPainter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QString>
|
||||
#include <QTableView>
|
||||
#include <QTableWidget>
|
||||
#include <QLabel>
|
||||
#include <QTextTable>
|
||||
#include <QDebug>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
#include <QTextEdit>
|
||||
#include <QTextTable>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace LtsPrinting
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
bool itemsHaveNoChildren(const QTreeView *view)
|
||||
bool itemsHaveNoChildren(const QTreeView* view)
|
||||
{
|
||||
const QAbstractItemModel *itemModel = view->model();
|
||||
int rowCount = itemModel->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
if (itemModel->hasChildren(itemModel->index(row, 0)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
const QAbstractItemModel* itemModel = view->model();
|
||||
int rowCount = itemModel->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
if (itemModel->hasChildren(itemModel->index(row, 0)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void setNameOfExerciseAndOperator(LtsSession::LtsSession *session, LtsPrinting::Base &nglPrinter)
|
||||
void setNameOfExerciseAndOperator(LtsSession::LtsSession* session, LtsPrinting::Base& nglPrinter)
|
||||
{
|
||||
if ( session->exerciseId() != 0 )
|
||||
nglPrinter.setCurrentExerciseName(QObject::tr("Exercise: %1 %2").arg(session->exerciseData()->exName,
|
||||
session->exerciseData()->phName));
|
||||
else
|
||||
nglPrinter.setCurrentExerciseName(QObject::tr("Exercise: Administration") );
|
||||
if (session->exerciseId() != 0)
|
||||
nglPrinter.setCurrentExerciseName(
|
||||
QObject::tr("Exercise: %1 %2").arg(session->exerciseData()->exName, session->exerciseData()->phName));
|
||||
else
|
||||
nglPrinter.setCurrentExerciseName(QObject::tr("Exercise: Administration"));
|
||||
|
||||
LtsSessionData::LtsSessionData *sessionData = LtsSessionData::LtsSessionData::getInstance();
|
||||
nglPrinter.setOperatorName(sessionData->getOperatorName());
|
||||
LtsSessionData::LtsSessionData* sessionData = LtsSessionData::LtsSessionData::getInstance();
|
||||
nglPrinter.setOperatorName(sessionData->getOperatorName());
|
||||
}
|
||||
|
||||
|
||||
void printView(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QAbstractItemView *view,
|
||||
void printView(LtsSession::LtsSession* session, QWidget* dialogParent, const QAbstractItemView* view,
|
||||
const QString& headingHtml)
|
||||
{
|
||||
const QTableView *tableView = dynamic_cast<const QTableView *>(view);
|
||||
const QTreeView *treeView = dynamic_cast<const QTreeView *>(view);
|
||||
QSet<int> hiddenCols;
|
||||
const QTableView* tableView = dynamic_cast<const QTableView*>(view);
|
||||
const QTreeView* treeView = dynamic_cast<const QTreeView*>(view);
|
||||
QSet<int> hiddenCols;
|
||||
|
||||
int switchNum = 0;
|
||||
if (tableView != nullptr)
|
||||
{
|
||||
switchNum = 1;
|
||||
hiddenCols = LtsPrinting::Base::getHiddenCols(tableView);
|
||||
}
|
||||
else if (treeView != nullptr)
|
||||
{
|
||||
switchNum = 2;
|
||||
hiddenCols = LtsPrinting::Base::getHiddenCols(treeView);
|
||||
if (itemsHaveNoChildren(treeView)) switchNum = 1;
|
||||
}
|
||||
else if (dynamic_cast<const QListView *>(view) != nullptr)
|
||||
switchNum = 3;
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(dialogParent->windowTitle()),
|
||||
dialogParent->windowTitle(),
|
||||
QPrinter::A4, QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
QString htmlStr;
|
||||
|
||||
switch (switchNum)
|
||||
{
|
||||
case 1:
|
||||
nglPrinter.printTableData(htmlStr, view, QString(), hiddenCols);
|
||||
break;
|
||||
case 2:
|
||||
nglPrinter.printTreeData(htmlStr, view, QString(), hiddenCols);
|
||||
break;
|
||||
case 3:
|
||||
nglPrinter.printListData(htmlStr, view, QString());
|
||||
break;
|
||||
}
|
||||
cursor.insertHtml(headingHtml);
|
||||
cursor.insertHtml(htmlStr);
|
||||
nglPrinter.print(&doc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void printView(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
QAbstractItemView *view,
|
||||
const QString& headingHtml)
|
||||
{
|
||||
const QAbstractItemView *itemView = static_cast<const QAbstractItemView *>(view);
|
||||
printView(session, dialogParent, itemView, headingHtml);
|
||||
}
|
||||
|
||||
|
||||
void printImage(LtsSession::LtsSession *session, QWidget *dialogParent,
|
||||
const QImage &image, const QString &imageTitle, const QString &description,
|
||||
const QPrinter::PageSize &pageSize, const QPrinter::Orientation &pageOrientation)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(windowTitle),
|
||||
windowTitle,
|
||||
pageSize, pageOrientation);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
nglPrinter.printDocImage(doc, image, imageTitle, description);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
|
||||
void printImages(LtsSession::LtsSession *session, QWidget *dialogParent,
|
||||
const QString &docName, QVector<QImage> &images,
|
||||
QVector<QString> &imageTitles, QVector<QString> &descriptions,
|
||||
const QPrinter::PageSize &pageSize, const QPrinter::Orientation &pageOrientation)
|
||||
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, docName);
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(docName),
|
||||
docName, pageSize, pageOrientation);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
for ( int i = 0; i < images.size(); i++)
|
||||
{
|
||||
QString imageTitle, imageDescription;
|
||||
if (imageTitles.size() > i && imageTitles[i].size() > 0)
|
||||
imageTitle = imageTitles[i];
|
||||
if (descriptions.size() > i && descriptions[i].size() > 0)
|
||||
imageDescription = descriptions[i];
|
||||
nglPrinter.printDocImage(doc, images[i], imageTitle, imageDescription);
|
||||
nglPrinter.printSinglePage(&doc);
|
||||
doc.clear();
|
||||
|
||||
if (i != images.size() -1)
|
||||
nglPrinter.newPage();
|
||||
|
||||
}
|
||||
|
||||
nglPrinter.printDone();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void printPDFImages(QWidget *dialogParent, const QString &docName, const QString &printPath, QVector<QImage> &images)
|
||||
|
||||
{
|
||||
QPrinter printer;
|
||||
|
||||
printer.setColorMode(QPrinter::ColorMode::Color);
|
||||
printer.setOrientation(QPrinter::Orientation::Portrait);
|
||||
printer.setPageSize(QPrinter::PageSize::A4);
|
||||
QString fn = docName;
|
||||
fn = fn.remove(QLatin1Char(' '));
|
||||
fn = fn.remove(QLatin1String(".."));
|
||||
fn = fn.remove(QLatin1Char('/'));
|
||||
fn = printPath + fn;
|
||||
if (!fn.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
|
||||
fn += QLatin1String(".pdf");
|
||||
#ifndef WIN32
|
||||
printer.setOutputFileName(fn);
|
||||
#endif
|
||||
printer.setOutputFormat(QPrinter::NativeFormat);
|
||||
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, dialogParent);
|
||||
dialog->setWindowTitle(QObject::tr("Print %1").arg(docName));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&printer);
|
||||
int lastItem = images.size() - 1;
|
||||
for (int i = 0; i < images.size(); ++i)
|
||||
{
|
||||
QRect rect = painter.viewport();
|
||||
QSize size = images.at(i).size();
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
painter.setViewport(rect.x(), rect.y(),
|
||||
size.width(), size.height());
|
||||
painter.setWindow(images.at(i).rect());
|
||||
painter.drawImage(0, 0, images.at(i));
|
||||
if (i != lastItem)
|
||||
printer.newPage();
|
||||
}
|
||||
painter.end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void printReport( LtsSession::LtsSession *session, QWidget *dialogParent, KDReports::Report& report )
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(dialogParent->windowTitle()),
|
||||
dialogParent->windowTitle(),
|
||||
QPrinter::A3, QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator( session, nglPrinter );
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
report.setWidthForEndlessPrinter(0);
|
||||
report.setPageSize(QPrinter::A3);
|
||||
report.setOrientation(QPrinter::Landscape);
|
||||
|
||||
LtsPrinting::Base::printReportData(doc, report);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
|
||||
void printWidget(LtsSession::LtsSession *session, QWidget *dialogParent, QWidget *widget, const QString &title)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
QImage image(widget->size(), QImage::Format_ARGB32);
|
||||
widget->render(&image);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(windowTitle),
|
||||
windowTitle,
|
||||
QPrinter::A3, QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
nglPrinter.printDocImage(doc, image, title);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
void printMessage(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QString &subject, const QString &subjectContent,
|
||||
const QString &from, const QString &fromContent,
|
||||
const QString &to, const QString &toContent,
|
||||
const QString &msgTextContent,
|
||||
const QString &time, const QString &timeContent)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QString windowTitle = subject;
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, subject);
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(windowTitle),
|
||||
windowTitle,
|
||||
QPrinter::A4, QPrinter::Portrait);
|
||||
|
||||
QString str = QString(QStringLiteral("<H2><strong>%1</strong> %2 </H2>")).arg(subject).arg(subjectContent);
|
||||
str.append( QString(QStringLiteral("<strong>%1</strong> %2<br>")).arg(time).arg(timeContent));
|
||||
str.append( QString(QStringLiteral("<strong>%1</strong> %2<br>")).arg(from).arg(fromContent));
|
||||
str.append( QString(QStringLiteral("<strong>%1</strong> %2<hr>")).arg(to).arg(toContent));
|
||||
str.append( QString(QStringLiteral("%1")).arg(msgTextContent));
|
||||
|
||||
doc.setHtml(str);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
|
||||
void printStoryboard(LtsSession::LtsSession *session, QWidget *dialogParent, QAbstractItemView *view, const QString &headingHtml)
|
||||
{
|
||||
QTableWidget *tbl = dynamic_cast< QTableWidget *>(view);
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
QTextBlockFormat tbfFormat;
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_Auto);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent,
|
||||
QObject::tr("Print %1").arg(windowTitle),
|
||||
windowTitle,
|
||||
QPrinter::A4, QPrinter::Portrait);
|
||||
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
const int rows = tbl->rowCount();
|
||||
cursor.insertHtml(headingHtml);
|
||||
|
||||
double currentHeight = 0;
|
||||
double previousPagesHeight = 0;
|
||||
QString htmlStr;
|
||||
for (int rowCounter = 0; rowCounter < rows; rowCounter++)
|
||||
{
|
||||
|
||||
htmlStr.append(QStringLiteral("<table>"));
|
||||
QTextEdit *labelForFirstCell = (QTextEdit*)tbl->cellWidget(rowCounter, 0);
|
||||
QString stringFirstColumn = labelForFirstCell->toHtml();
|
||||
|
||||
QTextEdit *labelSecondColumn = (QTextEdit*)tbl->cellWidget(rowCounter, 1);
|
||||
QString stringSecondColumn = labelSecondColumn->toHtml();
|
||||
|
||||
QTextEdit *labelThirdColumn = (QTextEdit*)tbl->cellWidget(rowCounter, 2);
|
||||
QString stringThirdColumn = labelThirdColumn->toHtml();
|
||||
|
||||
for (int rowInCellCounter = 0; rowInCellCounter < stringSecondColumn.split(QStringLiteral("<br>")).size(); ++rowInCellCounter)
|
||||
int switchNum = 0;
|
||||
if (tableView != nullptr)
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<tr>"));
|
||||
|
||||
if (rowInCellCounter < stringFirstColumn.split(QStringLiteral("<br>")).size())
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<td width = \"25%\">"));
|
||||
htmlStr.append(stringFirstColumn.split(QStringLiteral("<br>"))[rowInCellCounter]);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<td width = \"25%\"> "));
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
}
|
||||
QString currentTextSecond = stringSecondColumn.split(QStringLiteral("<br>"))[rowInCellCounter];
|
||||
htmlStr.append(QStringLiteral("<td width = \"37%\">"));
|
||||
htmlStr.append(currentTextSecond);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
|
||||
QString currentTextThird = stringThirdColumn.split(QStringLiteral("<br>"))[rowInCellCounter];
|
||||
htmlStr.append(QStringLiteral("<td width = \"37%\">"));
|
||||
htmlStr.append(currentTextThird);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
htmlStr.append(QStringLiteral("</tr>"));
|
||||
switchNum = 1;
|
||||
hiddenCols = LtsPrinting::Base::getHiddenCols(tableView);
|
||||
}
|
||||
QTextDocument tempDoc;
|
||||
tempDoc.setPageSize(doc.pageSize());
|
||||
tempDoc.setHtml(htmlStr);
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
|
||||
if (currentHeight + tempDoc.size().height() > nglPrinter.pageSizeInMM().height())
|
||||
else if (treeView != nullptr)
|
||||
{
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_AlwaysBefore);
|
||||
cursor.insertBlock(tbfFormat);
|
||||
previousPagesHeight = doc.size().height();
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
switchNum = 2;
|
||||
hiddenCols = LtsPrinting::Base::getHiddenCols(treeView);
|
||||
if (itemsHaveNoChildren(treeView))
|
||||
switchNum = 1;
|
||||
}
|
||||
else if (dynamic_cast<const QListView*>(view) != nullptr)
|
||||
switchNum = 3;
|
||||
else
|
||||
{
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_Auto);
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
return;
|
||||
}
|
||||
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(dialogParent->windowTitle()),
|
||||
dialogParent->windowTitle(), QPrinter::A4, QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
QString htmlStr;
|
||||
|
||||
switch (switchNum)
|
||||
{
|
||||
case 1:
|
||||
nglPrinter.printTableData(htmlStr, view, QString(), hiddenCols);
|
||||
break;
|
||||
case 2:
|
||||
nglPrinter.printTreeData(htmlStr, view, QString(), hiddenCols);
|
||||
break;
|
||||
case 3:
|
||||
nglPrinter.printListData(htmlStr, view, QString());
|
||||
break;
|
||||
}
|
||||
cursor.insertHtml(headingHtml);
|
||||
cursor.insertHtml(htmlStr);
|
||||
htmlStr.clear();
|
||||
}
|
||||
htmlStr.append(QStringLiteral("</table>"));
|
||||
cursor.insertHtml(htmlStr);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
nglPrinter.print(&doc);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
|
||||
void printView(LtsSession::LtsSession* session, QWidget* dialogParent, QAbstractItemView* view,
|
||||
const QString& headingHtml)
|
||||
{
|
||||
const QAbstractItemView* itemView = static_cast<const QAbstractItemView*>(view);
|
||||
printView(session, dialogParent, itemView, headingHtml);
|
||||
}
|
||||
|
||||
void printImage(LtsSession::LtsSession* session, QWidget* dialogParent, const QImage& image, const QString& imageTitle,
|
||||
const QString& description, const QPrinter::PageSize& pageSize,
|
||||
const QPrinter::Orientation& pageOrientation)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(windowTitle), windowTitle, pageSize,
|
||||
pageOrientation);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
nglPrinter.printDocImage(doc, image, imageTitle, description);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
void printImages(LtsSession::LtsSession* session, QWidget* dialogParent, const QString& docName,
|
||||
QVector<QImage>& images, QVector<QString>& imageTitles, QVector<QString>& descriptions,
|
||||
const QPrinter::PageSize& pageSize, const QPrinter::Orientation& pageOrientation)
|
||||
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, docName);
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(docName), docName, pageSize,
|
||||
pageOrientation);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
for (int i = 0; i < images.size(); i++)
|
||||
{
|
||||
QString imageTitle, imageDescription;
|
||||
if (imageTitles.size() > i && imageTitles[i].size() > 0)
|
||||
imageTitle = imageTitles[i];
|
||||
if (descriptions.size() > i && descriptions[i].size() > 0)
|
||||
imageDescription = descriptions[i];
|
||||
nglPrinter.printDocImage(doc, images[i], imageTitle, imageDescription);
|
||||
nglPrinter.printSinglePage(&doc);
|
||||
doc.clear();
|
||||
|
||||
if (i != images.size() - 1)
|
||||
nglPrinter.newPage();
|
||||
}
|
||||
|
||||
nglPrinter.printDone();
|
||||
}
|
||||
|
||||
void printPDFImages(QWidget* dialogParent, const QString& docName, const QString& printPath, QVector<QImage>& images)
|
||||
|
||||
{
|
||||
QPrinter printer;
|
||||
|
||||
printer.setColorMode(QPrinter::ColorMode::Color);
|
||||
printer.setOrientation(QPrinter::Orientation::Portrait);
|
||||
printer.setPageSize(QPrinter::PageSize::A4);
|
||||
QString fn = docName;
|
||||
fn = fn.remove(QLatin1Char(' '));
|
||||
fn = fn.remove(QLatin1String(".."));
|
||||
fn = fn.remove(QLatin1Char('/'));
|
||||
fn = printPath + fn;
|
||||
if (!fn.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
|
||||
fn += QLatin1String(".pdf");
|
||||
#ifndef WIN32
|
||||
printer.setOutputFileName(fn);
|
||||
#endif
|
||||
printer.setOutputFormat(QPrinter::NativeFormat);
|
||||
|
||||
QPrintDialog* dialog = new QPrintDialog(&printer, dialogParent);
|
||||
dialog->setWindowTitle(QObject::tr("Print %1").arg(docName));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&printer);
|
||||
int lastItem = images.size() - 1;
|
||||
for (int i = 0; i < images.size(); ++i)
|
||||
{
|
||||
QRect rect = painter.viewport();
|
||||
QSize size = images.at(i).size();
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
|
||||
painter.setWindow(images.at(i).rect());
|
||||
painter.drawImage(0, 0, images.at(i));
|
||||
if (i != lastItem)
|
||||
printer.newPage();
|
||||
}
|
||||
painter.end();
|
||||
}
|
||||
|
||||
void printReport(LtsSession::LtsSession* session, QWidget* dialogParent, KDReports::Report& report)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(dialogParent->windowTitle()),
|
||||
dialogParent->windowTitle(), QPrinter::A3, QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
report.setWidthForEndlessPrinter(0);
|
||||
report.setPageSize(QPrinter::A3);
|
||||
report.setOrientation(QPrinter::Landscape);
|
||||
|
||||
LtsPrinting::Base::printReportData(doc, report);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
void printWidget(LtsSession::LtsSession* session, QWidget* dialogParent, QWidget* widget, const QString& title)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
QImage image(widget->size(), QImage::Format_ARGB32);
|
||||
widget->render(&image);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(windowTitle), windowTitle, QPrinter::A3,
|
||||
QPrinter::Landscape);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
nglPrinter.printDocImage(doc, image, title);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
void printMessage(LtsSession::LtsSession* session, QWidget* dialogParent, const QString& subject,
|
||||
const QString& subjectContent, const QString& from, const QString& fromContent, const QString& to,
|
||||
const QString& toContent, const QString& msgTextContent, const QString& time,
|
||||
const QString& timeContent)
|
||||
{
|
||||
QTextDocument doc;
|
||||
QString windowTitle = subject;
|
||||
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, subject);
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(windowTitle), windowTitle, QPrinter::A4,
|
||||
QPrinter::Portrait);
|
||||
|
||||
QString str = QString(QStringLiteral("<H2><strong>%1</strong> %2 </H2>")).arg(subject).arg(subjectContent);
|
||||
str.append(QString(QStringLiteral("<strong>%1</strong> %2<br>")).arg(time).arg(timeContent));
|
||||
str.append(QString(QStringLiteral("<strong>%1</strong> %2<br>")).arg(from).arg(fromContent));
|
||||
str.append(QString(QStringLiteral("<strong>%1</strong> %2<hr>")).arg(to).arg(toContent));
|
||||
str.append(QString(QStringLiteral("%1")).arg(msgTextContent));
|
||||
|
||||
doc.setHtml(str);
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
void printStoryboard(LtsSession::LtsSession* session, QWidget* dialogParent, QAbstractItemView* view,
|
||||
const QString& headingHtml)
|
||||
{
|
||||
QTableWidget* tbl = dynamic_cast<QTableWidget*>(view);
|
||||
QTextDocument doc;
|
||||
QTextCursor cursor(&doc);
|
||||
|
||||
QTextBlockFormat tbfFormat;
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_Auto);
|
||||
|
||||
QString windowTitle = dialogParent->windowTitle();
|
||||
doc.setMetaInformation(QTextDocument::DocumentTitle, dialogParent->windowTitle());
|
||||
|
||||
LtsPrinting::Base nglPrinter(doc, dialogParent, QObject::tr("Print %1").arg(windowTitle), windowTitle, QPrinter::A4,
|
||||
QPrinter::Portrait);
|
||||
|
||||
if (!nglPrinter.printer())
|
||||
return;
|
||||
|
||||
const int rows = tbl->rowCount();
|
||||
cursor.insertHtml(headingHtml);
|
||||
|
||||
double currentHeight = 0;
|
||||
double previousPagesHeight = 0;
|
||||
QString htmlStr;
|
||||
for (int rowCounter = 0; rowCounter < rows; rowCounter++)
|
||||
{
|
||||
|
||||
htmlStr.append(QStringLiteral("<table>"));
|
||||
QTextEdit* labelForFirstCell = (QTextEdit*)tbl->cellWidget(rowCounter, 0);
|
||||
QString stringFirstColumn = labelForFirstCell->toHtml();
|
||||
|
||||
QTextEdit* labelSecondColumn = (QTextEdit*)tbl->cellWidget(rowCounter, 1);
|
||||
QString stringSecondColumn = labelSecondColumn->toHtml();
|
||||
|
||||
QTextEdit* labelThirdColumn = (QTextEdit*)tbl->cellWidget(rowCounter, 2);
|
||||
QString stringThirdColumn = labelThirdColumn->toHtml();
|
||||
|
||||
for (int rowInCellCounter = 0; rowInCellCounter < stringSecondColumn.split(QStringLiteral("<br>")).size();
|
||||
++rowInCellCounter)
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<tr>"));
|
||||
|
||||
if (rowInCellCounter < stringFirstColumn.split(QStringLiteral("<br>")).size())
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<td width = \"25%\">"));
|
||||
htmlStr.append(stringFirstColumn.split(QStringLiteral("<br>"))[rowInCellCounter]);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlStr.append(QStringLiteral("<td width = \"25%\"> "));
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
}
|
||||
QString currentTextSecond = stringSecondColumn.split(QStringLiteral("<br>"))[rowInCellCounter];
|
||||
htmlStr.append(QStringLiteral("<td width = \"37%\">"));
|
||||
htmlStr.append(currentTextSecond);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
|
||||
QString currentTextThird = stringThirdColumn.split(QStringLiteral("<br>"))[rowInCellCounter];
|
||||
htmlStr.append(QStringLiteral("<td width = \"37%\">"));
|
||||
htmlStr.append(currentTextThird);
|
||||
htmlStr.append(QStringLiteral("</td>"));
|
||||
htmlStr.append(QStringLiteral("</tr>"));
|
||||
}
|
||||
QTextDocument tempDoc;
|
||||
tempDoc.setPageSize(doc.pageSize());
|
||||
tempDoc.setHtml(htmlStr);
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
|
||||
if (currentHeight + tempDoc.size().height() > nglPrinter.pageSizeInMM().height())
|
||||
{
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_AlwaysBefore);
|
||||
cursor.insertBlock(tbfFormat);
|
||||
previousPagesHeight = doc.size().height();
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
tbfFormat.setPageBreakPolicy(QTextFormat::PageBreakFlag::PageBreak_Auto);
|
||||
currentHeight = doc.size().height() - previousPagesHeight;
|
||||
}
|
||||
cursor.insertHtml(htmlStr);
|
||||
htmlStr.clear();
|
||||
}
|
||||
htmlStr.append(QStringLiteral("</table>"));
|
||||
cursor.insertHtml(htmlStr);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
setNameOfExerciseAndOperator(session, nglPrinter);
|
||||
nglPrinter.print(&doc);
|
||||
}
|
||||
|
||||
} // namespace LtsPrinting
|
||||
Executable → Regular
+36
-64
@@ -1,94 +1,66 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtPrintSupport/QPrinter>
|
||||
|
||||
#ifndef LTSPRINTING_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSPRINTING_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSPRINTING_LIB)
|
||||
# define LTSPRINTING_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSPRINTING_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSPRINTING_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSPRINTING_LIB)
|
||||
#define LTSPRINTING_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSPRINTING_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class QWidget;
|
||||
class QAbstractItemView;
|
||||
class QImage;
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace KDReports
|
||||
{
|
||||
class Report;
|
||||
}
|
||||
|
||||
namespace LtsPrinting
|
||||
{
|
||||
|
||||
LTSPRINTING_EXPORT void printView(LtsSession::LtsSession* session, QWidget* dialogParent, const QAbstractItemView* view,
|
||||
const QString& headingHtml = QString());
|
||||
LTSPRINTING_EXPORT void printView(LtsSession::LtsSession* session, QWidget* dialogParent, QAbstractItemView* view,
|
||||
const QString& headingHtml = QString());
|
||||
LTSPRINTING_EXPORT void printStoryboard(LtsSession::LtsSession* session, QWidget* dialogParent, QAbstractItemView* view,
|
||||
const QString& headingHtml = QString());
|
||||
|
||||
LTSPRINTING_EXPORT void printView(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QAbstractItemView *view,
|
||||
const QString &headingHtml = QString());
|
||||
LTSPRINTING_EXPORT void printView(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
QAbstractItemView *view,
|
||||
const QString &headingHtml = QString());
|
||||
LTSPRINTING_EXPORT void printStoryboard(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
QAbstractItemView *view,
|
||||
const QString &headingHtml = QString());
|
||||
LTSPRINTING_EXPORT void printImage(LtsSession::LtsSession* session, QWidget* dialogParent, const QImage& image,
|
||||
const QString& imageTitle, const QString& description,
|
||||
const QPrinter::PageSize& pageSize = QPrinter::A3,
|
||||
const QPrinter::Orientation& pageOrientation = QPrinter::Landscape);
|
||||
|
||||
LTSPRINTING_EXPORT void printImages(LtsSession::LtsSession* session, QWidget* dialogParent, const QString& docName,
|
||||
QVector<QImage>& images, QVector<QString>& imageTitles,
|
||||
QVector<QString>& descriptions, const QPrinter::PageSize& pageSize = QPrinter::A3,
|
||||
const QPrinter::Orientation& pageOrientation = QPrinter::Landscape);
|
||||
|
||||
LTSPRINTING_EXPORT void printImage(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QImage &image,
|
||||
const QString &imageTitle,
|
||||
const QString &description,
|
||||
const QPrinter::PageSize &pageSize = QPrinter::A3,
|
||||
const QPrinter::Orientation &pageOrientation = QPrinter::Landscape);
|
||||
LTSPRINTING_EXPORT void printPDFImages(QWidget* dialogParent, const QString& docName, const QString& printPath,
|
||||
QVector<QImage>& images);
|
||||
|
||||
LTSPRINTING_EXPORT void printReport(LtsSession::LtsSession* session, QWidget* dialogParent, KDReports::Report& report);
|
||||
|
||||
LTSPRINTING_EXPORT void printWidget(LtsSession::LtsSession* session, QWidget* dialogParent, QWidget* widget,
|
||||
const QString& title);
|
||||
|
||||
LTSPRINTING_EXPORT void printImages(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QString &docName,
|
||||
QVector < QImage> &images,
|
||||
QVector < QString> &imageTitles,
|
||||
QVector < QString> &descriptions,
|
||||
const QPrinter::PageSize &pageSize = QPrinter::A3,
|
||||
const QPrinter::Orientation &pageOrientation = QPrinter::Landscape);
|
||||
|
||||
|
||||
|
||||
LTSPRINTING_EXPORT void printPDFImages(QWidget *dialogParent,
|
||||
const QString &docName,
|
||||
const QString &printPath,
|
||||
QVector<QImage> &images);
|
||||
|
||||
|
||||
|
||||
LTSPRINTING_EXPORT void printReport( LtsSession::LtsSession *session, QWidget *dialogParent, KDReports::Report& report );
|
||||
|
||||
|
||||
|
||||
LTSPRINTING_EXPORT void printWidget(LtsSession::LtsSession *session, QWidget *dialogParent, QWidget *widget, const QString &title);
|
||||
|
||||
|
||||
|
||||
LTSPRINTING_EXPORT void printMessage(LtsSession::LtsSession *session,
|
||||
QWidget *dialogParent,
|
||||
const QString &subject, const QString &subjectContent,
|
||||
const QString &from, const QString &fromContent,
|
||||
const QString &to, const QString &toContent,
|
||||
const QString &msgTextContent,
|
||||
const QString &time, const QString &timeContent);
|
||||
|
||||
}
|
||||
LTSPRINTING_EXPORT void printMessage(LtsSession::LtsSession* session, QWidget* dialogParent, const QString& subject,
|
||||
const QString& subjectContent, const QString& from, const QString& fromContent,
|
||||
const QString& to, const QString& toContent, const QString& msgTextContent,
|
||||
const QString& time, const QString& timeContent);
|
||||
|
||||
} // namespace LtsPrinting
|
||||
Executable → Regular
+817
-995
File diff suppressed because it is too large.
Load diff
Executable → Regular
+143
-214
@@ -9,7 +9,8 @@ namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
class Settings;
|
||||
}
|
||||
} // namespace NGL
|
||||
|
||||
namespace KDReports
|
||||
{
|
||||
class Report;
|
||||
@@ -28,273 +29,201 @@ static constexpr int DECORATION_EXTENT = 50;
|
||||
static constexpr int DOC_MARGIN = 60;
|
||||
static constexpr int ProjectIconHeight = 40;
|
||||
|
||||
static const QLatin1String
|
||||
HeaderText("<table width=\"100%\">"
|
||||
" <tr>"
|
||||
" <td align=\"left\" valign=\"bottom\">&exercise;</td>"
|
||||
" <td align=\"center\" valign=\"bottom\">&title;</td>"
|
||||
" <td align=\"right\" valign=\"top\"><img src=\"&logo;\" height=\"&logoHeight;\" alt=\"Logo\" /></td>"
|
||||
" </tr>"
|
||||
"</table>");
|
||||
|
||||
static const QLatin1String HeaderText(
|
||||
"<table width=\"100%\">"
|
||||
" <tr>"
|
||||
" <td align=\"left\" valign=\"bottom\">&exercise;</td>"
|
||||
" <td align=\"center\" valign=\"bottom\">&title;</td>"
|
||||
" <td align=\"right\" valign=\"top\"><img src=\"&logo;\" height=\"&logoHeight;\" alt=\"Logo\" /></td>"
|
||||
" </tr>"
|
||||
"</table>");
|
||||
|
||||
static const QLatin1String FooterText(
|
||||
"<table width=\"100%\">"
|
||||
" <tr>"
|
||||
" <td align=\"left\">&date; -- &user;</td>"
|
||||
" <td align=\"center\" valign=\"bottom\">&footertitle;</td>"
|
||||
" <td align=\"right\">&page;</td>"
|
||||
" </tr>"
|
||||
"</table>");
|
||||
|
||||
static const QLatin1String FooterText("<table width=\"100%\">"
|
||||
" <tr>"
|
||||
" <td align=\"left\">&date; -- &user;</td>"
|
||||
" <td align=\"center\" valign=\"bottom\">&footertitle;</td>"
|
||||
" <td align=\"right\">&page;</td>"
|
||||
" </tr>"
|
||||
"</table>");
|
||||
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
|
||||
public:
|
||||
Base(QTextDocument& doc, QWidget* dialogParent, const QString& dialogTitle, const QString& _fn,
|
||||
QPrinter::PaperSize _ps = QPrinter::A4, QPrinter::Orientation _or = QPrinter::Portrait,
|
||||
QPrinter::ColorMode _cm = QPrinter::Color);
|
||||
|
||||
Base(QTextDocument &doc,
|
||||
QWidget *dialogParent,
|
||||
const QString &dialogTitle,
|
||||
const QString &_fn,
|
||||
QPrinter::PaperSize _ps = QPrinter::A4,
|
||||
QPrinter::Orientation _or = QPrinter::Portrait,
|
||||
QPrinter::ColorMode _cm = QPrinter::Color);
|
||||
virtual ~Base();
|
||||
|
||||
|
||||
QPrinter* printer();
|
||||
|
||||
virtual ~Base();
|
||||
static void setPrintToFile(bool printToFile);
|
||||
|
||||
|
||||
static QString styleSheet();
|
||||
|
||||
QPrinter *printer();
|
||||
QPrinter::PageSize pageSize() const;
|
||||
|
||||
|
||||
void setPageSize(QPrinter::PageSize size);
|
||||
|
||||
static void setPrintToFile(bool printToFile);
|
||||
QPrinter::Orientation orientation() const;
|
||||
|
||||
|
||||
void setOrientation(QPrinter::Orientation orientation);
|
||||
|
||||
static QString styleSheet();
|
||||
bool newPage();
|
||||
|
||||
|
||||
QPrinter::PageSize pageSize() const;
|
||||
|
||||
void setPageSize(QPrinter::PageSize size);
|
||||
|
||||
QPrinter::Orientation orientation() const;
|
||||
|
||||
void setOrientation(QPrinter::Orientation orientation);
|
||||
double leftMargin() const;
|
||||
|
||||
bool newPage();
|
||||
void setLeftMargin(double margin);
|
||||
|
||||
|
||||
double leftMargin() const;
|
||||
|
||||
void setLeftMargin(double margin);
|
||||
|
||||
double rightMargin() const;
|
||||
|
||||
void setRightMargin(double margin);
|
||||
|
||||
double topMargin() const;
|
||||
|
||||
void setTopMargin(double margin);
|
||||
|
||||
double bottomMargin() const;
|
||||
|
||||
void setBottomMargin(double margin);
|
||||
|
||||
void setMargins(double margin);
|
||||
double rightMargin() const;
|
||||
|
||||
|
||||
double spacing() const;
|
||||
|
||||
void setSpacing(double spacing);
|
||||
void setRightMargin(double margin);
|
||||
|
||||
|
||||
double headerSize() const;
|
||||
|
||||
void setHeaderSize(double size);
|
||||
|
||||
double headerRule() const;
|
||||
|
||||
void setHeaderRule(double pointsize);
|
||||
|
||||
const QString &headerText() const;
|
||||
|
||||
void setHeaderText(const QString &text);
|
||||
double topMargin() const;
|
||||
|
||||
|
||||
double footerSize() const;
|
||||
|
||||
void setFooterSize(double size);
|
||||
|
||||
double footerRule() const;
|
||||
|
||||
void setFooterRule(double pointsize);
|
||||
|
||||
const QString &footerText() const;
|
||||
|
||||
void setFooterText(const QString &text);
|
||||
|
||||
void setFooterTitle(const QString &footertitle) { footertitle_ = footertitle; }
|
||||
|
||||
|
||||
void setItemFontSize(int itemFontSize);
|
||||
void setTopMargin(double margin);
|
||||
|
||||
|
||||
double bottomMargin() const;
|
||||
|
||||
static void printTitleData(QString &htmlStr, const QString &title, const QString &heading = QStringLiteral("h3"));
|
||||
void setBottomMargin(double margin);
|
||||
|
||||
|
||||
void setMargins(double margin);
|
||||
|
||||
bool printListData(QString &str,
|
||||
const QAbstractItemView *view,
|
||||
const QString &title,
|
||||
bool asIcons = false,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
|
||||
double spacing() const;
|
||||
|
||||
bool printTableData(QString &str,
|
||||
const QAbstractItemView *view,
|
||||
const QString &title = QString(),
|
||||
const QSet<int> &suppressCols = QSet<int>(),
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
|
||||
void setSpacing(double spacing);
|
||||
|
||||
bool printTreeData(QString &str,
|
||||
const QAbstractItemView *view,
|
||||
const QString &title = QString(),
|
||||
const QSet<int> &suppressCols = QSet<int>(),
|
||||
int iconExtent = DECORATION_EXTENT,
|
||||
const QList<QString> &tabtexts = QList<QString>());
|
||||
double headerSize() const;
|
||||
|
||||
|
||||
void setHeaderSize(double size);
|
||||
|
||||
static bool printDocTextBlock(QTextDocument &doc,
|
||||
const QString &text,
|
||||
const QString &title = QString());
|
||||
double headerRule() const;
|
||||
|
||||
|
||||
void setHeaderRule(double pointsize);
|
||||
|
||||
bool printDocImage(QTextDocument &doc, const QImage &image,
|
||||
const QString &title = QString(), const QString &description = QString(), const qreal alreadyUsedHeight = 0) const;
|
||||
const QString& headerText() const;
|
||||
|
||||
|
||||
void setHeaderText(const QString& text);
|
||||
|
||||
static bool printReportData(QTextDocument &doc, KDReports::Report &report);
|
||||
double footerSize() const;
|
||||
|
||||
|
||||
void setFooterSize(double size);
|
||||
|
||||
virtual void print(QTextDocument *doc);
|
||||
double footerRule() const;
|
||||
|
||||
void setFooterRule(double pointsize);
|
||||
|
||||
virtual void printSinglePage(QTextDocument *doc);
|
||||
const QString& footerText() const;
|
||||
|
||||
void setFooterText(const QString& text);
|
||||
|
||||
virtual void printDone();
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
static QSet<int> getHiddenCols(T *view)
|
||||
{
|
||||
QSet<int> hiddenCols;
|
||||
int colCount = view->model()->columnCount();
|
||||
for (int i = 0; i < colCount; ++i)
|
||||
void setFooterTitle(const QString& footertitle)
|
||||
{
|
||||
if (view->isColumnHidden(i))
|
||||
hiddenCols += i;
|
||||
footertitle_ = footertitle;
|
||||
}
|
||||
return hiddenCols;
|
||||
}
|
||||
|
||||
|
||||
void setItemFontSize(int itemFontSize);
|
||||
|
||||
void setCurrentExerciseName( const QString& exerciseName );
|
||||
static void printTitleData(QString& htmlStr, const QString& title, const QString& heading = QStringLiteral("h3"));
|
||||
|
||||
|
||||
bool printListData(QString& str, const QAbstractItemView* view, const QString& title, bool asIcons = false,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
|
||||
void setOperatorName( const QString& operatorName );
|
||||
bool printTableData(QString& str, const QAbstractItemView* view, const QString& title = QString(),
|
||||
const QSet<int>& suppressCols = QSet<int>(), int iconExtent = DECORATION_EXTENT);
|
||||
|
||||
|
||||
void paintPage(QTextDocument *document,
|
||||
int pagenum);
|
||||
bool printTreeData(QString& str, const QAbstractItemView* view, const QString& title = QString(),
|
||||
const QSet<int>& suppressCols = QSet<int>(), int iconExtent = DECORATION_EXTENT,
|
||||
const QList<QString>& tabtexts = QList<QString>());
|
||||
|
||||
QSize pageSizeInMM();
|
||||
static bool printDocTextBlock(QTextDocument& doc, const QString& text, const QString& title = QString());
|
||||
|
||||
protected:
|
||||
bool printDocImage(QTextDocument& doc, const QImage& image, const QString& title = QString(),
|
||||
const QString& description = QString(), const qreal alreadyUsedHeight = 0) const;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool printTableItemData(QString &str,
|
||||
const QAbstractItemModel *model,
|
||||
const QModelIndex &mi,
|
||||
int rowSpanSize,
|
||||
int columnSpanSize,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
bool printItemData(QString &str,
|
||||
const QAbstractItemModel *model,
|
||||
const QModelIndex &mi,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
void printDecorationData(QString &str,
|
||||
const QAbstractItemModel *model,
|
||||
const QModelIndex &mi,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
void printListPoint(QString &str,
|
||||
const QAbstractItemView *view,
|
||||
const QAbstractItemModel *vm,
|
||||
const QModelIndex &miColumn0,
|
||||
const QSet<int> &suppressCols = QSet<int>(),
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
static int hierarchyCount(const QModelIndex &child);
|
||||
QString iconFilename(int nr) const;
|
||||
QSize printerPageSize() const;
|
||||
QSize contentPageSize() const;
|
||||
static bool printReportData(QTextDocument& doc, KDReports::Report& report);
|
||||
|
||||
QString currentExerciseName() const;
|
||||
QString operatorName() const;
|
||||
virtual void print(QTextDocument* doc);
|
||||
|
||||
|
||||
QRectF paperRect(QPaintDevice *device);
|
||||
|
||||
QRectF contentRect(QPaintDevice *device);
|
||||
QRectF headerRect(QPaintDevice *device);
|
||||
QRectF footerRect(QPaintDevice *device);
|
||||
virtual void printSinglePage(QTextDocument* doc);
|
||||
|
||||
virtual void printDone();
|
||||
|
||||
|
||||
void printSinglePage();
|
||||
void print();
|
||||
template <class T> static QSet<int> getHiddenCols(T* view)
|
||||
{
|
||||
QSet<int> hiddenCols;
|
||||
int colCount = view->model()->columnCount();
|
||||
for (int i = 0; i < colCount; ++i)
|
||||
{
|
||||
if (view->isColumnHidden(i))
|
||||
hiddenCols += i;
|
||||
}
|
||||
return hiddenCols;
|
||||
}
|
||||
|
||||
private:
|
||||
QPrinter *m_printer;
|
||||
QPainter *m_painter;
|
||||
static bool m_printToFile;
|
||||
int m_iconFilenameNr;
|
||||
void setCurrentExerciseName(const QString& exerciseName);
|
||||
|
||||
QTextDocument *m_tempdoc;
|
||||
void setOperatorName(const QString& operatorName);
|
||||
|
||||
double leftmargin_;
|
||||
double rightmargin_;
|
||||
double topmargin_;
|
||||
double bottommargin_;
|
||||
double spacing_;
|
||||
void paintPage(QTextDocument* document, int pagenum);
|
||||
|
||||
double headersize_;
|
||||
double headerrule_;
|
||||
QString headertext_;
|
||||
double footersize_;
|
||||
double footerrule_;
|
||||
QString footertext_;
|
||||
QString footertitle_;
|
||||
int itemFontSize_;
|
||||
QSize pageSizeInMM();
|
||||
|
||||
private:
|
||||
NGL::Settings *m_settings;
|
||||
QString m_exerciseName;
|
||||
QString m_operatorName;
|
||||
int m_currentPage;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool printTableItemData(QString& str, const QAbstractItemModel* model, const QModelIndex& mi, int rowSpanSize,
|
||||
int columnSpanSize, int iconExtent = DECORATION_EXTENT);
|
||||
bool printItemData(QString& str, const QAbstractItemModel* model, const QModelIndex& mi,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
void printDecorationData(QString& str, const QAbstractItemModel* model, const QModelIndex& mi,
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
void printListPoint(QString& str, const QAbstractItemView* view, const QAbstractItemModel* vm,
|
||||
const QModelIndex& miColumn0, const QSet<int>& suppressCols = QSet<int>(),
|
||||
int iconExtent = DECORATION_EXTENT);
|
||||
static int hierarchyCount(const QModelIndex& child);
|
||||
QString iconFilename(int nr) const;
|
||||
QSize printerPageSize() const;
|
||||
QSize contentPageSize() const;
|
||||
|
||||
QString currentExerciseName() const;
|
||||
QString operatorName() const;
|
||||
|
||||
QRectF paperRect(QPaintDevice* device);
|
||||
|
||||
QRectF contentRect(QPaintDevice* device);
|
||||
QRectF headerRect(QPaintDevice* device);
|
||||
QRectF footerRect(QPaintDevice* device);
|
||||
|
||||
void printSinglePage();
|
||||
void print();
|
||||
|
||||
private:
|
||||
QPrinter* m_printer;
|
||||
QPainter* m_painter;
|
||||
static bool m_printToFile;
|
||||
int m_iconFilenameNr;
|
||||
|
||||
QTextDocument* m_tempdoc;
|
||||
|
||||
double leftmargin_;
|
||||
double rightmargin_;
|
||||
double topmargin_;
|
||||
double bottommargin_;
|
||||
double spacing_;
|
||||
|
||||
double headersize_;
|
||||
double headerrule_;
|
||||
QString headertext_;
|
||||
double footersize_;
|
||||
double footerrule_;
|
||||
QString footertext_;
|
||||
QString footertitle_;
|
||||
int itemFontSize_;
|
||||
|
||||
private:
|
||||
NGL::Settings* m_settings;
|
||||
QString m_exerciseName;
|
||||
QString m_operatorName;
|
||||
int m_currentPage;
|
||||
};
|
||||
}
|
||||
} // namespace LtsPrinting
|
||||
Reference in new issue
Block a user