summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--qt-ui/divelistview.cpp2
-rw-r--r--qt-ui/mainwindow.cpp12
-rw-r--r--qt-ui/mainwindow.h1
-rw-r--r--qt-ui/mainwindow.ui42
-rw-r--r--save-xml.c15
-rw-r--r--subsurface.qrc1
7 files changed, 47 insertions, 28 deletions
diff --git a/dive.h b/dive.h
index 8713d8c67..5215c4997 100644
--- a/dive.h
+++ b/dive.h
@@ -702,7 +702,7 @@ extern int parse_manual_file(const char *filename, int separator_index, int unit
extern int save_dives(const char *filename);
extern int save_dives_logic(const char *filename, bool select_only);
extern int save_dive(FILE *f, struct dive *dive);
-extern int export_dives_uddf(const char *filename, const bool selected);
+extern int export_dives_xslt(const char *filename, const bool selected, const char *export_xslt);
struct git_oid;
struct git_repository;
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index a3e2e5cf8..cbabdcffe 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -813,7 +813,7 @@ void DiveListView::exportSelectedDivesAsUDDF()
filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(),
tr("UDDF files (*.uddf *.UDDF)"));
if (!filename.isNull() && !filename.isEmpty())
- export_dives_uddf(filename.toUtf8(), true);
+ export_dives_xslt(filename.toUtf8(), true, "uddf-export.xslt");
}
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index f93ad2d23..5e8459ecd 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -280,7 +280,17 @@ void MainWindow::on_actionExportUDDF_triggered()
QString filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(),
tr("UDDF files (*.uddf *.UDDF)"));
if (!filename.isNull() && !filename.isEmpty())
- export_dives_uddf(filename.toUtf8(), false);
+ export_dives_xslt(filename.toUtf8(), false, "uddf-export.xslt");
+}
+
+void MainWindow::on_actionExport_CSV_triggered()
+{
+ QFileInfo fi(system_default_filename());
+ QString filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(),
+ tr("CSV files (*.csv *.CSV)"));
+
+ if (!filename.isNull() && !filename.isEmpty())
+ export_dives_xslt(filename.toUtf8(), false, "xml2csv.xslt");
}
void MainWindow::on_actionExportHTMLworldmap_triggered()
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 40d32b5e5..60081e957 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -91,6 +91,7 @@ slots:
void on_actionSaveAs_triggered();
void on_actionClose_triggered();
void on_actionExportUDDF_triggered();
+ void on_actionExport_CSV_triggered();
void on_actionExportHTMLworldmap_triggered();
void on_actionPrint_triggered();
void on_actionPreferences_triggered();
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index a2621de9a..072d321fc 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -294,14 +294,14 @@
</property>
</widget>
</item>
- <item row="7" column="0">
- <widget class="QToolButton" name="profHR">
- <property name="toolTip">
- <string>Show/hide heart rate</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
+ <item row="7" column="0">
+ <widget class="QToolButton" name="profHR">
+ <property name="toolTip">
+ <string>Show/hide heart rate</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_HR</normaloff>:/icon_HR</iconset>
@@ -312,14 +312,14 @@
<height>24</height>
</size>
</property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item row="8" column="0">
<widget class="QToolButton" name="profMod">
<property name="toolTip">
@@ -475,7 +475,7 @@
<bool>true</bool>
</property>
</widget>
- </item>
+ </item>
<item row="0" column="1" rowspan="15">
<widget class="ProfileWidget2" name="newProfile"/>
</item>
@@ -577,6 +577,7 @@
<addaction name="separator"/>
<addaction name="actionClose"/>
<addaction name="actionExportUDDF"/>
+ <addaction name="actionExport_CSV"/>
<addaction name="actionExportHTMLworldmap"/>
<addaction name="actionPrint"/>
<addaction name="actionPreferences"/>
@@ -709,7 +710,7 @@
<string>Ctrl+U</string>
</property>
</action>
- <action name="actionExportHTMLworldmap">
+ <action name="actionExportHTMLworldmap">
<property name="text">
<string>Export HTML World Map</string>
</property>
@@ -945,6 +946,11 @@
<string>&amp;Check for Updates</string>
</property>
</action>
+ <action name="actionExport_CSV">
+ <property name="text">
+ <string>Export CSV</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/save-xml.c b/save-xml.c
index 1db2513d0..b61f79440 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -618,7 +618,7 @@ int save_dives_logic(const char *filename, const bool select_only)
return error;
}
-int export_dives_uddf(const char *filename, const bool selected)
+int export_dives_xslt(const char *filename, const bool selected, const char *export_xslt)
{
FILE *f;
struct membuffer buf = { 0 };
@@ -626,15 +626,16 @@ int export_dives_uddf(const char *filename, const bool selected)
xsltStylesheetPtr xslt = NULL;
xmlDoc *transformed;
+
if (!filename)
- return report_error("No filename for UDDF export");
+ return report_error("No filename for export");
/* Save XML to file and convert it into a memory buffer */
save_dives_buffer(&buf, selected);
/*
* Parse the memory buffer into XML document and
- * transform it to UDDF format, finally dumping
+ * transform it to selected export format, finally dumping
* the XML into a character buffer.
*/
doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, 0);
@@ -642,16 +643,16 @@ int export_dives_uddf(const char *filename, const bool selected)
if (!doc)
return report_error("Failed to read XML memory");
- /* Convert to UDDF format */
- xslt = get_stylesheet("uddf-export.xslt");
+ /* Convert to export format */
+ xslt = get_stylesheet(export_xslt);
if (!xslt)
- return report_error("Failed to open UDDF conversion stylesheet");
+ return report_error("Failed to open export conversion stylesheet");
transformed = xsltApplyStylesheet(xslt, doc, NULL);
xsltFreeStylesheet(xslt);
xmlFreeDoc(doc);
- /* Write the transformed XML to file */
+ /* Write the transformed export to file */
f = subsurface_fopen(filename, "w");
if (!f)
return report_error("Failed to open %s for writing (%s)", filename, strerror(errno));
diff --git a/subsurface.qrc b/subsurface.qrc
index 27716b604..d074ea324 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -36,6 +36,7 @@
<file>xslt/SuuntoSDM.xslt</file>
<file>xslt/udcf.xslt</file>
<file>xslt/uddf-export.xslt</file>
+ <file>xslt/xml2csv.xslt</file>
<file>xslt/uddf.xslt</file>
<file>xslt/sensuscsv.xslt</file>
<file>xslt/manualcsv2xml.xslt</file>