[PATCH 4/7] CSV import: add support for DC hw info

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


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

diff --git a/dive.h b/dive.h
index 0ac2c37..e61d1e9 100644
--- a/dive.h
+++ b/dive.h
@@ -667,7 +667,7 @@ extern int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *
 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_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, const char *hw);
 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 cd3cb34..b535029 100644
--- a/file.c
+++ b/file.c
@@ -912,11 +912,11 @@ int init_csv_file_parsing(char **params, time_t *now, struct tm *timep, int time
 	return pnr - 1;
 }
 
-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)
+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, const char *hw)
 {
 	int ret, i;
 	struct memblock mem;
-	char *params[35];
+	char *params[37];
 	time_t now;
 	struct tm *timep = NULL;
 	int previous;
@@ -931,7 +931,13 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
 	if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f >= MAXCOLS || o2sensor1f >= MAXCOLS || o2sensor2f >= MAXCOLS || o2sensor3f >= MAXCOLS || cnsf >= MAXCOLS || ndlf >= MAXCOLS || cnsf >= MAXCOLS || stopdepthf >= MAXCOLS || pressuref >= MAXCOLS || setpointf >= MAXCOLS)
 		return report_error(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
 
-	init_csv_file_parsing(params, &now, timep, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, setpointf, sepidx, csvtemplate, unitidx);
+	ret = init_csv_file_parsing(params, &now, timep, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, setpointf, sepidx, csvtemplate, unitidx);
+
+	if (strlen(hw)) {
+		params[ret++] = "hw";
+		params[ret++] = strdup(hw);
+		params[ret++] = NULL;
+	}
 
 	if (filename == NULL)
 		return report_error("No CSV filename");
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 24cb805..29138da 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -665,7 +665,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 					       r.indexOf(tr("Sample setpoint")),
 					       ui->CSVSeparator->currentIndex(),
 					       specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
-					       ui->CSVUnits->currentIndex()
+					       ui->CSVUnits->currentIndex(),
+					       ui->knownImports->currentText().prepend("\"").append("\"").toUtf8().data()
 					       );
 			}
 		}
@@ -716,7 +717,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 					       r.indexOf(tr("Sample setpoint")),
 					       ui->CSVSeparator->currentIndex(),
 					       specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
-					       ui->CSVUnits->currentIndex()
+					       ui->CSVUnits->currentIndex(),
+					       ui->knownImports->currentText().prepend("\"").append("\"").toUtf8().data()
 					       );
 		}
 	}
-- 
2.1.4



More information about the subsurface mailing list