aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--file.c17
-rw-r--r--qt-ui/divelogimportdialog.cpp23
-rw-r--r--qt-ui/divelogimportdialog.h1
4 files changed, 27 insertions, 16 deletions
diff --git a/dive.h b/dive.h
index f53d46f07..7a77146ee 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 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);
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_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 3bbcace4d..8fca750ac 100644
--- a/file.c
+++ b/file.c
@@ -828,7 +828,7 @@ int parse_txt_file(const char *filename, const char *csv)
#define MAXCOLS 100
#define DATESTR 9
#define TIMESTR 6
-void init_csv_file_parsing(char **params, char *timebuf, char *depthbuf, char *tempbuf, char *po2buf, char *o2sensor1buf, char *o2sensor2buf, char *o2sensor3buf, char *cnsbuf, char *ndlbuf, char *ttsbuf, char *stopdepthbuf, char *pressurebuf, char *unitbuf, char *separator_index, time_t *now, struct tm *timep, char *curdate, char *curtime, 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)
+void init_csv_file_parsing(char **params, char *timebuf, char *depthbuf, char *tempbuf, char *po2buf, char *o2sensor1buf, char *o2sensor2buf, char *o2sensor3buf, char *cnsbuf, char *ndlbuf, char *ttsbuf, char *stopdepthbuf, char *pressurebuf, char *setpointbuf, char *unitbuf, char *separator_index, time_t *now, struct tm *timep, char *curdate, char *curtime, 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 pnr = 0;
@@ -844,6 +844,7 @@ void init_csv_file_parsing(char **params, char *timebuf, char *depthbuf, char *t
snprintf(ttsbuf, MAXCOLDIGITS, "%d", ttsf);
snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf);
snprintf(pressurebuf, MAXCOLDIGITS, "%d", pressuref);
+ snprintf(setpointbuf, MAXCOLDIGITS, "%d", setpointf);
snprintf(separator_index, MAXCOLDIGITS, "%d", sepidx);
snprintf(unitbuf, MAXCOLDIGITS, "%d", unitidx);
time(now);
@@ -878,6 +879,8 @@ void init_csv_file_parsing(char **params, char *timebuf, char *depthbuf, char *t
params[pnr++] = stopdepthbuf;
params[pnr++] = "pressureField";
params[pnr++] = pressurebuf;
+ params[pnr++] = "setpointField";
+ params[pnr++] = setpointbuf;
params[pnr++] = "date";
params[pnr++] = curdate;
params[pnr++] = "time";
@@ -889,11 +892,11 @@ void init_csv_file_parsing(char **params, char *timebuf, char *depthbuf, char *t
params[pnr++] = NULL;
}
-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 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)
{
int ret;
struct memblock mem;
- char *params[33];
+ char *params[35];
char timebuf[MAXCOLDIGITS];
char depthbuf[MAXCOLDIGITS];
char tempbuf[MAXCOLDIGITS];
@@ -906,6 +909,7 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
char ttsbuf[MAXCOLDIGITS];
char stopdepthbuf[MAXCOLDIGITS];
char pressurebuf[MAXCOLDIGITS];
+ char setpointbuf[MAXCOLDIGITS];
char unitbuf[MAXCOLDIGITS];
char separator_index[MAXCOLDIGITS];
time_t now;
@@ -921,10 +925,10 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
xsltMaxVars = 150000;
#endif
- 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)
+ 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, timebuf, depthbuf, tempbuf, po2buf, o2sensor1buf, o2sensor2buf, o2sensor3buf, cnsbuf, ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, sepidx, csvtemplate, unitidx);
+ init_csv_file_parsing(params, timebuf, depthbuf, tempbuf, po2buf, o2sensor1buf, o2sensor2buf, o2sensor3buf, cnsbuf, ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, setpointbuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, setpointf, sepidx, csvtemplate, unitidx);
if (filename == NULL)
return report_error("No CSV filename");
@@ -958,6 +962,7 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
char ttsbuf[MAXCOLDIGITS];
char stopdepthbuf[MAXCOLDIGITS];
char pressurebuf[MAXCOLDIGITS];
+ char setpointbuf[MAXCOLDIGITS];
char unitbuf[MAXCOLDIGITS];
char separator_index[MAXCOLDIGITS];
char deltabuf[MAXCOLDIGITS];
@@ -971,7 +976,7 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
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)
return report_error(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
- init_csv_file_parsing(params, timebuf, depthbuf, tempbuf, po2buf, o2sensor1buf, o2sensor2buf, o2sensor3buf, cnsbuf, ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, sepidx, csvtemplate, unitidx);
+ init_csv_file_parsing(params, timebuf, depthbuf, tempbuf, po2buf, o2sensor1buf, o2sensor2buf, o2sensor3buf, cnsbuf, ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, setpointbuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, o2sensor1f, o2sensor2f, o2sensor3f, cnsf, ndlf, ttsf, stopdepthf, pressuref, -1, sepidx, csvtemplate, unitidx);
if (filename == NULL)
return report_error("No CSV filename");
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 64f67fab2..ea783b093 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -10,14 +10,14 @@ static QString subsurface_mimedata = "subsurface/csvcolumns";
static QString subsurface_index = "subsurface/csvindex";
const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
- // time, depth, temperature, po2, sensor1, sensor2, sensor3, cns, ndl, tts, stopdepth, pressure
+ // time, depth, temperature, po2, sensor1, sensor2, sensor3, cns, ndl, tts, stopdepth, pressure, setpoint
// indices are 0 based, -1 means the column doesn't exist
{ "Manual import", },
- { "APD Log Viewer", 0, 1, 15, 6, 3, 4, 5, 17, -1, -1, 18, -1, "Tab" },
- { "XP5", 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
- { "SensusCSV", 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "," },
- { "Seabear CSV", 0, 1, 5, -1, -1, -1, -1, -1, 2, 3, 4, 6, ";" },
- { "SubsurfaceCSV", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
+ { "APD Log Viewer", 0, 1, 15, 6, 3, 4, 5, 17, -1, -1, 18, -1, 2, "Tab" },
+ { "XP5", 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
+ { "SensusCSV", 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "," },
+ { "Seabear CSV", 0, 1, 5, -1, -1, -1, -1, -1, 2, 3, 4, 6, -1, ";" },
+ { "SubsurfaceCSV", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
{ NULL, }
};
@@ -27,7 +27,8 @@ ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(par
tr("End pressure") << tr("Max. depth") << tr("Avg. depth") << tr("Divemaster") << tr("Buddy") << tr("Suit") << tr("Notes") << tr("Tags") << tr("Air temp.") << tr("Water temp.") <<
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 sensor1 pO₂") << tr("Sample sensor2 pO₂") << tr("Sample sensor3 pO₂") <<
+ tr("Sample setpoint");
}
bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent)
@@ -438,7 +439,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
// Special handling for APD Log Viewer
if ((triggeredBy == KNOWNTYPES && value == 1) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) {
apd=true;
- firstLine = "Sample time\tSample depth\t\t\t\t\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth";
+ firstLine = "Sample time\tSample depth\tSample setpoint\t\t\t\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth";
blockSignals(true);
ui->CSVSeparator->setCurrentText(tr("Tab"));
if (triggeredBy == INITIAL && fileNames.first().contains(".apd", Qt::CaseInsensitive))
@@ -518,7 +519,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
separator = "\t";
currColumns = firstLine.split(separator);
}
- // now set up time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
+ // now set up time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure, setpoint
for (int i = 0; i < currColumns.count(); i++)
headers.append("");
if (CSVApps[value].time > -1 && CSVApps[value].time < currColumns.count())
@@ -545,6 +546,8 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
headers.replace(CSVApps[value].stopdepth, tr("Sample stopdepth"));
if (CSVApps[value].pressure > -1 && CSVApps[value].pressure < currColumns.count())
headers.replace(CSVApps[value].pressure, tr("Sample pressure"));
+ if (CSVApps[value].setpoint > -1 && CSVApps[value].setpoint < currColumns.count())
+ headers.replace(CSVApps[value].setpoint, tr("Sample setpoint"));
}
f.reset();
@@ -625,6 +628,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
r.indexOf(tr("Sample TTS")),
r.indexOf(tr("Sample stopdepth")),
r.indexOf(tr("Sample pressure")),
+ r.indexOf(tr("Sample setpoint")),
ui->CSVSeparator->currentIndex(),
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
ui->CSVUnits->currentIndex()
@@ -675,6 +679,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
r.indexOf(tr("Sample TTS")),
r.indexOf(tr("Sample stopdepth")),
r.indexOf(tr("Sample pressure")),
+ r.indexOf(tr("Sample setpoint")),
ui->CSVSeparator->currentIndex(),
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
ui->CSVUnits->currentIndex()
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index a78d30f6a..c5c750973 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -110,6 +110,7 @@ private:
int tts;
int stopdepth;
int pressure;
+ int setpoint;
QString separator;
};