diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-01-07 22:01:28 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-08 05:54:20 +0800 |
commit | 88fdf1b138afaead559456d1734eae88b4778f83 (patch) | |
tree | 11fa840c47e78f8cf0691674fd7c32f97be5b38b /qt-ui/divelogimportdialog.cpp | |
parent | 58f6a01a220bcdc25de2aac84a4eb5e49562d739 (diff) | |
download | subsurface-88fdf1b138afaead559456d1734eae88b4778f83.tar.gz |
Show import dialog only when needed for CSV config
We do not need any import dialog when importing normal XML based
divelogs. With this they are imported directly after file selection
dialog. However, when CSV files are detected in the import list, the
configuration dialog is displayed and applied for them. (CSV files are
detected by file extension.)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelogimportdialog.cpp')
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 60 |
1 files changed, 4 insertions, 56 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 129dbd9d0..e5814795d 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -11,12 +11,13 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {NULL,} }; -DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) : +DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent), selector(true), ui(new Ui::DiveLogImportDialog) { ui->setupUi(this); + fileNames = *fn; for (int i = 0; !CSVApps[i].name.isNull(); ++i) ui->knownImports->addItem(CSVApps[i].name); @@ -24,7 +25,6 @@ DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) : ui->CSVSeparator->addItem("Tab"); ui->CSVSeparator->addItem(","); ui->knownImports->setCurrentIndex(1); - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); @@ -48,30 +48,8 @@ void DiveLogImportDialog::on_buttonBox_accepted() { 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, + for (int i = 0; i < fileNames.size(); ++i) { + parse_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1, ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature), VALUE_IF_CHECKED(CSVpo2), VALUE_IF_CHECKED(CSVcns), @@ -89,13 +67,6 @@ void DiveLogImportDialog::on_buttonBox_accepted() mainWindow()->refreshDisplay(); } -void DiveLogImportDialog::on_CSVFileSelector_clicked() -{ - QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv);;All Files(*)")); - ui->CSVFile->setText(filename); - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!filename.isEmpty()); -} - #define SET_VALUE_AND_CHECKBOX(CSV, BOX, VAL) ({\ ui->CSV->blockSignals(true);\ ui->CSV->setValue(VAL);\ @@ -134,26 +105,3 @@ void DiveLogImportDialog::unknownImports() { ui->knownImports->setCurrentIndex(0); } - -void DiveLogImportDialog::on_CSVFile_textEdited() -{ - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty()); -} - -void DiveLogImportDialog::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 DiveLogImportDialog::on_DiveLogFile_editingFinished() -{ - if (ui->DiveLogFile->text().size()) - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); - else - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); -} |