summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-02 22:26:31 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-05 21:00:40 +0300
commitbc80fc8849a01ac156c5e54ba8ef3fe04e1aaee3 (patch)
treed235d43cf54d5c30653147f2d1d9baec55bacf27
parent71561e720dbfd85b3cb724dd1eb509b0d230d5db (diff)
downloadsubsurface-bc80fc8849a01ac156c5e54ba8ef3fe04e1aaee3.tar.gz
Printing: pass the template_options struct to TemplateLayout
The template_options struct needs to be passed to TemplateLayout constructor. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--printer.cpp5
-rw-r--r--printer.h4
-rw-r--r--qt-ui/printdialog.cpp2
-rw-r--r--templatelayout.cpp5
-rw-r--r--templatelayout.h5
5 files changed, 15 insertions, 6 deletions
diff --git a/printer.cpp b/printer.cpp
index 5c93d2fed..83cc42d18 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -6,10 +6,11 @@
#include <QWebElementCollection>
#include <QWebElement>
-Printer::Printer(QPrinter *printer, print_options *printOptions)
+Printer::Printer(QPrinter *printer, print_options *printOptions, template_options *templateOptions)
{
this->printer = printer;
this->printOptions = printOptions;
+ this->templateOptions = templateOptions;
dpi = 0;
done = 0;
}
@@ -116,7 +117,7 @@ void Printer::templateProgessUpdated(int value)
void Printer::print()
{
- TemplateLayout t(printOptions);
+ TemplateLayout t(printOptions, templateOptions);
webView = new QWebView();
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
diff --git a/printer.h b/printer.h
index cba82e607..4ab65834a 100644
--- a/printer.h
+++ b/printer.h
@@ -8,6 +8,7 @@
#include "profile/profilewidget2.h"
#include "printoptions.h"
+#include "templateedit.h"
class Printer : public QObject {
Q_OBJECT
@@ -16,6 +17,7 @@ private:
QPrinter *printer;
QWebView *webView;
print_options *printOptions;
+ template_options *templateOptions;
QSize pageSize;
int done;
int dpi;
@@ -26,7 +28,7 @@ private slots:
void templateProgessUpdated(int value);
public:
- Printer(QPrinter *printer, print_options *printOptions);
+ Printer(QPrinter *printer, print_options *printOptions, template_options *templateOptions);
void print();
signals:
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 23c6f225e..9ff29e67b 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -45,7 +45,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
optionsWidget = new PrintOptions(this, &printOptions, &templateOptions);
// create a new printer object
- printer = new Printer(&qprinter, &printOptions);
+ printer = new Printer(&qprinter, &printOptions, &templateOptions);
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
diff --git a/templatelayout.cpp b/templatelayout.cpp
index 81a4d5f03..2a5bb8ff7 100644
--- a/templatelayout.cpp
+++ b/templatelayout.cpp
@@ -19,10 +19,11 @@ int getTotalWork(print_options *printOptions)
return dives;
}
-TemplateLayout::TemplateLayout(print_options *PrintOptions) :
+TemplateLayout::TemplateLayout(print_options *PrintOptions, template_options *templateOptions) :
m_engine(NULL)
{
this->PrintOptions = PrintOptions;
+ this->templateOptions = templateOptions;
}
TemplateLayout::~TemplateLayout()
@@ -45,6 +46,7 @@ QString TemplateLayout::generate()
m_engine->addTemplateLoader(m_templateLoader);
Grantlee::registerMetaType<Dive>();
+ Grantlee::registerMetaType<template_options>();
QVariantHash mapping;
QVariantList diveList;
@@ -61,6 +63,7 @@ QString TemplateLayout::generate()
emit progressUpdated(progress * 100.0 / totalWork);
}
mapping.insert("dives", diveList);
+ mapping.insert("template_options", QVariant::fromValue(*templateOptions));
Grantlee::Context c(mapping);
diff --git a/templatelayout.h b/templatelayout.h
index 4637a7962..a894ce4ca 100644
--- a/templatelayout.h
+++ b/templatelayout.h
@@ -4,19 +4,21 @@
#include <grantlee_templates.h>
#include "mainwindow.h"
#include "printoptions.h"
+#include "templateedit.h"
int getTotalWork(print_options *printOptions);
class TemplateLayout : public QObject {
Q_OBJECT
public:
- TemplateLayout(print_options *PrintOptions);
+ TemplateLayout(print_options *PrintOptions, template_options *templateOptions);
~TemplateLayout();
QString generate();
private:
Grantlee::Engine *m_engine;
print_options *PrintOptions;
+ template_options *templateOptions;
signals:
void progressUpdated(int value);
@@ -75,6 +77,7 @@ public:
};
Q_DECLARE_METATYPE(Dive)
+Q_DECLARE_METATYPE(template_options)
GRANTLEE_BEGIN_LOOKUP(Dive)
if (property == "number")