From 3a2ceed33d5fcb706a1790fa80fad322dba33556 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 24 May 2014 07:12:03 -0700 Subject: Add Subsurface XML export to Export dialog Also be consistent about the default folder we use when opening the file dialog. Signed-off-by: Dirk Hohndel --- qt-ui/divelogexportdialog.cpp | 43 +++++++++++++++++++++++-------- qt-ui/divelogexportdialog.ui | 59 +++++++++++++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 24 deletions(-) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index cc59b2e6d..28f343257 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "mainwindow.h" #include "divelogexportdialog.h" @@ -37,6 +37,8 @@ void DiveLogExportDialog::showExplanation() ui->description->setText("Send the dive data to Divelogs.de website."); } else if (ui->exportWorldMap->isChecked()) { ui->description->setText("HTML export of the dive locations, visualized on a world map."); + } else if (ui->exportSubsurfaceXML->isChecked()) { + ui->description->setText("Subsurface native XML format."); } } @@ -47,29 +49,50 @@ void DiveLogExportDialog::on_exportGroup_buttonClicked(QAbstractButton *button) void DiveLogExportDialog::on_buttonBox_accepted() { - QFileInfo fi(system_default_filename()); QString filename; QString stylesheet; + QSettings settings; + QString lastDir = QDir::homePath(); + + settings.beginGroup("FileDialog"); + if (settings.contains("LastDir")) { + if (QDir::setCurrent(settings.value("LastDir").toString())) { + lastDir = settings.value("LastDir").toString(); + } + } + settings.endGroup(); if (ui->exportUDDF->isChecked()) { stylesheet = "uddf-export.xslt"; - filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(), + filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), lastDir, tr("UDDF files (*.uddf *.UDDF)")); } else if (ui->exportCSV->isChecked()) { stylesheet = "xml2csv.xslt"; - filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(), + filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), lastDir, tr("CSV files (*.csv *.CSV)")); } else if (ui->exportDivelogs->isChecked()) { DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked()); - return; } else if (ui->exportWorldMap->isChecked()) { - filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(), + filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), lastDir, tr("HTML files (*.html)")); if (!filename.isNull() && !filename.isEmpty()) export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked()); - return; + } else if (ui->exportSubsurfaceXML->isChecked()) { + filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir, + tr("XML files (*.xml *.ssrf)")); + if (!filename.isNull() && !filename.isEmpty()) { + QByteArray bt = QFile::encodeName(filename); + save_dives_logic(bt.data(), true); + } + } + if (!filename.isNull() && !filename.isEmpty()) { + // remember the last export path + QFileInfo fileInfo(filename); + settings.beginGroup("FileDialog"); + settings.setValue("LastDir", fileInfo.dir().path()); + settings.endGroup(); + // the non XSLT exports are called directly above, the XSLT based ons are called here + if (!stylesheet.isEmpty()) + export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toStdString().c_str()); } - - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toStdString().c_str()); } diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui index c937308e1..cb84e083f 100644 --- a/qt-ui/divelogexportdialog.ui +++ b/qt-ui/divelogexportdialog.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 419 + 448 + 473 @@ -17,7 +17,7 @@ 20 - 360 + 420 341 32 @@ -61,8 +61,8 @@ 20 70 - 161 - 171 + 201 + 211 @@ -72,16 +72,22 @@ 10 - 30 + 70 110 24 + + + 110 + 16777215 + + UDDF - true + false exportGroup @@ -91,7 +97,7 @@ 10 - 60 + 100 131 24 @@ -107,7 +113,7 @@ 10 - 90 + 130 110 24 @@ -123,8 +129,8 @@ 10 - 120 - 110 + 160 + 171 24 @@ -135,11 +141,36 @@ exportGroup + + + + 10 + 40 + 171 + 21 + + + + + 171 + 16777215 + + + + Subsurface XML + + + true + + + exportGroup + + - 190 + 240 70 191 141 @@ -185,7 +216,7 @@ 60 - 240 + 280 231 16 @@ -198,7 +229,7 @@ 30 - 260 + 310 341 91 -- cgit v1.2.3-70-g09d2