aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogexportdialog.cpp
blob: 3ac9638add4a344af97357a2ac0360cee3ca20d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QFileDialog>
#include <QString>

#include "mainwindow.h"
#include "divelogexportdialog.h"
#include "ui_divelogexportdialog.h"
#include "subsurfacewebservices.h"
#include "worldmap-save.h"

DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::DiveLogExportDialog)
{
	ui->setupUi(this);
}

DiveLogExportDialog::~DiveLogExportDialog()
{
	delete ui;
}

void DiveLogExportDialog::on_buttonBox_accepted()
{
	QFileInfo fi(system_default_filename());
	QString filename;
	QString stylesheet;

	if (ui->exportUDDF->isChecked()) {
		stylesheet = "uddf-export.xslt";
		filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(),
							tr("UDDF files (*.uddf *.UDDF)"));
	} else if (ui->exportCSV->isChecked()) {
		stylesheet = "xml2csv.xslt";
		filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(),
							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(),
				tr("HTML files (*.html)"));
		if (!filename.isNull() && !filename.isEmpty())
			export_worldmap_HTML(filename.toUtf8().data());
		return;
	} else if (ui->exportWorldMap->isChecked()) {
		filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(),
							tr("HTML files (*.html)"));
		if (!filename.isNull() && !filename.isEmpty())
			export_worldmap_HTML(filename.toUtf8().data());
		return;
	}

	if (!filename.isNull() && !filename.isEmpty())
		export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toStdString().c_str());
}