Skip to content

Commit

Permalink
Export unused cylinders to divelogs.de
Browse files Browse the repository at this point in the history
When user has selected to show unused cylinders in equipment tab,
respect this setting when exporting to divelogs.de.

Fixes subsurface#3277

Signed-off-by: Miika Turkia <[email protected]>
  • Loading branch information
mturkia committed Jul 18, 2021
1 parent 235ee48 commit 63795a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/uploadDiveLogsDE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "core/membuffer.h"
#include "core/divesite.h"
#include "core/cloudstorage.h"
#include "core/xmlparams.h"
#ifndef SUBSURFACE_MOBILE
#include "core/selection.h"
#endif // SUBSURFACE_MOBILE
Expand Down Expand Up @@ -97,6 +98,7 @@ bool uploadDiveLogsDE::prepareDives(const QString &tempfile, bool selected)
xmlDoc *transformed;
struct zip_source *s;
struct membuffer mb = {};
struct xml_params *params = alloc_xml_params();

/*
* Get the i'th dive in XML format so we can process it.
Expand Down Expand Up @@ -153,7 +155,9 @@ bool uploadDiveLogsDE::prepareDives(const QString &tempfile, bool selected)
}
free_buffer(&mb);

transformed = xsltApplyStylesheet(xslt, doc, NULL);
xml_params_add_int(params, "allcylinders", prefs.display_unused_tanks);
transformed = xsltApplyStylesheet(xslt, doc, xml_params_get(params));
free_xml_params(params);
if (!transformed) {
qWarning() << errPrefix << "XSLT transform failed for dive: " << i;
report_error(tr("Conversion of dive %1 to divelogs.de format failed").arg(i).toUtf8());
Expand Down
3 changes: 2 additions & 1 deletion xslt/divelogs-export.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="commonTemplates.xsl"/>
<xsl:strip-space elements="*"/>
<xsl:param name="allcylinders" select="allcylinders"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes"
cdata-section-elements="LOCATION SITE WEATHER WATERVIZIBILITY PARTNER BOATNAME CYLINDERDESCRIPTION LOGNOTES"
/>
Expand Down Expand Up @@ -170,7 +171,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="following-sibling::divecomputer/event[@name='gaschange' and @value=$gas] or substring-before(@start, ' ') - 5 &gt; substring-before(@end, ' ')">
<xsl:if test="following-sibling::divecomputer/event[@name='gaschange' and @value=$gas] or substring-before(@start, ' ') - 5 &gt; substring-before(@end, ' ') or $allcylinders &gt; 0">
<xsl:variable name="cur_cyl">
<xsl:value-of select="position()"/>
</xsl:variable>
Expand Down

0 comments on commit 63795a8

Please sign in to comment.