mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Merging Import dialog
This patch merges import dialog with CSV import dialog. The aim is to have only one import menu entry for log files. This menu entry pops up an import dialog that has tabs for different types of imports (supported dive logs and CSV configuration currently). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
65eb86f854
commit
646c6ba58b
3 changed files with 354 additions and 222 deletions
|
@ -48,6 +48,29 @@ void CSVImportDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
|
if (ui->tabWidget->currentIndex() == 0) {
|
||||||
|
QStringList fileNames = ui->DiveLogFile->text().split(";");
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (ui->ImportAdvanced->isChecked()) {
|
||||||
|
for (int i = 0; i < fileNames.size(); ++i) {
|
||||||
|
parse_xml_file_units(fileNames.at(i).toUtf8().data(),
|
||||||
|
ui->XMLImportFormat->currentIndex(), ui->XMLImportUnits->currentIndex(),
|
||||||
|
&error);
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
|
||||||
|
mainWindow()->showError(error);
|
||||||
|
free(error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*/
|
||||||
|
mainWindow()->importFiles(fileNames);
|
||||||
|
return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
} else {
|
||||||
parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value() - 1,
|
parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value() - 1,
|
||||||
ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
|
ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
|
||||||
VALUE_IF_CHECKED(CSVpo2),
|
VALUE_IF_CHECKED(CSVpo2),
|
||||||
|
@ -60,6 +83,7 @@ void CSVImportDialog::on_buttonBox_accepted()
|
||||||
free(error);
|
free(error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
process_dives(TRUE, FALSE);
|
process_dives(TRUE, FALSE);
|
||||||
|
|
||||||
mainWindow()->refreshDisplay();
|
mainWindow()->refreshDisplay();
|
||||||
|
@ -115,3 +139,21 @@ void CSVImportDialog::on_CSVFile_textEdited()
|
||||||
{
|
{
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty());
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVImportDialog::on_DiveLogFileSelector_clicked()
|
||||||
|
{
|
||||||
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), ".", tr("XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;All Files(*)"));
|
||||||
|
ui->DiveLogFile->setText(fileNames.join(";"));
|
||||||
|
if (fileNames.size())
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
|
else
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVImportDialog::on_DiveLogFile_editingFinished()
|
||||||
|
{
|
||||||
|
if (ui->DiveLogFile->text().size())
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
|
else
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ private slots:
|
||||||
void unknownImports(int);
|
void unknownImports(int);
|
||||||
void unknownImports(bool);
|
void unknownImports(bool);
|
||||||
|
|
||||||
|
void on_DiveLogFileSelector_clicked();
|
||||||
|
void on_DiveLogFile_editingFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void unknownImports();
|
void unknownImports();
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>515</width>
|
||||||
<height>330</height>
|
<height>440</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -20,7 +20,44 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Droid Sans [unknown]</family>
|
||||||
|
<pointsize>14</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Import Dive Log File</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>DiveLog</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QGroupBox" name="groupBox_8">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>65</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -28,7 +65,43 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Import File (CSV)</string>
|
<string>Import File</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="DiveLogFile"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="DiveLogFileSelector">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>CSV</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>65</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Import File</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -43,18 +116,61 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>210</x>
|
||||||
|
<y>88</y>
|
||||||
|
<width>281</width>
|
||||||
|
<height>65</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Field Separator</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="CSVSeparator"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<widget class="QWidget" name="horizontalWidget" native="true">
|
</widget>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="spacing">
|
<property name="geometry">
|
||||||
<number>0</number>
|
<rect>
|
||||||
|
<x>210</x>
|
||||||
|
<y>159</y>
|
||||||
|
<width>281</width>
|
||||||
|
<height>65</height>
|
||||||
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="sizePolicy">
|
||||||
<number>0</number>
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Pre-configured imports</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
|
<widget class="QComboBox" name="knownImports">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>16</x>
|
||||||
|
<y>88</y>
|
||||||
|
<width>185</width>
|
||||||
|
<height>246</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -65,57 +181,6 @@
|
||||||
<string>Field Configuration</string>
|
<string>Field Configuration</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QSpinBox" name="CSVTime">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1</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>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>2</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="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<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>
|
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QSpinBox" name="CSVpo2">
|
<widget class="QSpinBox" name="CSVpo2">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
|
@ -129,30 +194,30 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="1" column="1">
|
||||||
<widget class="QCheckBox" name="po2CheckBox">
|
<widget class="QSpinBox" name="CSVDepth">
|
||||||
<property name="text">
|
<property name="minimum">
|
||||||
<string>PO2</string>
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="CSVcns">
|
<widget class="QSpinBox" name="CSVTemperature">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QCheckBox" name="cnsCheckBox">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cns</string>
|
<string>Depth</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -176,6 +241,57 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="po2CheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>PO2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="temperatureCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Temp</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="CSVTime">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QSpinBox" name="CSVcns">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QCheckBox" name="cnsCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cns</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<zorder>label</zorder>
|
<zorder>label</zorder>
|
||||||
<zorder>label_2</zorder>
|
<zorder>label_2</zorder>
|
||||||
|
@ -190,7 +306,27 @@
|
||||||
<zorder>stopdepthCheckBox</zorder>
|
<zorder>stopdepthCheckBox</zorder>
|
||||||
<zorder>CSVstopdepth</zorder>
|
<zorder>CSVstopdepth</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="horizontalWidget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="verticalWidget" native="true">
|
<widget class="QWidget" name="verticalWidget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
@ -203,53 +339,6 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Field Separator</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="CSVSeparator"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Pre-configured imports</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="knownImports">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -268,9 +357,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../subsurface.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
|
Loading…
Reference in a new issue