Commit graph

25 commits

Author SHA1 Message Date
Grace Karanja
390c10bb08 QML UI: Remove unneeded MobileDive class
The MobileDive class in divelistmodel.h is a duplication of the
Dive class in templatelayout.h. This patch moves the Dive to
the qthelper file.

[Dirk Hohndel: merged with upstream master - let's hope I didn't
               mess anything up]

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:47:48 -07:00
Dirk Hohndel
d5aacd092d Fix printing on Mac
While I cannot explain for the life of me why this worked on Linux and
Windows and not on Mac, what I have now seems to work on all three
platforms.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-28 09:15:56 -07:00
Gehad elrobey
b0e84e7e2b Printing: generate a Grantlee statistics template
As there are two types of templates, Grantlee need to support both.

This commit adds the support to generating a statistics HTML code from
a statistics template.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-22 18:35:51 +03:00
Gehad elrobey
70e8862efc Printing: export a statistics data structure to the Grantlee backend
Add a YearInfo class which represents a year statistics. Export the
class to the Grantlee backend, also export all it's members to the
printing backend.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-22 18:34:48 +03:00
Gehad elrobey
77c81b299b Printing: read statistics templates from the "statistics" path
Now there are two types of templates, dive list and statistics.
We need to support reading both types of templates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-22 18:34:06 +03:00
Gehad elrobey
06e2fab291 Printing: insert placeholders in empty feilds
Don't leave fields empty, this may corrupt the layout, a better way is
to insert placeholders for empty data, which also provides a better UX.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15 15:02:59 +03:00
Gehad elrobey
f05e9c5c79 Printing: export more dive details with Grantlee backend
Add SAC, tags, used gas and dive rating to dive data fields exported
with Grantlee backend.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15 15:02:20 +03:00
Dirk Hohndel
a4608f7c91 Printing: fix dive lookup for profile generation
The existing code (and templates) looked up dives by number and then used
that as index into the dive table. This worked exactly in one case: if all
dives were numbered consecutively starting with 1. While that is not an
entirely unreasonable case, it's of course not an acceptable assumption to
make.

This commit adds the necessary changes to instead look up dives by their
unique id. That's what it's there fore, after all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-28 13:37:14 -07:00
Gehad elrobey
858796af09 Printing: clear all templates before insterting the new templates
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-28 11:39:07 +03:00
Gehad elrobey
2b2c506cb7 Printing: use grantlee templates from the current existing template list
We use templates from the grantlee templates list created and
dynamically. So we don't need static templates anymore.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-28 11:37:30 +03:00
Gehad elrobey
f76ebe3b9d Printing: search for grantlee templates in the templates directory
We need to dynamically look up for all the existing templates in the
template directory. A grantlee template can be named any name but we
ignore files ending with '~'.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-28 11:37:23 +03:00
Gehad elrobey
599920c6cf Printing: export grayscale filter value to template
Export grayscale value to Grantlee template, So we must declare
print_options as QMetatype.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20 15:29:05 +03:00
Gehad elrobey
c56b1c1114 Printing: overwrite the old custom template file
Change the new file size after inserting the new template to overwrite
the old one.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20 15:26:41 +03:00
Gehad elrobey
605e1e2d93 Printing: add functions that read/write a template
Read/write templates from files.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:02:40 +03:00
Gehad elrobey
c35092f5c9 Printing: add custom options to the PrintDialog
Add:
-custom.html template
-custom template to print_options struct
-options to the options dialog

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:02:09 +03:00
Gehad elrobey
bc80fc8849 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>
2015-07-05 21:00:40 +03:00
Gehad elrobey
1faa198020 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>
2015-07-05 20:58:24 +03:00
Dirk Hohndel
094264014d Fix helper function
Avoid counting the selected dives - we have that number.
But also don't return 0 because we devide by the total work for the
progress bar.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 22:37:43 -07:00
Dirk Hohndel
1ecc9b0cc0 Address uninitialized member warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:51 -07:00
Gehad elrobey
75263e3d2c Printing: rename the "base" template for consistency
Change the name of the template "base" to "two_dives" as this name
describes it better.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19 21:41:58 +03:00
Gehad elrobey
6c54781e17 Printing: use selected print preferences while printing
Having a pointer to the printing_options struct, it should be
used to privide the selected options while printing.

Print options used ATM:
- number of dives per page
- template file name
- print in colors

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19 21:41:58 +03:00
Gehad elrobey
60c5e3cf25 Printing: pass the print_options struct to TemplateLayout and Printer
As the print_options struct is needed by both TemplateLayout and Printer
class, it can be passed to their constructor.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19 21:41:57 +03:00
Gehad elrobey
1040f0d4e5 Printing: fix rendering bug for odd number of dives
Odd number of dives needs extra space from the buttom, so that when we
scroll to the last page extra whitespace is shown under the last dive
frame, this is fixed by adding a default footer to the base template.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19 21:41:56 +03:00
Gehad elrobey
a820688aeb Printing: Add progress updating ability to print dialog
The progress bar shows the progress of both the rendering part and the
templating part, unfortunately we can't check the progress of Grantlee
templating engine so the progess bar doesn't have a constant pace it
stops a little around 20%.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:08:09 -07:00
Gehad elrobey
e2ad38189e Printing: Add TemplateLayout class
This is the main class to hold Grantlee engine logic.
TemplateLayout::generate() loads QT5Grantlee and initialize the
templates then returns a QString that contains the rendered HTML by
Grantlee library.

Also this class contains the Dive class which holds the logic that
formats the data before passing it to the templates.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:25 -07:00