summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-08-07 16:11:23 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-11 08:21:03 -0700
commit3ebb62f153c11a123e86d68f0b62998e91162779 (patch)
tree336b8ba6847fcbfb17a98e9a8126795c5d0e1901 /qt-ui
parent70cfe4f9eb31a69cec07de1b1b54f388525909d0 (diff)
downloadsubsurface-3ebb62f153c11a123e86d68f0b62998e91162779.tar.gz
HTML: Add total row to yearly statistics table.
Add new row to the yearly statistics table containing the total. Total values are calculated to some columns only, it doesn't make any sense to add the total value to other columns (Temperature cols for example). Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelogexportdialog.cpp30
-rw-r--r--qt-ui/divelogexportdialog.h6
2 files changed, 36 insertions, 0 deletions
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 0b6ab732e..9156f17ac 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -139,6 +139,12 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
QFile file(filename);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
+
+ stats_t total_stats;
+
+ total_stats.selection_size = 0;
+ total_stats.total_time.seconds = 0;
+
int i = 0;
out << "divestat=[";
if (ui->exportStatistics->isChecked()) {
@@ -160,13 +166,37 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
out << "},";
+ total_stats.selection_size += stats_yearly[i].selection_size;
+ total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
i++;
}
}
+ exportHTMLstatisticsTotal(out, &total_stats);
out << "]";
file.close();
}
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
+{
+ out << "{";
+ out << "\"YEAR\":\"Total\",";
+ out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
+ out << "\"TOTAL_TIME\":\"" << get_time_string(total_stats->total_time.seconds, 0) << "\",";
+ out << "\"AVERAGE_TIME\":\"--\",";
+ out << "\"SHORTEST_TIME\":\"--\",";
+ out << "\"LONGEST_TIME\":\"--\",";
+ out << "\"AVG_DEPTH\":\"--\",";
+ out << "\"MIN_DEPTH\":\"--\",";
+ out << "\"MAX_DEPTH\":\"--\",";
+ out << "\"AVG_SAC\":\"--\",";
+ out << "\"MIN_SAC\":\"--\",";
+ out << "\"MAX_SAC\":\"--\",";
+ out << "\"AVG_TEMP\":\"--\",";
+ out << "\"MIN_TEMP\":\"--\",";
+ out << "\"MAX_TEMP\":\"--\",";
+ out << "},";
+}
+
void DiveLogExportDialog::on_exportGroup_buttonClicked(QAbstractButton *button)
{
showExplanation();
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index e398a5a05..8472f8075 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -2,12 +2,18 @@
#define DIVELOGEXPORTDIALOG_H
#include <QDialog>
+#include <QTextStream>
+#include "helpers.h"
+#include "statistics.h"
+
class QAbstractButton;
namespace Ui {
class DiveLogExportDialog;
}
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats);
+
class DiveLogExportDialog : public QDialog {
Q_OBJECT