diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2018-04-28 12:20:39 +0300 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-01 22:42:10 +0300 |
commit | 12e4b6d62c06cde3e8ad0d1202ebd52b020f693c (patch) | |
tree | ff47ddc9bd3c204d9000dd8d823948dc614a3966 | |
parent | c53442e37edb19f9481f4f0bb7e6b7b7773aea43 (diff) | |
download | subsurface-12e4b6d62c06cde3e8ad0d1202ebd52b020f693c.tar.gz |
CSV import: include visibility and rating in import
Add support for visibility and rating to CSV import dialog.
Fixes #1212
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r-- | desktop-widgets/divelogimportdialog.cpp | 12 | ||||
-rw-r--r-- | xslt/manualcsv2xml.xslt | 20 |
2 files changed, 30 insertions, 2 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index 84cff0f97..5633d50a2 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -49,7 +49,7 @@ ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(par tr("O₂") << tr("He") << tr("Sample time") << tr("Sample depth") << tr("Sample temperature") << tr("Sample pO₂") << tr("Sample CNS") << tr("Sample NDL") << tr("Sample TTS") << tr("Sample stopdepth") << tr("Sample pressure") << tr("Sample sensor1 pO₂") << tr("Sample sensor2 pO₂") << tr("Sample sensor3 pO₂") << - tr("Sample setpoint"); + tr("Sample setpoint") << tr("Visibility") << tr("Rating"); } bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent) @@ -784,6 +784,10 @@ int DiveLogImportDialog::setup_csv_params(QStringList r, char **params, int pnr) params[pnr++] = intdup(r.indexOf(tr("Sample pressure"))); params[pnr++] = strdup("setpointField"); params[pnr++] = intdup(r.indexOf(tr("Sample setpoint"))); + params[pnr++] = strdup("visibilityField"); + params[pnr++] = intdup(r.indexOf(tr("Visibility"))); + params[pnr++] = strdup("ratingField"); + params[pnr++] = intdup(r.indexOf(tr("Rating"))); params[pnr++] = strdup("separatorIndex"); params[pnr++] = intdup(ui->CSVSeparator->currentIndex()); params[pnr++] = strdup("units"); @@ -875,7 +879,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() } else { for (int i = 0; i < fileNames.size(); ++i) { if (r.indexOf(tr("Sample time")) < 0) { - char *params[55]; + char *params[59]; int pnr = 0; params[pnr++] = strdup("numberField"); params[pnr++] = intdup(r.indexOf(tr("Dive #"))); @@ -927,6 +931,10 @@ void DiveLogImportDialog::on_buttonBox_accepted() params[pnr++] = intdup(r.indexOf(tr("Air temp."))); params[pnr++] = strdup("watertempField"); params[pnr++] = intdup(r.indexOf(tr("Water temp."))); + params[pnr++] = strdup("visibilityField"); + params[pnr++] = intdup(r.indexOf(tr("Visibility"))); + params[pnr++] = strdup("ratingField"); + params[pnr++] = intdup(r.indexOf(tr("Rating"))); params[pnr++] = NULL; parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1); diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt index 3f7f15d8a..2382ddb01 100644 --- a/xslt/manualcsv2xml.xslt +++ b/xslt/manualcsv2xml.xslt @@ -26,6 +26,8 @@ <xsl:param name="cylindersizeField" select="cylindersizeField"/> <xsl:param name="startpressureField" select="startpressureField"/> <xsl:param name="endpressureField" select="endpressureField"/> + <xsl:param name="visibilityField" select="visibilityField"/> + <xsl:param name="ratingField" select="ratingField"/> <xsl:param name="o2Field" select="o2Field"/> <xsl:param name="heField" select="heField"/> <xsl:output method="xml" encoding="utf-8" indent="yes"/> @@ -205,6 +207,24 @@ </xsl:attribute> </xsl:if> + <xsl:if test="$visibilityField >= 0"> + <xsl:attribute name="visibility"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$visibilityField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + + <xsl:if test="$ratingField >= 0"> + <xsl:attribute name="rating"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$ratingField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + <divecomputer deviceid="ffffffff" model="csv" /> <xsl:if test="$locationField >= 0 or $gpsField >= 0"> |