aboutsummaryrefslogtreecommitdiffstats
path: root/printer.cpp
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-10 21:30:18 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-20 15:27:56 +0300
commit3a6963836682aa0e0e2825db4eaac7ea48a9939b (patch)
tree8bf8cbc1e5bfac2ce4a808482bc2ea4be499bbfb /printer.cpp
parent142fd950c8d69dc4d4aad4034fe65ca400d37783 (diff)
downloadsubsurface-3a6963836682aa0e0e2825db4eaac7ea48a9939b.tar.gz
Printing: check for different printing modes
Add PRINT/PREVIEW print modes, check for printing modes before casting. We must pass a QPaintDevice with type QPixmap for previewing and with type QPrinter for actual printing. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'printer.cpp')
-rw-r--r--printer.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/printer.cpp b/printer.cpp
index da5d5142d..c5867450f 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -6,11 +6,12 @@
#include <QWebElementCollection>
#include <QWebElement>
-Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions)
+Printer::Printer(QPaintDevice *paintDevice, print_options *printOptions, template_options *templateOptions, PrintMode printMode)
{
this->paintDevice = paintDevice;
this->printOptions = printOptions;
this->templateOptions = templateOptions;
+ this->printMode = printMode;
dpi = 0;
done = 0;
webView = new QWebView();
@@ -80,7 +81,7 @@ void Printer::render(int Pages = 0)
// rendering progress is 4/5 of total work
emit(progessUpdated((i * 80.0 / Pages) + done));
- if (i < Pages - 1)
+ if (i < Pages - 1 && printMode == Printer::PRINT)
static_cast<QPrinter*>(paintDevice)->newPage();
}
painter.end();
@@ -106,6 +107,11 @@ void Printer::templateProgessUpdated(int value)
void Printer::print()
{
+ // we can only print if "PRINT" mode is selected
+ if (printMode != Printer::PRINT) {
+ return;
+ }
+
QPrinter *printerPtr;
printerPtr = static_cast<QPrinter*>(paintDevice);