Printing: refactor printing code

This section of the code is called only while rendering a flow layout
template, so move it to the flow layout function.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
Gehad elrobey 2015-08-19 23:02:58 +02:00 committed by Lubomir I. Ivanov
parent 4a988aa868
commit afc697e797

View file

@ -59,6 +59,11 @@ void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter
void Printer::flowRender() void Printer::flowRender()
{ {
// add extra padding at the bottom to pages with height not divisible by view port
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
// render the Qwebview // render the Qwebview
QPainter painter; QPainter painter;
QRect viewPort(0, 0, 0, 0); QRect viewPort(0, 0, 0, 0);
@ -187,6 +192,7 @@ void Printer::print()
return; return;
} }
QPrinter *printerPtr; QPrinter *printerPtr;
printerPtr = static_cast<QPrinter*>(paintDevice); printerPtr = static_cast<QPrinter*>(paintDevice);
@ -218,10 +224,6 @@ void Printer::print()
} }
int Pages; int Pages;
if (divesPerPage == 0) { if (divesPerPage == 0) {
// add extra padding at the bottom to pages with height not divisible by view port
int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
flowRender(); flowRender();
} else { } else {
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage); Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);