mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Add optional support for stopdepth import from csv
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5eccd73a30
commit
26656310ab
6 changed files with 52 additions and 6 deletions
2
dive.h
2
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 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_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(const char *filename);
|
||||||
extern void save_dives_logic(const char *filename, bool select_only);
|
extern void save_dives_logic(const char *filename, bool select_only);
|
||||||
|
|
10
file.c
10
file.c
|
@ -327,22 +327,23 @@ void parse_file(const char *filename, char **error)
|
||||||
|
|
||||||
#define MAXCOLDIGITS 3
|
#define MAXCOLDIGITS 3
|
||||||
#define MAXCOLS 100
|
#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;
|
struct memblock mem;
|
||||||
int pnr=0;
|
int pnr=0;
|
||||||
char *params[15];
|
char *params[17];
|
||||||
char timebuf[MAXCOLDIGITS];
|
char timebuf[MAXCOLDIGITS];
|
||||||
char depthbuf[MAXCOLDIGITS];
|
char depthbuf[MAXCOLDIGITS];
|
||||||
char tempbuf[MAXCOLDIGITS];
|
char tempbuf[MAXCOLDIGITS];
|
||||||
char po2buf[MAXCOLDIGITS];
|
char po2buf[MAXCOLDIGITS];
|
||||||
char cnsbuf[MAXCOLDIGITS];
|
char cnsbuf[MAXCOLDIGITS];
|
||||||
|
char stopdepthbuf[MAXCOLDIGITS];
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *timep;
|
struct tm *timep;
|
||||||
char curdate[9];
|
char curdate[9];
|
||||||
char curtime[6];
|
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;
|
int len = strlen(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d")) + MAXCOLDIGITS;
|
||||||
*error = malloc(len);
|
*error = malloc(len);
|
||||||
snprintf(*error, len, translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
|
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(tempbuf, MAXCOLDIGITS, "%d", tempf);
|
||||||
snprintf(po2buf, MAXCOLDIGITS, "%d", po2f);
|
snprintf(po2buf, MAXCOLDIGITS, "%d", po2f);
|
||||||
snprintf(cnsbuf, MAXCOLDIGITS, "%d", cnsf);
|
snprintf(cnsbuf, MAXCOLDIGITS, "%d", cnsf);
|
||||||
|
snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf);
|
||||||
time(&now);
|
time(&now);
|
||||||
timep = localtime(&now);
|
timep = localtime(&now);
|
||||||
strftime(curdate, sizeof(curdate), "%Y%m%d", timep);
|
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++] = po2buf;
|
||||||
params[pnr++] = "cnsField";
|
params[pnr++] = "cnsField";
|
||||||
params[pnr++] = cnsbuf;
|
params[pnr++] = cnsbuf;
|
||||||
|
params[pnr++] = "stopdepthField";
|
||||||
|
params[pnr++] = stopdepthbuf;
|
||||||
params[pnr++] = "date";
|
params[pnr++] = "date";
|
||||||
params[pnr++] = curdate;
|
params[pnr++] = curdate;
|
||||||
params[pnr++] = "time";
|
params[pnr++] = "time";
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = {
|
const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = {
|
||||||
{"", },
|
{"", },
|
||||||
{"APD Log Viewer", 0, 1, 15, 6, 17, "Tab"},
|
{"APD Log Viewer", 0, 1, 15, 6, 17, 18, "Tab"},
|
||||||
{"XP5", 0, 1, 9, -1, -1, "Tab"},
|
{"XP5", 0, 1, 9, -1, -1, -1, "Tab"},
|
||||||
{NULL,}
|
{NULL,}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
||||||
connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
||||||
connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
||||||
connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
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()
|
CSVImportDialog::~CSVImportDialog()
|
||||||
|
@ -49,6 +51,7 @@ void CSVImportDialog::on_buttonBox_accepted()
|
||||||
ui->CSVDepth->value(), VALUE_IF_CHECKED(CSVTemperature),
|
ui->CSVDepth->value(), VALUE_IF_CHECKED(CSVTemperature),
|
||||||
VALUE_IF_CHECKED(CSVpo2),
|
VALUE_IF_CHECKED(CSVpo2),
|
||||||
VALUE_IF_CHECKED(CSVcns),
|
VALUE_IF_CHECKED(CSVcns),
|
||||||
|
VALUE_IF_CHECKED(CSVstopdepth),
|
||||||
&error);
|
&error);
|
||||||
if (error != NULL) {
|
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(CSVTemperature, temperatureCheckBox, CSVApps[index].temperature);
|
||||||
SET_VALUE_AND_CHECKBOX(CSVpo2, po2CheckBox, CSVApps[index].po2);
|
SET_VALUE_AND_CHECKBOX(CSVpo2, po2CheckBox, CSVApps[index].po2);
|
||||||
SET_VALUE_AND_CHECKBOX(CSVcns, cnsCheckBox, CSVApps[index].cns);
|
SET_VALUE_AND_CHECKBOX(CSVcns, cnsCheckBox, CSVApps[index].cns);
|
||||||
|
SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::unknownImports(bool arg1)
|
void CSVImportDialog::unknownImports(bool arg1)
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
int temperature;
|
int temperature;
|
||||||
int po2;
|
int po2;
|
||||||
int cns;
|
int cns;
|
||||||
|
int stopdepth;
|
||||||
QString separator;
|
QString separator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,23 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QSpinBox" name="CSVstopdepth">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="stopdepthCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Stopdepth</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<zorder>label</zorder>
|
<zorder>label</zorder>
|
||||||
<zorder>label_2</zorder>
|
<zorder>label_2</zorder>
|
||||||
|
@ -194,6 +211,8 @@
|
||||||
<zorder>CSVpo2</zorder>
|
<zorder>CSVpo2</zorder>
|
||||||
<zorder>cnsCheckBox</zorder>
|
<zorder>cnsCheckBox</zorder>
|
||||||
<zorder>CSVcns</zorder>
|
<zorder>CSVcns</zorder>
|
||||||
|
<zorder>stopdepthCheckBox</zorder>
|
||||||
|
<zorder>CSVstopdepth</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
@ -274,5 +293,11 @@
|
||||||
<receiver>CSVcns</receiver>
|
<receiver>CSVcns</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>stopdepthCheckBox</sender>
|
||||||
|
<signal>clicked(bool)</signal>
|
||||||
|
<receiver>CSVstopdepth</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<xsl:param name="tempField" select="tempField"/>
|
<xsl:param name="tempField" select="tempField"/>
|
||||||
<xsl:param name="po2Field" select="po2Field"/>
|
<xsl:param name="po2Field" select="po2Field"/>
|
||||||
<xsl:param name="cnsField" select="cnsField"/>
|
<xsl:param name="cnsField" select="cnsField"/>
|
||||||
|
<xsl:param name="otuField" select="otuField"/>
|
||||||
<xsl:param name="date" select="date"/>
|
<xsl:param name="date" select="date"/>
|
||||||
<xsl:param name="time" select="time"/>
|
<xsl:param name="time" select="time"/>
|
||||||
<xsl:output method="xml" indent="yes"/>
|
<xsl:output method="xml" indent="yes"/>
|
||||||
|
@ -129,6 +130,17 @@
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
|
|
||||||
|
<xsl:attribute name="otu">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$otuField >= 0">
|
||||||
|
<xsl:call-template name="getFieldByIndex">
|
||||||
|
<xsl:with-param name="index" select="$otuField"/>
|
||||||
|
<xsl:with-param name="line" select="$line"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:attribute>
|
||||||
</sample>
|
</sample>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
Loading…
Reference in a new issue