summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--printer.cpp2
-rw-r--r--templatelayout.cpp20
-rw-r--r--templatelayout.h2
3 files changed, 16 insertions, 8 deletions
diff --git a/printer.cpp b/printer.cpp
index 79f04e4a0..44f0739bc 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -56,7 +56,7 @@ void Printer::render()
divesPerPage = 2;
break;
}
- int Pages = ceil(getTotalWork() / (float)divesPerPage);
+ int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
// get all refereces to diveprofile class in the Html template
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
diff --git a/templatelayout.cpp b/templatelayout.cpp
index 5f47b64a2..81a4d5f03 100644
--- a/templatelayout.cpp
+++ b/templatelayout.cpp
@@ -4,11 +4,19 @@
#include "helpers.h"
#include "display.h"
-int getTotalWork()
+int getTotalWork(print_options *printOptions)
{
- // return the correct number depending on all/selected dives
- // but don't return 0 as we might divide by this number
- return amount_selected ? amount_selected : 1;
+ if (printOptions->print_selected) {
+ // return the correct number depending on all/selected dives
+ // but don't return 0 as we might divide by this number
+ return amount_selected ? amount_selected : 1;
+ }
+ int dives = 0, i;
+ struct dive *dive;
+ for_each_dive (i, dive) {
+ dives++;
+ }
+ return dives;
}
TemplateLayout::TemplateLayout(print_options *PrintOptions) :
@@ -25,7 +33,7 @@ TemplateLayout::~TemplateLayout()
QString TemplateLayout::generate()
{
int progress = 0;
- int totalWork = getTotalWork();
+ int totalWork = getTotalWork(PrintOptions);
QString templateName;
QString htmlContent;
@@ -45,7 +53,7 @@ QString TemplateLayout::generate()
int i;
for_each_dive (i, dive) {
//TODO check for exporting selected dives only
- if (!dive->selected)
+ if (!dive->selected && PrintOptions->print_selected)
continue;
Dive d(dive);
diveList.append(QVariant::fromValue(d));
diff --git a/templatelayout.h b/templatelayout.h
index 21eae1b80..4637a7962 100644
--- a/templatelayout.h
+++ b/templatelayout.h
@@ -5,7 +5,7 @@
#include "mainwindow.h"
#include "printoptions.h"
-int getTotalWork();
+int getTotalWork(print_options *printOptions);
class TemplateLayout : public QObject {
Q_OBJECT