[PATCH 3/7] Add hw info to Seabear import

Miika Turkia miika.turkia at gmail.com
Mon Jul 27 06:13:29 PDT 2015


Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 dive.h                        |  2 +-
 file.c                        |  8 ++++++--
 qt-ui/divelogimportdialog.cpp | 19 ++++++++++++++++---
 qt-ui/divelogimportdialog.h   |  1 +
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/dive.h b/dive.h
index 7a77146..0ac2c37 100644
--- a/dive.h
+++ b/dive.h
@@ -668,7 +668,7 @@ extern int parse_dlf_buffer(unsigned char *buffer, size_t size);
 
 extern int parse_file(const char *filename);
 extern int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int o2Sensor1f, int o2Sensor2f, int o2Sensor3f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int setpointf, int sepidx, const char *csvtemplate, int unitidx);
-extern int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int o2Sensor1f, int o2Sensor2f, int o2Sensor3f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx, const char *delta);
+extern int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int o2Sensor1f, int o2Sensor2f, int o2Sensor3f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx, const char *delta, const char *hw);
 extern int parse_txt_file(const char *filename, const char *csv);
 extern int parse_manual_file(const char *filename, int separator_index, int units, int dateformat, int durationformat, int number, int date, int time, int duration, int location, int gps, int maxdepth, int meandepth, int divemaster, int buddy, int suit, int notes, int weight, int tags, int cylsizef, int startpresf, int endpresf, int o2f, int hef, int airtempf, int watertempf);
 
diff --git a/file.c b/file.c
index f7f9833..cd3cb34 100644
--- a/file.c
+++ b/file.c
@@ -950,8 +950,8 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
 	return ret;
 }
 
-#define SBPARAMS 38
-int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int o2sensor1f, int o2sensor2f, int o2sensor3f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx, const char *delta)
+#define SBPARAMS 40
+int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int o2sensor1f, int o2sensor2f, int o2sensor3f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx, const char *delta, const char *hw)
 {
 	int ret, i, pnr;
 	struct memblock mem;
@@ -1043,6 +1043,10 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
 	snprintf(deltabuf, MAXCOLDIGITS, "%s", delta);
 	params[pnr++] = "delta";
 	params[pnr++] = strdup(deltabuf);
+	if (strlen(hw)) {
+			params[pnr++] = "hw";
+			params[pnr++] = strdup(hw);
+	}
 	params[pnr++] = NULL;
 
 	/* Move the CSV data to the start of mem buffer */
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index d799bf1..24cb805 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -330,6 +330,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
 	fileNames = fn;
 	column = 0;
 	delta = "0";
+	hw = "";
 
 	/* Add indexes of XSLTs requiring special handling to the list */
 	specialCSV << 3;
@@ -392,8 +393,19 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 
 		/*
 		 * Parse header - currently only interested in sample
-		 * interval, or if we have old format (if interval value
-		 * is missing from the header).
+		 * interval and hardware version. If we have old format
+		 * the interval value is missing from the header.
+		 */
+
+		while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) {
+			if (firstLine.contains("//Hardware Version: ")) {
+				hw = firstLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\"");
+				break;
+			}
+		}
+
+		/*
+		 * Note that we scan over the "Log interval" on purpose
 		 */
 
 		while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) {
@@ -624,7 +636,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 						       ui->CSVSeparator->currentIndex(),
 						       "csv",
 						       ui->CSVUnits->currentIndex(),
-						       delta.toUtf8().data()
+						       delta.toUtf8().data(),
+						       hw.toUtf8().data()
 						       ) < 0) {
 					return;
 				}
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 050090f..9840c94 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -95,6 +95,7 @@ private:
 	int column;
 	ColumnNameResult *resultModel;
 	QString delta;
+	QString hw;
 
 	struct CSVAppConfig {
 		QString name;
-- 
2.1.4



More information about the subsurface mailing list