diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-08-23 07:38:11 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-23 07:38:11 -0700 |
commit | 2f540b56a8e42c8a0722dec3676297024f31eb74 (patch) | |
tree | d5c34830520481fccef873a3cbc5b9f60aae8d07 /templatelayout.h | |
parent | fbce8a0378f5ebcd36dbc08b3b5771ccf5cad830 (diff) | |
parent | cc864794753eb586e89470d87196e13568cb9031 (diff) | |
download | subsurface-2f540b56a8e42c8a0722dec3676297024f31eb74.tar.gz |
Merge branch 'custom-print' of github.com:neolit123/subsurface
Diffstat (limited to 'templatelayout.h')
-rw-r--r-- | templatelayout.h | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/templatelayout.h b/templatelayout.h index 41a3cbfa9..d9fa29295 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -4,11 +4,13 @@ #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(); -extern QList<QString> grantlee_templates; +extern QList<QString> grantlee_templates, grantlee_statistics_templates; class TemplateLayout : public QObject { Q_OBJECT @@ -16,6 +18,7 @@ public: TemplateLayout(print_options *PrintOptions, template_options *templateOptions); ~TemplateLayout(); QString generate(); + QString generateStatistics(); static QString readTemplate(QString template_name); static void writeTemplate(QString template_name, QString grantlee_template); @@ -98,9 +101,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 +198,40 @@ 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 |