mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
planner: pass in_planner down to TemplateLayout
The TemplateLayout prints different dives depending on whether the planner is active. Instead of accessing a global variable, pass the status down from the MainWindow. That's all quite convoluted, since there are multiple layers involved. On the positive side, the in_planner() function has now no users an can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
18049bc8d0
commit
42cff9b3a5
10 changed files with 20 additions and 20 deletions
|
@ -1484,11 +1484,6 @@ extern "C" void parse_display_units(char *line)
|
||||||
qDebug() << line;
|
qDebug() << line;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" bool in_planner()
|
|
||||||
{
|
|
||||||
return getAppState() == ApplicationState::PlanDive || getAppState() == ApplicationState::EditPlannedDive;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" enum deco_mode decoMode(bool in_planner)
|
extern "C" enum deco_mode decoMode(bool in_planner)
|
||||||
{
|
{
|
||||||
return in_planner ? prefs.planner_deco_mode : prefs.display_deco_mode;
|
return in_planner ? prefs.planner_deco_mode : prefs.display_deco_mode;
|
||||||
|
|
|
@ -137,7 +137,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *printGPSCoordsC(const location_t *loc);
|
char *printGPSCoordsC(const location_t *loc);
|
||||||
bool in_planner();
|
|
||||||
bool getProxyString(char **buffer);
|
bool getProxyString(char **buffer);
|
||||||
bool canReachCloudServer();
|
bool canReachCloudServer();
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
|
|
|
@ -653,7 +653,9 @@ void MainWindow::updateLastUsedDir(const QString &dir)
|
||||||
void MainWindow::on_actionPrint_triggered()
|
void MainWindow::on_actionPrint_triggered()
|
||||||
{
|
{
|
||||||
#ifndef NO_PRINTING
|
#ifndef NO_PRINTING
|
||||||
PrintDialog dlg(this);
|
bool in_planner = getAppState() == ApplicationState::PlanDive ||
|
||||||
|
getAppState() == ApplicationState::EditPlannedDive;
|
||||||
|
PrintDialog dlg(in_planner, this);
|
||||||
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
|
|
||||||
template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_colors, custom_colors;
|
template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_colors, custom_colors;
|
||||||
|
|
||||||
PrintDialog::PrintDialog(QWidget *parent) :
|
PrintDialog::PrintDialog(bool inPlanner, QWidget *parent) :
|
||||||
QDialog(parent, QFlag(0)),
|
QDialog(parent, QFlag(0)),
|
||||||
|
inPlanner(inPlanner),
|
||||||
printer(NULL),
|
printer(NULL),
|
||||||
qprinter(NULL)
|
qprinter(NULL)
|
||||||
{
|
{
|
||||||
|
@ -174,10 +175,10 @@ void PrintDialog::createPrinterObj()
|
||||||
{
|
{
|
||||||
// create a new printer object
|
// create a new printer object
|
||||||
if (!printer) {
|
if (!printer) {
|
||||||
qprinter = new QPrinter();
|
qprinter = new QPrinter;
|
||||||
qprinter->setResolution(printOptions.resolution);
|
qprinter->setResolution(printOptions.resolution);
|
||||||
qprinter->setOrientation((QPrinter::Orientation)printOptions.landscape);
|
qprinter->setOrientation((QPrinter::Orientation)printOptions.landscape);
|
||||||
printer = new Printer(qprinter, printOptions, templateOptions, Printer::PRINT);
|
printer = new Printer(qprinter, printOptions, templateOptions, Printer::PRINT, inPlanner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,11 @@ class PrintDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PrintDialog(QWidget *parent = 0);
|
explicit PrintDialog(bool inPlanner, QWidget *parent = 0);
|
||||||
~PrintDialog();
|
~PrintDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool inPlanner;
|
||||||
PrintOptions *optionsWidget;
|
PrintOptions *optionsWidget;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
Printer *printer;
|
Printer *printer;
|
||||||
|
|
|
@ -14,12 +14,13 @@
|
||||||
#include <QWebElement>
|
#include <QWebElement>
|
||||||
#include "profile-widget/profilewidget2.h"
|
#include "profile-widget/profilewidget2.h"
|
||||||
|
|
||||||
Printer::Printer(QPaintDevice *paintDevice, const print_options &printOptions, const template_options &templateOptions, PrintMode printMode) :
|
Printer::Printer(QPaintDevice *paintDevice, const print_options &printOptions, const template_options &templateOptions, PrintMode printMode, bool inPlanner) :
|
||||||
paintDevice(paintDevice),
|
paintDevice(paintDevice),
|
||||||
webView(new QWebView),
|
webView(new QWebView),
|
||||||
printOptions(printOptions),
|
printOptions(printOptions),
|
||||||
templateOptions(templateOptions),
|
templateOptions(templateOptions),
|
||||||
printMode(printMode),
|
printMode(printMode),
|
||||||
|
inPlanner(inPlanner),
|
||||||
done(0),
|
done(0),
|
||||||
dpi(0)
|
dpi(0)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +206,7 @@ QString Printer::exportHtml()
|
||||||
QString html;
|
QString html;
|
||||||
|
|
||||||
if (printOptions.type == print_options::DIVELIST)
|
if (printOptions.type == print_options::DIVELIST)
|
||||||
html = t.generate();
|
html = t.generate(inPlanner);
|
||||||
else if (printOptions.type == print_options::STATISTICS )
|
else if (printOptions.type == print_options::STATISTICS )
|
||||||
html = t.generateStatistics();
|
html = t.generateStatistics();
|
||||||
|
|
||||||
|
@ -235,7 +236,7 @@ void Printer::print()
|
||||||
// export border width with at least 1 pixel
|
// export border width with at least 1 pixel
|
||||||
// templateOptions.borderwidth = std::max(1, pageSize.width() / 1000);
|
// templateOptions.borderwidth = std::max(1, pageSize.width() / 1000);
|
||||||
if (printOptions.type == print_options::DIVELIST)
|
if (printOptions.type == print_options::DIVELIST)
|
||||||
webView->setHtml(t.generate());
|
webView->setHtml(t.generate(inPlanner));
|
||||||
else if (printOptions.type == print_options::STATISTICS )
|
else if (printOptions.type == print_options::STATISTICS )
|
||||||
webView->setHtml(t.generateStatistics());
|
webView->setHtml(t.generateStatistics());
|
||||||
if (printOptions.color_selected && printerPtr->colorMode())
|
if (printOptions.color_selected && printerPtr->colorMode())
|
||||||
|
@ -269,7 +270,7 @@ void Printer::previewOnePage()
|
||||||
// initialize the border settings
|
// initialize the border settings
|
||||||
// templateOptions.border_width = std::max(1, pageSize.width() / 1000);
|
// templateOptions.border_width = std::max(1, pageSize.width() / 1000);
|
||||||
if (printOptions.type == print_options::DIVELIST)
|
if (printOptions.type == print_options::DIVELIST)
|
||||||
webView->setHtml(t.generate());
|
webView->setHtml(t.generate(inPlanner));
|
||||||
else if (printOptions.type == print_options::STATISTICS )
|
else if (printOptions.type == print_options::STATISTICS )
|
||||||
webView->setHtml(t.generateStatistics());
|
webView->setHtml(t.generateStatistics());
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
|
@ -27,6 +27,7 @@ private:
|
||||||
const template_options &templateOptions;
|
const template_options &templateOptions;
|
||||||
QSize pageSize;
|
QSize pageSize;
|
||||||
PrintMode printMode;
|
PrintMode printMode;
|
||||||
|
bool inPlanner;
|
||||||
int done;
|
int done;
|
||||||
int dpi;
|
int dpi;
|
||||||
void render(int Pages);
|
void render(int Pages);
|
||||||
|
@ -38,7 +39,7 @@ private slots:
|
||||||
void templateProgessUpdated(int value);
|
void templateProgessUpdated(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Printer(QPaintDevice *paintDevice, const print_options &printOptions, const template_options &templateOptions, PrintMode printMode);
|
Printer(QPaintDevice *paintDevice, const print_options &printOptions, const template_options &templateOptions, PrintMode printMode, bool inPlanner);
|
||||||
~Printer();
|
~Printer();
|
||||||
void print();
|
void print();
|
||||||
void previewOnePage();
|
void previewOnePage();
|
||||||
|
|
|
@ -59,7 +59,7 @@ void TemplateEdit::updatePreview()
|
||||||
int height = ui->label->height();
|
int height = ui->label->height();
|
||||||
QPixmap map(width * 2, height * 2);
|
QPixmap map(width * 2, height * 2);
|
||||||
map.fill(QColor::fromRgb(255, 255, 255));
|
map.fill(QColor::fromRgb(255, 255, 255));
|
||||||
Printer printer(&map, printOptions, newTemplateOptions, Printer::PREVIEW);
|
Printer printer(&map, printOptions, newTemplateOptions, Printer::PREVIEW, false);
|
||||||
printer.previewOnePage();
|
printer.previewOnePage();
|
||||||
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
|
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
|
||||||
|
|
||||||
|
|
|
@ -95,13 +95,13 @@ TemplateLayout::TemplateLayout(const print_options &printOptions, const template
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TemplateLayout::generate()
|
QString TemplateLayout::generate(bool in_planner)
|
||||||
{
|
{
|
||||||
QString htmlContent;
|
QString htmlContent;
|
||||||
|
|
||||||
State state;
|
State state;
|
||||||
|
|
||||||
if (in_planner()) {
|
if (in_planner) {
|
||||||
state.dives.append(&displayed_dive);
|
state.dives.append(&displayed_dive);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TemplateLayout : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TemplateLayout(const print_options &printOptions, const template_options &templateOptions);
|
TemplateLayout(const print_options &printOptions, const template_options &templateOptions);
|
||||||
QString generate();
|
QString generate(bool in_planner);
|
||||||
QString generateStatistics();
|
QString generateStatistics();
|
||||||
static QString readTemplate(QString template_name);
|
static QString readTemplate(QString template_name);
|
||||||
static void writeTemplate(QString template_name, QString grantlee_template);
|
static void writeTemplate(QString template_name, QString grantlee_template);
|
||||||
|
|
Loading…
Add table
Reference in a new issue