mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
bc0b443afd
commit
1faa198020
3 changed files with 16 additions and 8 deletions
|
@ -56,7 +56,7 @@ void Printer::render()
|
||||||
divesPerPage = 2;
|
divesPerPage = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int Pages = ceil(getTotalWork() / (float)divesPerPage);
|
int Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);
|
||||||
|
|
||||||
// get all refereces to diveprofile class in the Html template
|
// get all refereces to diveprofile class in the Html template
|
||||||
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
||||||
|
|
|
@ -4,11 +4,19 @@
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
int getTotalWork()
|
int getTotalWork(print_options *printOptions)
|
||||||
{
|
{
|
||||||
// return the correct number depending on all/selected dives
|
if (printOptions->print_selected) {
|
||||||
// but don't return 0 as we might divide by this number
|
// return the correct number depending on all/selected dives
|
||||||
return amount_selected ? amount_selected : 1;
|
// 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) :
|
TemplateLayout::TemplateLayout(print_options *PrintOptions) :
|
||||||
|
@ -25,7 +33,7 @@ TemplateLayout::~TemplateLayout()
|
||||||
QString TemplateLayout::generate()
|
QString TemplateLayout::generate()
|
||||||
{
|
{
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
int totalWork = getTotalWork();
|
int totalWork = getTotalWork(PrintOptions);
|
||||||
QString templateName;
|
QString templateName;
|
||||||
|
|
||||||
QString htmlContent;
|
QString htmlContent;
|
||||||
|
@ -45,7 +53,7 @@ QString TemplateLayout::generate()
|
||||||
int i;
|
int i;
|
||||||
for_each_dive (i, dive) {
|
for_each_dive (i, dive) {
|
||||||
//TODO check for exporting selected dives only
|
//TODO check for exporting selected dives only
|
||||||
if (!dive->selected)
|
if (!dive->selected && PrintOptions->print_selected)
|
||||||
continue;
|
continue;
|
||||||
Dive d(dive);
|
Dive d(dive);
|
||||||
diveList.append(QVariant::fromValue(d));
|
diveList.append(QVariant::fromValue(d));
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "printoptions.h"
|
#include "printoptions.h"
|
||||||
|
|
||||||
int getTotalWork();
|
int getTotalWork(print_options *printOptions);
|
||||||
|
|
||||||
class TemplateLayout : public QObject {
|
class TemplateLayout : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Add table
Reference in a new issue