void DiveLogExportDialog::on_buttonBox_accepted() { 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(); switch (ui->tabWidget->currentIndex()) { case 0: if (ui->exportUDDF->isChecked()) { stylesheet = "uddf-export.xslt"; 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"), lastDir, tr("CSV files (*.csv *.CSV)")); } else if (ui->exportDivelogs->isChecked()) { DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked()); } else if (ui->exportWorldMap->isChecked()) { 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()); } 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(), ui->exportSelected->isChecked()); } } break; case 1: filename = QFileDialog::getSaveFileName(this, tr("Export HTML files as"), lastDir, tr("HTML files (*.html)")); if (!filename.isNull() && !filename.isEmpty()) exportHtmlInit(filename); break; } 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.toUtf8()); } }
void DiveLogExportDialog::on_buttonBox_accepted() { 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(); switch (ui->tabWidget->currentIndex()) { case 0: if (ui->exportUDDF->isChecked()) { stylesheet = "uddf-export.xslt"; 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"), lastDir, tr("CSV files (*.csv *.CSV)")); } else if (ui->exportCSVDetails->isChecked()) { stylesheet = "xml2manualcsv.xslt"; 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()); } else if (ui->exportDiveshare->isChecked()) { DiveShareExportDialog::instance()->prepareDivesForUpload(ui->exportSelected->isChecked()); } else if (ui->exportWorldMap->isChecked()) { 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()); } else if (ui->exportSubsurfaceXML->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir, tr("XML files (*.xml *.ssrf)")); if (!filename.isNull() && !filename.isEmpty()) { if (!filename.contains('.')) filename.append(".ssrf"); QByteArray bt = QFile::encodeName(filename); save_dives_logic(bt.data(), ui->exportSelected->isChecked()); } } else if (ui->exportImageDepths->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir); if (!filename.isNull() && !filename.isEmpty()) export_depths(filename.toUtf8().data(), ui->exportSelected->isChecked()); } break; case 1: filename = QFileDialog::getSaveFileName(this, tr("Export HTML files as"), lastDir, tr("HTML files (*.html)")); if (!filename.isNull() && !filename.isEmpty()) exportHtmlInit(filename); break; } 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()) { future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8()); MainWindow::instance()->getNotificationWidget()->showNotification(tr("Please wait, exporting..."), KMessageWidget::Information); MainWindow::instance()->getNotificationWidget()->setFuture(future); } } }