summaryrefslogtreecommitdiffstats
path: root/printer.cpp
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-08-21 11:02:10 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-08-22 18:33:36 +0300
commitc516421bc2ba8bcd70e1ac3e7173f3e9524ecb24 (patch)
tree04f1002bd330dcd4f42d024e5bc93d9d26ab2da1 /printer.cpp
parent13febc1eee0766801f3d86e0aa413552def76135 (diff)
downloadsubsurface-c516421bc2ba8bcd70e1ac3e7173f3e9524ecb24.tar.gz
Printing: check the print type in the preview section
Preview output should be identical to the actual printing code, so call the flow rendering method for all flow templates. Also don't create new pages while rendering a one page preview, just exit after the first page is full. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Diffstat (limited to 'printer.cpp')
-rw-r--r--printer.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/printer.cpp b/printer.cpp
index b4d937094..66fed7cf3 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -95,7 +95,14 @@ void Printer::flowRender()
// rendering progress is 4/5 of total work
emit(progessUpdated((end * 80.0 / fullPageResolution) + done));
- static_cast<QPrinter*>(paintDevice)->newPage();
+
+ // add new pages only in print mode, while previewing we don't add new pages
+ if (printMode == Printer::PRINT)
+ static_cast<QPrinter*>(paintDevice)->newPage();
+ else {
+ painter.end();
+ return;
+ }
start = dontbreakElement.geometry().y();
}
}
@@ -297,7 +304,16 @@ void Printer::previewOnePage()
templateOptions->border_width = std::max(1, pageSize.width() / 1000);
webView->setHtml(t.generate());
- // render only one page
- render(1);
+ bool ok;
+ int divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
+ if (!ok) {
+ divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed
+ //TODO: show warning
+ }
+ if (divesPerPage == 0) {
+ flowRender();
+ } else {
+ render(1);
+ }
}
}