From 646c6ba58b28cc2a2dec8e0a2187158623416b6e Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 29 Dec 2013 18:11:19 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/csvimportdialog.cpp | 64 +++++- qt-ui/csvimportdialog.h | 3 + qt-ui/csvimportdialog.ui | 509 +++++++++++++++++++++++++++------------------- 3 files changed, 354 insertions(+), 222 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp index b88d9ceca..8ddf760f9 100644 --- a/qt-ui/csvimportdialog.cpp +++ b/qt-ui/csvimportdialog.cpp @@ -48,17 +48,41 @@ void CSVImportDialog::on_buttonBox_accepted() { char *error = NULL; - parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value() - 1, - ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature), - VALUE_IF_CHECKED(CSVpo2), - VALUE_IF_CHECKED(CSVcns), - VALUE_IF_CHECKED(CSVstopdepth), - ui->CSVSeparator->currentIndex(), - &error); - if (error != NULL) { - mainWindow()->showError(error); - free(error); - 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, + ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature), + VALUE_IF_CHECKED(CSVpo2), + VALUE_IF_CHECKED(CSVcns), + VALUE_IF_CHECKED(CSVstopdepth), + ui->CSVSeparator->currentIndex(), + &error); + if (error != NULL) { + mainWindow()->showError(error); + free(error); + error = NULL; + } } process_dives(TRUE, FALSE); @@ -115,3 +139,21 @@ void CSVImportDialog::on_CSVFile_textEdited() { 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); +} diff --git a/qt-ui/csvimportdialog.h b/qt-ui/csvimportdialog.h index fda36bcb7..90dd2ac48 100644 --- a/qt-ui/csvimportdialog.h +++ b/qt-ui/csvimportdialog.h @@ -26,6 +26,9 @@ private slots: void unknownImports(int); void unknownImports(bool); + void on_DiveLogFileSelector_clicked(); + void on_DiveLogFile_editingFinished(); + private: void unknownImports(); diff --git a/qt-ui/csvimportdialog.ui b/qt-ui/csvimportdialog.ui index 9c89704f3..68e95d0a0 100644 --- a/qt-ui/csvimportdialog.ui +++ b/qt-ui/csvimportdialog.ui @@ -6,8 +6,8 @@ 0 0 - 432 - 330 + 515 + 440 @@ -20,28 +20,293 @@ - - - - 0 - 0 - + + + + Droid Sans [unknown] + 14 + 75 + true + - - Import File (CSV) + + QFrame::NoFrame + + + Import Dive Log File + + + Qt::AlignCenter - - - - - - - - ... - - - - + + + + + + 0 + + + + DiveLog + + + + + 10 + 10 + 441 + 65 + + + + + 0 + 0 + + + + Import File + + + + + + + + + ... + + + + + + + + + CSV + + + + + 10 + 10 + 441 + 65 + + + + + 0 + 0 + + + + Import File + + + + + + + + + ... + + + + + + + + + 210 + 88 + 281 + 65 + + + + Field Separator + + + + + + + + + + + 210 + 159 + 281 + 65 + + + + + 0 + 0 + + + + Pre-configured imports + + + + + + -1 + + + + + + + + + 16 + 88 + 185 + 246 + + + + + 0 + 0 + + + + Field Configuration + + + + + + 1 + + + false + + + 0 + + + + + + + 1 + + + 2 + + + + + + + 1 + + + false + + + + + + + Depth + + + + + + + 1 + + + false + + + 0 + + + + + + + Stopdepth + + + + + + + PO2 + + + + + + + Time + + + + + + + Temp + + + + + + + 1 + + + 1 + + + + + + + 1 + + + false + + + 0 + + + + + + + Cns + + + + + label + label_2 + CSVTime + CSVDepth + temperatureCheckBox + CSVTemperature + po2CheckBox + CSVpo2 + cnsCheckBox + CSVcns + stopdepthCheckBox + CSVstopdepth + + @@ -50,147 +315,18 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 - - - - - 0 - 0 - - - - Field Configuration - - - - - - 1 - - - 1 - - - - - - - Time - - - - - - - 1 - - - 2 - - - - - - - Depth - - - - - - - 1 - - - false - - - - - - - Temp - - - - - - - 1 - - - false - - - 0 - - - - - - - PO2 - - - - - - - 1 - - - false - - - 0 - - - - - - - Cns - - - - - - - 1 - - - false - - - 0 - - - - - - - Stopdepth - - - - - label - label_2 - CSVTime - CSVDepth - temperatureCheckBox - CSVTemperature - po2CheckBox - CSVpo2 - cnsCheckBox - CSVcns - stopdepthCheckBox - CSVstopdepth - - @@ -203,53 +339,6 @@ 0 - - - - Field Separator - - - - - - - - - - - - - 0 - 0 - - - - Pre-configured imports - - - - - - -1 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -268,9 +357,7 @@ - - - + buttonBox -- cgit v1.2.3-70-g09d2