mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make temperature optional in csv import
This adds a checkbox to be able to import csv files without temperature. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1a0adea0cc
commit
cf06f78892
4 changed files with 87 additions and 95 deletions
|
@ -28,6 +28,7 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
||||||
connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
||||||
connect(ui->CSVTime, 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->CSVTemperature, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
||||||
|
connect(ui->temperatureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVImportDialog::~CSVImportDialog()
|
CSVImportDialog::~CSVImportDialog()
|
||||||
|
@ -35,11 +36,12 @@ CSVImportDialog::~CSVImportDialog()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() : -1)
|
||||||
void CSVImportDialog::on_buttonBox_accepted()
|
void CSVImportDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
char *error = NULL;
|
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) {
|
if (error != NULL) {
|
||||||
|
|
||||||
mainWindow()->showError(error);
|
mainWindow()->showError(error);
|
||||||
|
@ -61,6 +63,13 @@ void CSVImportDialog::on_CSVFileSelector_clicked()
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
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)
|
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
|
@ -68,13 +77,16 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||||
|
|
||||||
ui->CSVTime->blockSignals(true);
|
ui->CSVTime->blockSignals(true);
|
||||||
ui->CSVDepth->blockSignals(true);
|
ui->CSVDepth->blockSignals(true);
|
||||||
ui->CSVTemperature->blockSignals(true);
|
|
||||||
ui->CSVTime->setValue(CSVApps[index].time);
|
ui->CSVTime->setValue(CSVApps[index].time);
|
||||||
ui->CSVDepth->setValue(CSVApps[index].depth);
|
ui->CSVDepth->setValue(CSVApps[index].depth);
|
||||||
ui->CSVTemperature->setValue(CSVApps[index].temperature);
|
|
||||||
ui->CSVTime->blockSignals(false);
|
ui->CSVTime->blockSignals(false);
|
||||||
ui->CSVDepth->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)
|
void CSVImportDialog::unknownImports(int arg1)
|
||||||
|
|
|
@ -24,6 +24,7 @@ private slots:
|
||||||
void on_knownImports_currentIndexChanged(int index);
|
void on_knownImports_currentIndexChanged(int index);
|
||||||
void on_CSVFile_textEdited();
|
void on_CSVFile_textEdited();
|
||||||
void unknownImports(int);
|
void unknownImports(int);
|
||||||
|
void unknownImports(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void unknownImports();
|
void unknownImports();
|
||||||
|
|
|
@ -100,93 +100,62 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Field Configuration</string>
|
<string>Field Configuration</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QSpinBox" name="CSVTime">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="geometry">
|
<item row="0" column="1">
|
||||||
<rect>
|
<widget class="QSpinBox" name="CSVTime">
|
||||||
<x>60</x>
|
<property name="minimum">
|
||||||
<y>30</y>
|
<number>0</number>
|
||||||
<width>56</width>
|
</property>
|
||||||
<height>29</height>
|
<property name="value">
|
||||||
</rect>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
</widget>
|
||||||
<number>0</number>
|
</item>
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
<property name="value">
|
<widget class="QLabel" name="label">
|
||||||
<number>0</number>
|
<property name="text">
|
||||||
</property>
|
<string>Time</string>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QSpinBox" name="CSVDepth">
|
</widget>
|
||||||
<property name="geometry">
|
</item>
|
||||||
<rect>
|
<item row="1" column="1">
|
||||||
<x>60</x>
|
<widget class="QSpinBox" name="CSVDepth">
|
||||||
<y>70</y>
|
<property name="minimum">
|
||||||
<width>56</width>
|
<number>0</number>
|
||||||
<height>29</height>
|
</property>
|
||||||
</rect>
|
<property name="value">
|
||||||
</property>
|
<number>1</number>
|
||||||
<property name="minimum">
|
</property>
|
||||||
<number>0</number>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="value">
|
<item row="1" column="0">
|
||||||
<number>1</number>
|
<widget class="QLabel" name="label_2">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Depth</string>
|
||||||
<widget class="QSpinBox" name="CSVTemperature">
|
</property>
|
||||||
<property name="geometry">
|
</widget>
|
||||||
<rect>
|
</item>
|
||||||
<x>60</x>
|
<item row="2" column="1">
|
||||||
<y>110</y>
|
<widget class="QSpinBox" name="CSVTemperature">
|
||||||
<width>56</width>
|
<property name="enabled">
|
||||||
<height>29</height>
|
<bool>false</bool>
|
||||||
</rect>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="minimum">
|
</item>
|
||||||
<number>0</number>
|
<item row="2" column="0">
|
||||||
</property>
|
<widget class="QCheckBox" name="temperatureCheckBox">
|
||||||
<property name="value">
|
<property name="text">
|
||||||
<number>15</number>
|
<string>Temp</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label">
|
</item>
|
||||||
<property name="geometry">
|
</layout>
|
||||||
<rect>
|
<zorder>label</zorder>
|
||||||
<x>0</x>
|
<zorder>label_2</zorder>
|
||||||
<y>30</y>
|
<zorder>CSVTime</zorder>
|
||||||
<width>41</width>
|
<zorder>CSVDepth</zorder>
|
||||||
<height>19</height>
|
<zorder>temperatureCheckBox</zorder>
|
||||||
</rect>
|
<zorder>CSVTemperature</zorder>
|
||||||
</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>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
@ -249,5 +218,11 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>temperatureCheckBox</sender>
|
||||||
|
<signal>clicked(bool)</signal>
|
||||||
|
<receiver>CSVTemperature</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -96,10 +96,14 @@
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
|
|
||||||
<xsl:attribute name="temp">
|
<xsl:attribute name="temp">
|
||||||
<xsl:call-template name="getFieldByIndex">
|
<xsl:choose>
|
||||||
<xsl:with-param name="index" select="$tempField"/>
|
<xsl:when test="$tempField >= 0">
|
||||||
<xsl:with-param name="line" select="$line"/>
|
<xsl:call-template name="getFieldByIndex">
|
||||||
</xsl:call-template>
|
<xsl:with-param name="index" select="$tempField"/>
|
||||||
|
<xsl:with-param name="line" select="$line"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</sample>
|
</sample>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
Loading…
Add table
Reference in a new issue