mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
18fa359b48
commit
3a2ceed33d
2 changed files with 78 additions and 24 deletions
|
@ -3,7 +3,7 @@
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QButtonGroup>
|
#include <QSettings>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "divelogexportdialog.h"
|
#include "divelogexportdialog.h"
|
||||||
|
@ -37,6 +37,8 @@ void DiveLogExportDialog::showExplanation()
|
||||||
ui->description->setText("Send the dive data to Divelogs.de website.");
|
ui->description->setText("Send the dive data to Divelogs.de website.");
|
||||||
} else if (ui->exportWorldMap->isChecked()) {
|
} else if (ui->exportWorldMap->isChecked()) {
|
||||||
ui->description->setText("HTML export of the dive locations, visualized on a world map.");
|
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()
|
void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
QFileInfo fi(system_default_filename());
|
|
||||||
QString filename;
|
QString filename;
|
||||||
QString stylesheet;
|
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()) {
|
if (ui->exportUDDF->isChecked()) {
|
||||||
stylesheet = "uddf-export.xslt";
|
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)"));
|
tr("UDDF files (*.uddf *.UDDF)"));
|
||||||
} else if (ui->exportCSV->isChecked()) {
|
} else if (ui->exportCSV->isChecked()) {
|
||||||
stylesheet = "xml2csv.xslt";
|
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)"));
|
tr("CSV files (*.csv *.CSV)"));
|
||||||
} else if (ui->exportDivelogs->isChecked()) {
|
} else if (ui->exportDivelogs->isChecked()) {
|
||||||
DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked());
|
DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked());
|
||||||
return;
|
|
||||||
} else if (ui->exportWorldMap->isChecked()) {
|
} 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)"));
|
tr("HTML files (*.html)"));
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked());
|
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())
|
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());
|
export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>448</width>
|
||||||
<height>419</height>
|
<height>473</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>360</y>
|
<y>420</y>
|
||||||
<width>341</width>
|
<width>341</width>
|
||||||
<height>32</height>
|
<height>32</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -61,8 +61,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>70</y>
|
<y>70</y>
|
||||||
<width>161</width>
|
<width>201</width>
|
||||||
<height>171</height>
|
<height>211</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -72,16 +72,22 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>30</y>
|
<y>70</y>
|
||||||
<width>110</width>
|
<width>110</width>
|
||||||
<height>24</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>110</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>UDDF</string>
|
<string>UDDF</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<attribute name="buttonGroup">
|
||||||
<string notr="true">exportGroup</string>
|
<string notr="true">exportGroup</string>
|
||||||
|
@ -91,7 +97,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>60</y>
|
<y>100</y>
|
||||||
<width>131</width>
|
<width>131</width>
|
||||||
<height>24</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -107,7 +113,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>90</y>
|
<y>130</y>
|
||||||
<width>110</width>
|
<width>110</width>
|
||||||
<height>24</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -123,8 +129,8 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>120</y>
|
<y>160</y>
|
||||||
<width>110</width>
|
<width>171</width>
|
||||||
<height>24</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -135,11 +141,36 @@
|
||||||
<string notr="true">exportGroup</string>
|
<string notr="true">exportGroup</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QRadioButton" name="exportSubsurfaceXML">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>171</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Subsurface XML</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">exportGroup</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QGroupBox" name="exportSelection">
|
<widget class="QGroupBox" name="exportSelection">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>190</x>
|
<x>240</x>
|
||||||
<y>70</y>
|
<y>70</y>
|
||||||
<width>191</width>
|
<width>191</width>
|
||||||
<height>141</height>
|
<height>141</height>
|
||||||
|
@ -185,7 +216,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>240</y>
|
<y>280</y>
|
||||||
<width>231</width>
|
<width>231</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -198,7 +229,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
<y>260</y>
|
<y>310</y>
|
||||||
<width>341</width>
|
<width>341</width>
|
||||||
<height>91</height>
|
<height>91</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue