diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2015-08-21 19:00:46 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-08-22 18:34:48 +0300 |
commit | 70e8862efc7189342ee9c016e85054538b4d7b99 (patch) | |
tree | d674b42d4acdedb5254d9967a3541f41034ae867 /templatelayout.h | |
parent | 6a692495c024876d74145df8b67734323ec348b6 (diff) | |
download | subsurface-70e8862efc7189342ee9c016e85054538b4d7b99.tar.gz |
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>
Diffstat (limited to 'templatelayout.h')
-rw-r--r-- | templatelayout.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/templatelayout.h b/templatelayout.h index 41a3cbfa9..47ca31f4c 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -4,6 +4,8 @@ #include <grantlee_templates.h> #include "mainwindow.h" #include "printoptions.h" +#include "statistics.h" +#include "helpers.h" int getTotalWork(print_options *printOptions); void find_all_templates(); @@ -98,9 +100,22 @@ public: QString sac() const; }; +class YearInfo { +public: + stats_t *year; + YearInfo(stats_t& year) + :year(&year) + { + + } + YearInfo(); + ~YearInfo(); +}; + Q_DECLARE_METATYPE(Dive) Q_DECLARE_METATYPE(template_options) Q_DECLARE_METATYPE(print_options) +Q_DECLARE_METATYPE(YearInfo) GRANTLEE_BEGIN_LOOKUP(Dive) if (property == "number") @@ -182,4 +197,41 @@ if (property == "grayscale") { } GRANTLEE_END_LOOKUP +GRANTLEE_BEGIN_LOOKUP(YearInfo) + +if (property == "year") { + return object.year->period; +} else if (property == "dives") { + return object.year->selection_size; +} else if (property == "min_temp") { + const char *unit; + double temp = get_temp_units(object.year->min_temp, &unit); + return object.year->min_temp == 0 ? "0" : QString::number(temp, 'g', 2) + unit; +} else if (property == "max_temp") { + const char *unit; + double temp = get_temp_units(object.year->max_temp, &unit); + return object.year->max_temp == 0 ? "0" : QString::number(temp, 'g', 2) + unit; +} else if (property == "total_time") { + return get_time_string(object.year->total_time.seconds, 0); +} else if (property == "avg_time") { + return get_minutes(object.year->total_time.seconds / object.year->selection_size); +} else if (property == "shortest_time") { + return get_minutes(object.year->shortest_time.seconds); +} else if (property == "longest_time") { + return get_minutes(object.year->longest_time.seconds); +} else if (property == "avg_depth") { + return get_depth_string(object.year->avg_depth); +} else if (property == "min_depth") { + return get_depth_string(object.year->min_depth); +} else if (property == "max_depth") { + return get_depth_string(object.year->max_depth); +} else if (property == "avg_sac") { + return get_volume_string(object.year->avg_sac); +} else if (property == "min_sac") { + return get_volume_string(object.year->min_sac); +} else if (property == "max_sac") { + return get_volume_string(object.year->max_sac); +} +GRANTLEE_END_LOOKUP + #endif |