summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-06-21 06:13:22 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-05 20:58:24 +0300
commit1faa198020de343004a7f1db85a83e6bc0ef8b34 (patch)
treeaa588f64eb16c979f98adfea156f90a90b23e8d8
parentbc0b443afd73e0bc7c18b293d051aa01bf82d99f (diff)
downloadsubsurface-1faa198020de343004a7f1db85a83e6bc0ef8b34.tar.gz
Printing: print all dives if 'print selected' is unchecked
User can choose either to print all dives or print selected dives only. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-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