summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/csvimportdialog.cpp20
-rw-r--r--qt-ui/csvimportdialog.h1
-rw-r--r--qt-ui/csvimportdialog.ui149
-rw-r--r--xslt/csv2xml.xslt12
4 files changed, 87 insertions, 95 deletions
diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp
index caafe3562..192080503 100644
--- a/qt-ui/csvimportdialog.cpp
+++ b/qt-ui/csvimportdialog.cpp
@@ -28,6 +28,7 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
connect(ui->CSVTemperature, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
+ connect(ui->temperatureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
}
CSVImportDialog::~CSVImportDialog()
@@ -35,11 +36,12 @@ CSVImportDialog::~CSVImportDialog()
delete ui;
}
+#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() : -1)
void CSVImportDialog::on_buttonBox_accepted()
{
char *error = NULL;
- parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value(), ui->CSVDepth->value(), ui->CSVTemperature->value(), &error);
+ parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value(), ui->CSVDepth->value(), VALUE_IF_CHECKED(CSVTemperature), &error);
if (error != NULL) {
mainWindow()->showError(error);
@@ -61,6 +63,13 @@ void CSVImportDialog::on_CSVFileSelector_clicked()
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
}
+#define SET_VALUE_AND_CHECKBOX(CSV, BOX, VAL) ({\
+ ui->CSV->blockSignals(true);\
+ ui->CSV->setValue(VAL);\
+ ui->CSV->setEnabled(VAL >= 0);\
+ ui->BOX->setChecked(VAL >= 0);\
+ ui->CSV->blockSignals(false);\
+ })
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
{
if (index == 0)
@@ -68,13 +77,16 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
ui->CSVTime->blockSignals(true);
ui->CSVDepth->blockSignals(true);
- ui->CSVTemperature->blockSignals(true);
ui->CSVTime->setValue(CSVApps[index].time);
ui->CSVDepth->setValue(CSVApps[index].depth);
- ui->CSVTemperature->setValue(CSVApps[index].temperature);
ui->CSVTime->blockSignals(false);
ui->CSVDepth->blockSignals(false);
- ui->CSVTemperature->blockSignals(false);
+ SET_VALUE_AND_CHECKBOX(CSVTemperature, temperatureCheckBox, CSVApps[index].temperature);
+}
+
+void CSVImportDialog::unknownImports(bool arg1)
+{
+ unknownImports();
}
void CSVImportDialog::unknownImports(int arg1)
diff --git a/qt-ui/csvimportdialog.h b/qt-ui/csvimportdialog.h
index 40359a505..9a4fc2c78 100644
--- a/qt-ui/csvimportdialog.h
+++ b/qt-ui/csvimportdialog.h
@@ -24,6 +24,7 @@ private slots:
void on_knownImports_currentIndexChanged(int index);
void on_CSVFile_textEdited();
void unknownImports(int);
+ void unknownImports(bool);
private:
void unknownImports();
diff --git a/qt-ui/csvimportdialog.ui b/qt-ui/csvimportdialog.ui
index ec5002baf..81ee4fdc1 100644
--- a/qt-ui/csvimportdialog.ui
+++ b/qt-ui/csvimportdialog.ui
@@ -100,93 +100,62 @@
<property name="title">
<string>Field Configuration</string>
</property>
- <widget class="QSpinBox" name="CSVTime">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>30</y>
- <width>56</width>
- <height>29</height>
- </rect>
- </property>
- <property name="minimum">
- <number>0</number>
- </property>
- <property name="value">
- <number>0</number>
- </property>
- </widget>
- <widget class="QSpinBox" name="CSVDepth">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>70</y>
- <width>56</width>
- <height>29</height>
- </rect>
- </property>
- <property name="minimum">
- <number>0</number>
- </property>
- <property name="value">
- <number>1</number>
- </property>
- </widget>
- <widget class="QSpinBox" name="CSVTemperature">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>110</y>
- <width>56</width>
- <height>29</height>
- </rect>
- </property>
- <property name="minimum">
- <number>0</number>
- </property>
- <property name="value">
- <number>15</number>
- </property>
- </widget>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>30</y>
- <width>41</width>
- <height>19</height>
- </rect>
- </property>
- <property name="text">
- <string>Time</string>
- </property>
- </widget>
- <widget class="QLabel" name="label_2">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>70</y>
- <width>51</width>
- <height>19</height>
- </rect>
- </property>
- <property name="text">
- <string>Depth</string>
- </property>
- </widget>
- <widget class="QLabel" name="label_3">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>110</y>
- <width>41</width>
- <height>19</height>
- </rect>
- </property>
- <property name="text">
- <string>Temp</string>
- </property>
- </widget>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="CSVTime">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Time</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="CSVDepth">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Depth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="CSVTemperature">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="temperatureCheckBox">
+ <property name="text">
+ <string>Temp</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ <zorder>label</zorder>
+ <zorder>label_2</zorder>
+ <zorder>CSVTime</zorder>
+ <zorder>CSVDepth</zorder>
+ <zorder>temperatureCheckBox</zorder>
+ <zorder>CSVTemperature</zorder>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
@@ -249,5 +218,11 @@
</hint>
</hints>
</connection>
+ <connection>
+ <sender>temperatureCheckBox</sender>
+ <signal>clicked(bool)</signal>
+ <receiver>CSVTemperature</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
</connections>
</ui>
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index 5c9abfe1e..677e83613 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -96,10 +96,14 @@
</xsl:attribute>
<xsl:attribute name="temp">
- <xsl:call-template name="getFieldByIndex">
- <xsl:with-param name="index" select="$tempField"/>
- <xsl:with-param name="line" select="$line"/>
- </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="$tempField >= 0">
+ <xsl:call-template name="getFieldByIndex">
+ <xsl:with-param name="index" select="$tempField"/>
+ <xsl:with-param name="line" select="$line"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
</xsl:attribute>
</sample>
</xsl:if>