Signed-off-by: Anton Lundin <gla...@acc.umu.se>
---
 dive.h                        |  2 +-
 file.c                        | 10 +++++++---
 qt-ui/divelogimportdialog.cpp | 14 +++++++++-----
 qt-ui/divelogimportdialog.h   |  1 +
 qt-ui/divelogimportdialog.ui  | 20 ++++++++++++++++++++
 xslt/csv2xml.xslt             | 10 ++++++++++
 6 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/dive.h b/dive.h
index ef57e29..871818c 100644
--- a/dive.h
+++ b/dive.h
@@ -556,7 +556,7 @@ extern int parse_dm4_buffer(sqlite3 *handle, const char 
*url, const char *buf, i
 extern int parse_shearwater_buffer(sqlite3 *handle, const char *url, const 
char *buf, int size, struct dive_table *table);
 
 extern int parse_file(const char *filename);
-extern int parse_csv_file(const char *filename, int time, int depth, int temp, 
int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int sepidx, const char 
*csvtemplate, int units);
+extern int parse_csv_file(const char *filename, int time, int depth, int temp, 
int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int 
sepidx, const char *csvtemplate, int units);
 extern int parse_manual_file(const char *filename, int separator_index, int 
units, int number, int date, int time, int duration, int location, int gps, int 
maxdepth, int meandepth, int buddy, int notes, int weight, int tags);
 
 extern int save_dives(const char *filename);
diff --git a/file.c b/file.c
index 9d8dafe..1859e39 100644
--- a/file.c
+++ b/file.c
@@ -384,11 +384,11 @@ int parse_file(const char *filename)
 
 #define MAXCOLDIGITS 3
 #define MAXCOLS 100
-int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int 
po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int sepidx, const char 
*csvtemplate, int unitidx)
+int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int 
po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, 
const char *csvtemplate, int unitidx)
 {
        struct memblock mem;
        int pnr = 0;
-       char *params[25];
+       char *params[27];
        char timebuf[MAXCOLDIGITS];
        char depthbuf[MAXCOLDIGITS];
        char tempbuf[MAXCOLDIGITS];
@@ -397,6 +397,7 @@ int parse_csv_file(const char *filename, int timef, int 
depthf, int tempf, int p
        char ndlbuf[MAXCOLDIGITS];
        char ttsbuf[MAXCOLDIGITS];
        char stopdepthbuf[MAXCOLDIGITS];
+       char pressurebuf[MAXCOLDIGITS];
        char unitbuf[MAXCOLDIGITS];
        char separator_index[MAXCOLDIGITS];
        time_t now;
@@ -404,7 +405,7 @@ int parse_csv_file(const char *filename, int timef, int 
depthf, int tempf, int p
        char curdate[9];
        char curtime[6];
 
-       if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f 
>= MAXCOLS || cnsf >= MAXCOLS || ndlf >= MAXCOLS || cnsf >= MAXCOLS || 
stopdepthf >= MAXCOLS)
+       if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f 
>= MAXCOLS || cnsf >= MAXCOLS || ndlf >= MAXCOLS || cnsf >= MAXCOLS || 
stopdepthf >= MAXCOLS || pressuref >= MAXCOLS)
                return report_error(translate("gettextFromC", "Maximum number 
of supported columns on CSV import is %d"), MAXCOLS);
 
        snprintf(timebuf, MAXCOLDIGITS, "%d", timef);
@@ -415,6 +416,7 @@ int parse_csv_file(const char *filename, int timef, int 
depthf, int tempf, int p
        snprintf(ndlbuf, MAXCOLDIGITS, "%d", ndlf);
        snprintf(ttsbuf, MAXCOLDIGITS, "%d", ttsf);
        snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf);
+       snprintf(pressurebuf, MAXCOLDIGITS, "%d", pressuref);
        snprintf(separator_index, MAXCOLDIGITS, "%d", sepidx);
        snprintf(unitbuf, MAXCOLDIGITS, "%d", unitidx);
        time(&now);
@@ -441,6 +443,8 @@ int parse_csv_file(const char *filename, int timef, int 
depthf, int tempf, int p
        params[pnr++] = ttsbuf;
        params[pnr++] = "stopdepthField";
        params[pnr++] = stopdepthbuf;
+       params[pnr++] = "pressureField";
+       params[pnr++] = pressurebuf;
        params[pnr++] = "date";
        params[pnr++] = curdate;
        params[pnr++] = "time";
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 403438e..deaa612 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -6,12 +6,12 @@
 #include "ui_divelogimportdialog.h"
 
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] 
= {
-       // time, depth, temperature, po2, cns, ndl, tts, stopdepth
+       // time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
        { "", },
-       { "APD Log Viewer", 1, 2, 16, 7, 18, -1, -1, 19, "Tab" },
-       { "XP5", 1, 2, 10, -1, -1, -1, -1, -1, "Tab" },
-       { "SensusCSV", 10, 11, -1, -1, -1, -1, -1, -1, "," },
-       { "Seabear CSV", 1, 2, 6, -1, -1, 3, 4, 5, ";" },
+       { "APD Log Viewer", 1, 2, 16, 7, 18, -1, -1, 19, -1, "Tab" },
+       { "XP5", 1, 2, 10, -1, -1, -1, -1, -1, -1, "Tab" },
+       { "SensusCSV", 10, 11, -1, -1, -1, -1, -1, -1, -1, "," },
+       { "Seabear CSV", 1, 2, 6, -1, -1, 3, 4, 5, 7, ";" },
        { NULL, }
 };
 
@@ -51,6 +51,8 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, 
QWidget *parent) : QDi
        connect(ui->ttsCheckBox, SIGNAL(clicked(bool)), this, 
SLOT(unknownImports()));
        connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, 
SLOT(unknownImports()));
        connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, 
SLOT(unknownImports()));
+       connect(ui->CSVpressure, SIGNAL(valueChanged(int)), this, 
SLOT(unknownImports()));
+       connect(ui->pressureCheckBox, SIGNAL(clicked(bool)), this, 
SLOT(unknownImports()));
        QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), 
this);
        connect(close, SIGNAL(activated()), this, SLOT(close()));
        QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), 
this);
@@ -74,6 +76,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
                                       VALUE_IF_CHECKED(CSVndl),
                                       VALUE_IF_CHECKED(CSVtts),
                                       VALUE_IF_CHECKED(CSVstopdepth),
+                                      VALUE_IF_CHECKED(CSVpressure),
                                       ui->CSVSeparator->currentIndex(),
                                       
specialCSV.contains(ui->knownImports->currentIndex()) ? 
CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
                                       ui->CSVUnits->currentIndex());
@@ -147,6 +150,7 @@ void 
DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
        SET_VALUE_AND_CHECKBOX(CSVndl, ndlCheckBox, CSVApps[index].ndl);
        SET_VALUE_AND_CHECKBOX(CSVtts, ttsCheckBox, CSVApps[index].tts);
        SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, 
CSVApps[index].stopdepth);
+       SET_VALUE_AND_CHECKBOX(CSVpressure, pressureCheckBox, 
CSVApps[index].pressure);
        ui->CSVSeparator->blockSignals(true);
        int separator_index = 
ui->CSVSeparator->findText(CSVApps[index].separator);
        if (separator_index != -1)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 637d85a..147216a 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -39,6 +39,7 @@ private:
                int ndl;
                int tts;
                int stopdepth;
+               int pressure;
                QString separator;
        };
 
diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 987768d..935325c 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -95,6 +95,26 @@
             </property>
            </widget>
           </item>
+          <item row="8" column="1">
+           <widget class="QSpinBox" name="CSVpressure">
+            <property name="enabled">
+             <bool>false</bool>
+            </property>
+            <property name="minimum">
+             <number>1</number>
+            </property>
+            <property name="value">
+             <number>1</number>
+            </property>
+           </widget>
+          </item>
+          <item row="8" column="0">
+           <widget class="QCheckBox" name="pressureCheckBox">
+            <property name="text">
+             <string>Pressure</string>
+            </property>
+           </widget>
+          </item>
           <item row="3" column="0">
            <widget class="QCheckBox" name="po2CheckBox">
             <property name="text">
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index 74770f4..f2a11da 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -11,6 +11,7 @@
   <xsl:param name="ndlField" select="ndlField"/>
   <xsl:param name="ttsField" select="ttsField"/>
   <xsl:param name="stopdepthField" select="stopdepthField"/>
+  <xsl:param name="pressureField" select="pressureField"/>
   <xsl:param name="date" select="date"/>
   <xsl:param name="time" select="time"/>
   <xsl:param name="units" select="units"/>
@@ -222,6 +223,15 @@
             </xsl:choose>
           </xsl:attribute>
         </xsl:if>
+
+        <xsl:if test="$pressureField >= 0">
+          <xsl:attribute name="pressure">
+            <xsl:call-template name="getFieldByIndex">
+              <xsl:with-param name="index" select="$pressureField"/>
+              <xsl:with-param name="line" select="$line"/>
+            </xsl:call-template>
+          </xsl:attribute>
+        </xsl:if>
       </sample>
     </xsl:if>
   </xsl:template>
-- 
1.9.1

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to