mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
71561e720d
commit
bc80fc8849
5 changed files with 15 additions and 6 deletions
|
@ -6,10 +6,11 @@
|
||||||
#include <QWebElementCollection>
|
#include <QWebElementCollection>
|
||||||
#include <QWebElement>
|
#include <QWebElement>
|
||||||
|
|
||||||
Printer::Printer(QPrinter *printer, print_options *printOptions)
|
Printer::Printer(QPrinter *printer, print_options *printOptions, template_options *templateOptions)
|
||||||
{
|
{
|
||||||
this->printer = printer;
|
this->printer = printer;
|
||||||
this->printOptions = printOptions;
|
this->printOptions = printOptions;
|
||||||
|
this->templateOptions = templateOptions;
|
||||||
dpi = 0;
|
dpi = 0;
|
||||||
done = 0;
|
done = 0;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,7 @@ void Printer::templateProgessUpdated(int value)
|
||||||
|
|
||||||
void Printer::print()
|
void Printer::print()
|
||||||
{
|
{
|
||||||
TemplateLayout t(printOptions);
|
TemplateLayout t(printOptions, templateOptions);
|
||||||
webView = new QWebView();
|
webView = new QWebView();
|
||||||
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
|
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "profile/profilewidget2.h"
|
#include "profile/profilewidget2.h"
|
||||||
#include "printoptions.h"
|
#include "printoptions.h"
|
||||||
|
#include "templateedit.h"
|
||||||
|
|
||||||
class Printer : public QObject {
|
class Printer : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -16,6 +17,7 @@ private:
|
||||||
QPrinter *printer;
|
QPrinter *printer;
|
||||||
QWebView *webView;
|
QWebView *webView;
|
||||||
print_options *printOptions;
|
print_options *printOptions;
|
||||||
|
template_options *templateOptions;
|
||||||
QSize pageSize;
|
QSize pageSize;
|
||||||
int done;
|
int done;
|
||||||
int dpi;
|
int dpi;
|
||||||
|
@ -26,7 +28,7 @@ private slots:
|
||||||
void templateProgessUpdated(int value);
|
void templateProgessUpdated(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Printer(QPrinter *printer, print_options *printOptions);
|
Printer(QPrinter *printer, print_options *printOptions, template_options *templateOptions);
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -45,7 +45,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
|
||||||
optionsWidget = new PrintOptions(this, &printOptions, &templateOptions);
|
optionsWidget = new PrintOptions(this, &printOptions, &templateOptions);
|
||||||
|
|
||||||
// create a new printer object
|
// create a new printer object
|
||||||
printer = new Printer(&qprinter, &printOptions);
|
printer = new Printer(&qprinter, &printOptions, &templateOptions);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
|
@ -19,10 +19,11 @@ int getTotalWork(print_options *printOptions)
|
||||||
return dives;
|
return dives;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLayout::TemplateLayout(print_options *PrintOptions) :
|
TemplateLayout::TemplateLayout(print_options *PrintOptions, template_options *templateOptions) :
|
||||||
m_engine(NULL)
|
m_engine(NULL)
|
||||||
{
|
{
|
||||||
this->PrintOptions = PrintOptions;
|
this->PrintOptions = PrintOptions;
|
||||||
|
this->templateOptions = templateOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLayout::~TemplateLayout()
|
TemplateLayout::~TemplateLayout()
|
||||||
|
@ -45,6 +46,7 @@ QString TemplateLayout::generate()
|
||||||
m_engine->addTemplateLoader(m_templateLoader);
|
m_engine->addTemplateLoader(m_templateLoader);
|
||||||
|
|
||||||
Grantlee::registerMetaType<Dive>();
|
Grantlee::registerMetaType<Dive>();
|
||||||
|
Grantlee::registerMetaType<template_options>();
|
||||||
|
|
||||||
QVariantHash mapping;
|
QVariantHash mapping;
|
||||||
QVariantList diveList;
|
QVariantList diveList;
|
||||||
|
@ -61,6 +63,7 @@ QString TemplateLayout::generate()
|
||||||
emit progressUpdated(progress * 100.0 / totalWork);
|
emit progressUpdated(progress * 100.0 / totalWork);
|
||||||
}
|
}
|
||||||
mapping.insert("dives", diveList);
|
mapping.insert("dives", diveList);
|
||||||
|
mapping.insert("template_options", QVariant::fromValue(*templateOptions));
|
||||||
|
|
||||||
Grantlee::Context c(mapping);
|
Grantlee::Context c(mapping);
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,21 @@
|
||||||
#include <grantlee_templates.h>
|
#include <grantlee_templates.h>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "printoptions.h"
|
#include "printoptions.h"
|
||||||
|
#include "templateedit.h"
|
||||||
|
|
||||||
int getTotalWork(print_options *printOptions);
|
int getTotalWork(print_options *printOptions);
|
||||||
|
|
||||||
class TemplateLayout : public QObject {
|
class TemplateLayout : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TemplateLayout(print_options *PrintOptions);
|
TemplateLayout(print_options *PrintOptions, template_options *templateOptions);
|
||||||
~TemplateLayout();
|
~TemplateLayout();
|
||||||
QString generate();
|
QString generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Grantlee::Engine *m_engine;
|
Grantlee::Engine *m_engine;
|
||||||
print_options *PrintOptions;
|
print_options *PrintOptions;
|
||||||
|
template_options *templateOptions;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void progressUpdated(int value);
|
void progressUpdated(int value);
|
||||||
|
@ -75,6 +77,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Dive)
|
Q_DECLARE_METATYPE(Dive)
|
||||||
|
Q_DECLARE_METATYPE(template_options)
|
||||||
|
|
||||||
GRANTLEE_BEGIN_LOOKUP(Dive)
|
GRANTLEE_BEGIN_LOOKUP(Dive)
|
||||||
if (property == "number")
|
if (property == "number")
|
||||||
|
|
Loading…
Add table
Reference in a new issue