From 26656310aba5f5de5c873603f8e74d56283d12a9 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Thu, 21 Nov 2013 23:48:42 +0100 Subject: Add optional support for stopdepth import from csv Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- dive.h | 2 +- file.c | 10 +++++++--- qt-ui/csvimportdialog.cpp | 8 ++++++-- qt-ui/csvimportdialog.h | 1 + qt-ui/csvimportdialog.ui | 25 +++++++++++++++++++++++++ xslt/csv2xml.xslt | 12 ++++++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/dive.h b/dive.h index d6490fdf7..41e37a720 100644 --- a/dive.h +++ b/dive.h @@ -626,7 +626,7 @@ extern void set_filename(const char *filename, bool force); extern int parse_dm4_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error); extern void parse_file(const char *filename, char **error); -extern void parse_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, char **error); +extern void parse_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int stopdepthf, char **error); extern void save_dives(const char *filename); extern void save_dives_logic(const char *filename, bool select_only); diff --git a/file.c b/file.c index 47bc1d5b3..5f9b3d90a 100644 --- a/file.c +++ b/file.c @@ -327,22 +327,23 @@ void parse_file(const char *filename, char **error) #define MAXCOLDIGITS 3 #define MAXCOLS 100 -void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, char **error) +void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int stopdepthf, char **error) { struct memblock mem; int pnr=0; - char *params[15]; + char *params[17]; char timebuf[MAXCOLDIGITS]; char depthbuf[MAXCOLDIGITS]; char tempbuf[MAXCOLDIGITS]; char po2buf[MAXCOLDIGITS]; char cnsbuf[MAXCOLDIGITS]; + char stopdepthbuf[MAXCOLDIGITS]; time_t now; struct tm *timep; char curdate[9]; char curtime[6]; - if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f >= MAXCOLS || cnsf >= MAXCOLS) { + if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f >= MAXCOLS || cnsf >= MAXCOLS || stopdepthf >= MAXCOLS ) { int len = strlen(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d")) + MAXCOLDIGITS; *error = malloc(len); snprintf(*error, len, translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS); @@ -354,6 +355,7 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int snprintf(tempbuf, MAXCOLDIGITS, "%d", tempf); snprintf(po2buf, MAXCOLDIGITS, "%d", po2f); snprintf(cnsbuf, MAXCOLDIGITS, "%d", cnsf); + snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf); time(&now); timep = localtime(&now); strftime(curdate, sizeof(curdate), "%Y%m%d", timep); @@ -372,6 +374,8 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int params[pnr++] = po2buf; params[pnr++] = "cnsField"; params[pnr++] = cnsbuf; + params[pnr++] = "stopdepthField"; + params[pnr++] = stopdepthbuf; params[pnr++] = "date"; params[pnr++] = curdate; params[pnr++] = "time"; diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp index 281aa66f6..91b9ddd40 100644 --- a/qt-ui/csvimportdialog.cpp +++ b/qt-ui/csvimportdialog.cpp @@ -6,8 +6,8 @@ const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = { {"", }, - {"APD Log Viewer", 0, 1, 15, 6, 17, "Tab"}, - {"XP5", 0, 1, 9, -1, -1, "Tab"}, + {"APD Log Viewer", 0, 1, 15, 6, 17, 18, "Tab"}, + {"XP5", 0, 1, 9, -1, -1, -1, "Tab"}, {NULL,} }; @@ -33,6 +33,8 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) : connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); + connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); + connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); } CSVImportDialog::~CSVImportDialog() @@ -49,6 +51,7 @@ void CSVImportDialog::on_buttonBox_accepted() ui->CSVDepth->value(), VALUE_IF_CHECKED(CSVTemperature), VALUE_IF_CHECKED(CSVpo2), VALUE_IF_CHECKED(CSVcns), + VALUE_IF_CHECKED(CSVstopdepth), &error); if (error != NULL) { @@ -92,6 +95,7 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index) SET_VALUE_AND_CHECKBOX(CSVTemperature, temperatureCheckBox, CSVApps[index].temperature); SET_VALUE_AND_CHECKBOX(CSVpo2, po2CheckBox, CSVApps[index].po2); SET_VALUE_AND_CHECKBOX(CSVcns, cnsCheckBox, CSVApps[index].cns); + SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth); } void CSVImportDialog::unknownImports(bool arg1) diff --git a/qt-ui/csvimportdialog.h b/qt-ui/csvimportdialog.h index ec2f02347..fda36bcb7 100644 --- a/qt-ui/csvimportdialog.h +++ b/qt-ui/csvimportdialog.h @@ -39,6 +39,7 @@ private: int temperature; int po2; int cns; + int stopdepth; QString separator; }; diff --git a/qt-ui/csvimportdialog.ui b/qt-ui/csvimportdialog.ui index 3b1167066..8f405e9d4 100644 --- a/qt-ui/csvimportdialog.ui +++ b/qt-ui/csvimportdialog.ui @@ -183,6 +183,23 @@ + + + + false + + + 0 + + + + + + + Stopdepth + + + label label_2 @@ -194,6 +211,8 @@ CSVpo2 cnsCheckBox CSVcns + stopdepthCheckBox + CSVstopdepth @@ -274,5 +293,11 @@ CSVcns setEnabled(bool) + + stopdepthCheckBox + clicked(bool) + CSVstopdepth + setEnabled(bool) + diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt index 382bb2be6..07aa91d55 100644 --- a/xslt/csv2xml.xslt +++ b/xslt/csv2xml.xslt @@ -7,6 +7,7 @@ + @@ -129,6 +130,17 @@ + + + + + + + + + + + -- cgit v1.2.3-70-g09d2