diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2013-12-29 18:11:20 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-03 10:30:08 -0800 |
commit | b052b790dfe1cddccebf1ea52197c6781eeaf775 (patch) | |
tree | 38aa1677dd898f7369d5ac27f1dbfa2fd6389dd5 /qt-ui/csvimportdialog.cpp | |
parent | 646c6ba58b28cc2a2dec8e0a2187158623416b6e (diff) | |
download | subsurface-b052b790dfe1cddccebf1ea52197c6781eeaf775.tar.gz |
Refactoring import to DiveLogImportDialog
Changing the import stuff to DiveLogImport. Now we should have one
import function/dialog for importing divelogs instead of multiple menu
entries.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/csvimportdialog.cpp')
-rw-r--r-- | qt-ui/csvimportdialog.cpp | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp deleted file mode 100644 index 8ddf760f9..000000000 --- a/qt-ui/csvimportdialog.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include <QtDebug> -#include <QFileDialog> -#include "csvimportdialog.h" -#include "mainwindow.h" -#include "ui_csvimportdialog.h" - -const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = { - {"", }, - {"APD Log Viewer", 1, 2, 16, 7, 18, 19, "Tab"}, - {"XP5", 1, 2, 10, -1, -1, -1, "Tab"}, - {NULL,} -}; - -CSVImportDialog::CSVImportDialog(QWidget *parent) : - QDialog(parent), - selector(true), - ui(new Ui::CSVImportDialog) -{ - ui->setupUi(this); - - for (int i = 0; !CSVApps[i].name.isNull(); ++i) - ui->knownImports->addItem(CSVApps[i].name); - - 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))); - connect(ui->CSVTemperature, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); - connect(ui->temperatureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); - connect(ui->CSVpo2, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); - connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); - connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); - connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); - connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int))); - connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); -} - -CSVImportDialog::~CSVImportDialog() -{ - delete ui; -} - -#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1: -1) -void CSVImportDialog::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, - 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); - - mainWindow()->refreshDisplay(); -} - -void CSVImportDialog::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);\ - ui->CSV->setEnabled(VAL >= 0);\ - ui->BOX->setChecked(VAL >= 0);\ - ui->CSV->blockSignals(false);\ - }) -void CSVImportDialog::on_knownImports_currentIndexChanged(int index) -{ - if (index == 0) - return; - - ui->CSVTime->blockSignals(true); - ui->CSVDepth->blockSignals(true); - ui->CSVTime->setValue(CSVApps[index].time); - ui->CSVDepth->setValue(CSVApps[index].depth); - ui->CSVTime->blockSignals(false); - ui->CSVDepth->blockSignals(false); - SET_VALUE_AND_CHECKBOX(CSVTemperature, temperatureCheckBox, CSVApps[index].temperature); - SET_VALUE_AND_CHECKBOX(CSVpo2, po2CheckBox, CSVApps[index].po2); - SET_VALUE_AND_CHECKBOX(CSVcns, cnsCheckBox, CSVApps[index].cns); - SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth); -} - -void CSVImportDialog::unknownImports(bool arg1) -{ - unknownImports(); -} - -void CSVImportDialog::unknownImports(int arg1) -{ - unknownImports(); -} - -void CSVImportDialog::unknownImports() -{ - ui->knownImports->setCurrentIndex(0); -} - -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); -} |