mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add second CSV export with dive details
This is intended to export all the details that someone might copy from a paper logbook. We need a matching import template to make this simple. This hasn't been well tested, I'm sure it will break when elements and attributes are missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1ba4137fec
commit
74f5842f0c
5 changed files with 135 additions and 3 deletions
|
@ -272,6 +272,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
stylesheet = "xml2csv.xslt";
|
stylesheet = "xml2csv.xslt";
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Export CSV file as"), lastDir,
|
filename = QFileDialog::getSaveFileName(this, tr("Export CSV file as"), lastDir,
|
||||||
tr("CSV files (*.csv *.CSV)"));
|
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()) {
|
} else if (ui->exportDivelogs->isChecked()) {
|
||||||
DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked());
|
DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked());
|
||||||
} else if (ui->exportDiveshare->isChecked()) {
|
} else if (ui->exportDiveshare->isChecked()) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>507</width>
|
<width>507</width>
|
||||||
<height>413</height>
|
<height>423</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -166,7 +166,17 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="exportCSV">
|
<widget class="QRadioButton" name="exportCSV">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>CSV</string>
|
<string>CSV samples</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">exportGroup</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="exportCSVDetails">
|
||||||
|
<property name="text">
|
||||||
|
<string>CSV dive details</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<attribute name="buttonGroup">
|
||||||
<string notr="true">exportGroup</string>
|
<string notr="true">exportGroup</string>
|
||||||
|
@ -440,7 +450,7 @@
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroup"/>
|
|
||||||
<buttongroup name="exportGroup"/>
|
<buttongroup name="exportGroup"/>
|
||||||
|
<buttongroup name="buttonGroup"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -647,6 +647,9 @@ int export_dives_xslt(const char *filename, const bool selected, const char *exp
|
||||||
xmlDoc *transformed;
|
xmlDoc *transformed;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "export_dives_xslt with stylesheet %s\n", export_xslt);
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return report_error("No filename for export");
|
return report_error("No filename for export");
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<file>xslt/udcf.xslt</file>
|
<file>xslt/udcf.xslt</file>
|
||||||
<file>xslt/uddf-export.xslt</file>
|
<file>xslt/uddf-export.xslt</file>
|
||||||
<file>xslt/xml2csv.xslt</file>
|
<file>xslt/xml2csv.xslt</file>
|
||||||
|
<file>xslt/xml2manualcsv.xslt</file>
|
||||||
<file>xslt/uddf.xslt</file>
|
<file>xslt/uddf.xslt</file>
|
||||||
<file>xslt/sensuscsv.xslt</file>
|
<file>xslt/sensuscsv.xslt</file>
|
||||||
<file>xslt/manualcsv2xml.xslt</file>
|
<file>xslt/manualcsv2xml.xslt</file>
|
||||||
|
|
114
xslt/xml2manualcsv.xslt
Normal file
114
xslt/xml2manualcsv.xslt
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||||
|
<xsl:strip-space elements="*"/>
|
||||||
|
<xsl:output method="text" encoding="UTF-8"/>
|
||||||
|
|
||||||
|
<xsl:variable name="fs">,</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:template match="/divelog/dives">
|
||||||
|
<xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth"', $fs, '"avgdepth"', $fs, '"airtemp"', $fs, '"watertemp"', $fs, '"startpressure"', $fs, '"endpressure"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"')"/>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:apply-templates select="dive|trip/dive"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="dive">
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@number"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@date"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@time"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@duration"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:apply-templates select="divecomputer/depth"/>
|
||||||
|
<xsl:apply-templates select="divetemperature"/>
|
||||||
|
<xsl:apply-templates select="cylinder"/>
|
||||||
|
<xsl:apply-templates select="location"/>
|
||||||
|
<xsl:apply-templates select="divemaster"/>
|
||||||
|
<xsl:apply-templates select="buddy"/>
|
||||||
|
<xsl:apply-templates select="suit"/>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@rating"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@visibility"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:apply-templates select="notes"/>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="divecomputer/depth">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@max"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@mean"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="divetemperature">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@air"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@water"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="cylinder">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@start"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@end"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="location">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="@gps"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="divemaster">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="buddy">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="suit">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="notes">
|
||||||
|
<xsl:value-of select="$fs"/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
<xsl:text>"</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
Loading…
Add table
Reference in a new issue