summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogexportdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/divelogexportdialog.cpp')
-rw-r--r--qt-ui/divelogexportdialog.cpp85
1 files changed, 66 insertions, 19 deletions
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 03bdaf9cb..99669d6d4 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -45,6 +45,15 @@ DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent),
if (settings.contains("themeSelection")) {
ui->themeSelection->setCurrentIndex(settings.value("themeSelection").toInt());
}
+ if (settings.contains("subsurfaceNumbers")) {
+ ui->exportSubsurfaceNumber->setChecked(settings.value("subsurfaceNumbers").toBool());
+ }
+ if (settings.contains("yearlyStatistics")) {
+ ui->exportStatistics->setChecked(settings.value("yearlyStatistics").toBool());
+ }
+ if (settings.contains("listOnly")) {
+ ui->exportListOnly->setChecked(settings.value("listOnly").toBool());
+ }
settings.endGroup();
}
@@ -86,6 +95,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
QString json_dive_data = exportFiles + QDir::separator() + "file.json";
QString json_settings = exportFiles + QDir::separator() + "settings.json";
+ QString translation = exportFiles + QDir::separator() + "translation.json";
QString stat_file = exportFiles + QDir::separator() + "stat.json";
QString photos_directory = exportFiles + QDir::separator() + "photos" + QDir::separator();
mainDir.mkdir(photos_directory);
@@ -93,6 +103,8 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
exportHTMLsettings(json_settings);
exportHTMLstatistics(stat_file);
+ export_translation(translation.toUtf8().data());
+
export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());
QString searchPath = getSubsurfaceDataPath("theme");
@@ -121,6 +133,9 @@ void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
settings.setValue("fontSelection", ui->fontSelection->currentIndex());
settings.setValue("fontSizeSelection", ui->fontSizeSelection->currentIndex());
settings.setValue("themeSelection", ui->themeSelection->currentIndex());
+ settings.setValue("subsurfaceNumbers", ui->exportSubsurfaceNumber->isChecked());
+ settings.setValue("yearlyStatistics", ui->exportStatistics->isChecked());
+ settings.setValue("listOnly", ui->exportListOnly->isChecked());
settings.endGroup();
QString fontSize = ui->fontSizeSelection->currentText();
@@ -138,32 +153,64 @@ 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=[";
- while (stats_yearly != NULL && stats_yearly[i].period) {
- out << "{";
- out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
- out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
- out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
- out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
- out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
- out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
- out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
- out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
- out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
- out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
- out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
- out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
- out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
- 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 << "},";
- i++;
+ if (ui->exportStatistics->isChecked()) {
+ while (stats_yearly != NULL && stats_yearly[i].period) {
+ out << "{";
+ out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
+ out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
+ out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
+ out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
+ out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
+ out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
+ out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
+ out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
+ out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
+ out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
+ out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
+ out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
+ out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
+ 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();