From 48775c530e887bf3c64b4ec5ece3e289250e03a2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 6 Jan 2015 14:12:29 -0200 Subject: Clean a lot of code for a new and improved CSV import dialog This mostly cleans out stuff that is going to be uneeded. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 187 +----- qt-ui/divelogimportdialog.h | 20 - qt-ui/divelogimportdialog.ui | 1271 +++-------------------------------------- 3 files changed, 98 insertions(+), 1380 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 3318bc90b..02fc03e69 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -31,53 +31,10 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDi for (int i = 0; !CSVApps[i].name.isNull(); ++i) ui->knownImports->addItem(CSVApps[i].name); - ui->CSVSeparator->addItem("Tab"); - ui->CSVSeparator->addItem(","); - ui->CSVSeparator->addItem(";"); + ui->CSVSeparator->addItems( QStringList() << tr("Separator") << tr("Tab") << ";" << ","); ui->knownImports->setCurrentIndex(1); - ui->ManualSeparator->addItem("Tab"); - ui->ManualSeparator->addItem(","); - ui->ManualSeparator->addItem(";"); - ui->knownImports->setCurrentIndex(1); - - connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->CSVTemperature, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->temperatureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVpo2, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVndl, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->ndlCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVtts, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->ttsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); - connect(ui->CSVpressure, SIGNAL(valueChanged(int)), this, SLOT(unknownImports())); - connect(ui->pressureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports())); /* manually import CSV file */ - connect(ui->DiveNumberCheck, SIGNAL(clicked(bool)), this, SLOT(manualDiveNumber())); - connect(ui->DateCheck, SIGNAL(clicked(bool)), this, SLOT(manualDate())); - connect(ui->TimeCheck, SIGNAL(clicked(bool)), this, SLOT(manualTime())); - connect(ui->LocationCheck, SIGNAL(clicked(bool)), this, SLOT(manualLocation())); - connect(ui->GpsCheck, SIGNAL(clicked(bool)), this, SLOT(manualGps())); - connect(ui->MaxDepthCheck, SIGNAL(clicked(bool)), this, SLOT(manualMaxDepth())); - connect(ui->MeanDepthCheck, SIGNAL(clicked(bool)), this, SLOT(manualMeanDepth())); - connect(ui->BuddyCheck, SIGNAL(clicked(bool)), this, SLOT(manualBuddy())); - connect(ui->NotesCheck, SIGNAL(clicked(bool)), this, SLOT(manualNotes())); - connect(ui->TagsCheck, SIGNAL(clicked(bool)), this, SLOT(manualTags())); - connect(ui->WeightCheck, SIGNAL(clicked(bool)), this, SLOT(manualWeight())); - connect(ui->DurationCheck, SIGNAL(clicked(bool)), this, SLOT(manualDuration())); - connect(ui->CylinderSizeCheck, SIGNAL(clicked(bool)), this, SLOT(manualCylinderSize())); - connect(ui->StartPressureCheck, SIGNAL(clicked(bool)), this, SLOT(manualStartPressure())); - connect(ui->EndPressureCheck, SIGNAL(clicked(bool)), this, SLOT(manualEndPressure())); - connect(ui->O2Check, SIGNAL(clicked(bool)), this, SLOT(manualO2())); - connect(ui->HeCheck, SIGNAL(clicked(bool)), this, SLOT(manualHe())); - connect(ui->AirTempCheck, SIGNAL(clicked(bool)), this, SLOT(manualAirTemp())); - connect(ui->WaterTempCheck, SIGNAL(clicked(bool)), this, SLOT(manualWaterTemp())); - QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(close, SIGNAL(activated()), this, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); @@ -92,11 +49,11 @@ DiveLogImportDialog::~DiveLogImportDialog() #define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1) void DiveLogImportDialog::on_buttonBox_accepted() { - if (ui->tabWidget->currentIndex() == 0) { - for (int i = 0; i < fileNames.size(); ++i) { - if (ui->knownImports->currentText() == QString("Seabear CSV")) { - parse_seabear_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1, - ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature), + /* + for (int i = 0; i < fileNames.size(); ++i) { + if (ui->knownImports->currentText() == QString("Seabear CSV")) { + parse_seabear_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), VALUE_IF_CHECKED(CSVndl), @@ -107,7 +64,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv", ui->CSVUnits->currentIndex()); - /* Seabear CSV stores NDL and TTS in Minutes, not seconds */ + // Seabear CSV stores NDL and TTS in Minutes, not seconds struct dive *dive = dive_table.dives[dive_table.nr - 1]; for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) { struct sample *sample = dive->dc.sample + s_nr; @@ -147,7 +104,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() VALUE_IF_CHECKED(WaterTemp)); } } - +*/ process_dives(true, false); MainWindow::instance()->refreshDisplay(); @@ -159,34 +116,12 @@ void DiveLogImportDialog::on_buttonBox_accepted() ui->CSV->setEnabled(VAL >= 0);\ ui->BOX->setChecked(VAL >= 0);\ ui->CSV->blockSignals(false); }) + void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index) { - if (specialCSV.contains(index)) { - ui->groupBox_3->setEnabled(false); - } else { - ui->groupBox_3->setEnabled(true); - } 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(CSVndl, ndlCheckBox, CSVApps[index].ndl); - SET_VALUE_AND_CHECKBOX(CSVtts, ttsCheckBox, CSVApps[index].tts); - SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth); - SET_VALUE_AND_CHECKBOX(CSVpressure, pressureCheckBox, CSVApps[index].pressure); - ui->CSVSeparator->blockSignals(true); - int separator_index = ui->CSVSeparator->findText(CSVApps[index].separator); - if (separator_index != -1) - ui->CSVSeparator->setCurrentIndex(separator_index); - ui->CSVSeparator->blockSignals(false); } void DiveLogImportDialog::unknownImports() @@ -194,107 +129,3 @@ void DiveLogImportDialog::unknownImports() if (!specialCSV.contains(ui->knownImports->currentIndex())) ui->knownImports->setCurrentIndex(0); } - -#define SET_COLUMN(CHECK, VALUE) ({\ - if (ui->CHECK->isChecked()) {\ - ui->VALUE->setEnabled(true);\ - ui->VALUE->setValue(++column);\ - } else {\ - ui->VALUE->setEnabled(false);\ - --column;}\ - }) - -void DiveLogImportDialog::manualDiveNumber() -{ - SET_COLUMN(DiveNumberCheck, DiveNumber); -} - -void DiveLogImportDialog::manualDate() -{ - SET_COLUMN(DateCheck, Date); -} - -void DiveLogImportDialog::manualTime() -{ - SET_COLUMN(TimeCheck, Time); -} - -void DiveLogImportDialog::manualLocation() -{ - SET_COLUMN(LocationCheck, Location); -} - -void DiveLogImportDialog::manualGps() -{ - SET_COLUMN(GpsCheck, Gps); -} - -void DiveLogImportDialog::manualMaxDepth() -{ - SET_COLUMN(MaxDepthCheck, MaxDepth); -} - -void DiveLogImportDialog::manualMeanDepth() -{ - SET_COLUMN(MeanDepthCheck, MeanDepth); -} - -void DiveLogImportDialog::manualBuddy() -{ - SET_COLUMN(BuddyCheck, Buddy); -} - -void DiveLogImportDialog::manualNotes() -{ - SET_COLUMN(NotesCheck, Notes); -} - -void DiveLogImportDialog::manualTags() -{ - SET_COLUMN(TagsCheck, Tags); -} - -void DiveLogImportDialog::manualWeight() -{ - SET_COLUMN(WeightCheck, Weight); -} - -void DiveLogImportDialog::manualDuration() -{ - SET_COLUMN(DurationCheck, Duration); -} - -void DiveLogImportDialog::manualCylinderSize() -{ - SET_COLUMN(CylinderSizeCheck, CylinderSize); -} - -void DiveLogImportDialog::manualStartPressure() -{ - SET_COLUMN(StartPressureCheck, StartPressure); -} - -void DiveLogImportDialog::manualEndPressure() -{ - SET_COLUMN(EndPressureCheck, EndPressure); -} - -void DiveLogImportDialog::manualO2() -{ - SET_COLUMN(O2Check, O2); -} - -void DiveLogImportDialog::manualHe() -{ - SET_COLUMN(HeCheck, He); -} - -void DiveLogImportDialog::manualAirTemp() -{ - SET_COLUMN(AirTempCheck, AirTemp); -} - -void DiveLogImportDialog::manualWaterTemp() -{ - SET_COLUMN(WaterTempCheck, WaterTemp); -} diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h index 36314f7f5..b2ee4ff99 100644 --- a/qt-ui/divelogimportdialog.h +++ b/qt-ui/divelogimportdialog.h @@ -23,26 +23,6 @@ slots: void on_knownImports_currentIndexChanged(int index); void unknownImports(); - void manualDiveNumber(); - void manualDate(); - void manualTime(); - void manualLocation(); - void manualGps(); - void manualMaxDepth(); - void manualMeanDepth(); - void manualBuddy(); - void manualNotes(); - void manualTags(); - void manualWeight(); - void manualDuration(); - void manualCylinderSize(); - void manualStartPressure(); - void manualEndPressure(); - void manualO2(); - void manualHe(); - void manualAirTemp(); - void manualWaterTemp(); - private: bool selector; QStringList fileNames; diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui index 7b4e909bf..13ee3e9de 100644 --- a/qt-ui/divelogimportdialog.ui +++ b/qt-ui/divelogimportdialog.ui @@ -6,8 +6,8 @@ 0 0 - 522 - 436 + 709 + 646 @@ -19,816 +19,104 @@ - - - - 0 - - - - CSV options - - - - - - Units - - - - - - - Metric - - - - - Imperial - - - - - - - - - - - Field separator - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Field configuration - - - - - - false - - - 1 - - - 1 - - - - - - - 1 - - - 2 - - - - - - - false - - - 1 - - - - - - - Depth - - - - - - - false - - - 1 - - - 1 - - - - - - - Stopdepth - - - - - - - false - - - 1 - - - 1 - - - - - - - Pressure - - - - - - - pO₂ - - - - - - - Time - - - - - - - Temp - - - - - - - 1 - - - 1 - - - - - - - false - - - 1 - - - 1 - - - - - - - NDL - - - - - - - false - - - 1 - - - 1 - - - - - - - TTS - - - - - - - false - - - 1 - - - 1 - - - - - - - Cns - - - - - CSVpressure - pressureCheckBox - ndlCheckBox - CSVndl - ttsCheckBox - CSVtts - label - label_2 - CSVTime - CSVDepth - temperatureCheckBox - CSVTemperature - po2CheckBox - CSVpo2 - cnsCheckBox - CSVcns - stopdepthCheckBox - CSVstopdepth - - - - - - Pre-configured imports - - - - - - -1 - - - - - - - - - - - Manual dives - - - - - - - 0 - 0 - - - - - 0 - 70 - - - - Choose day, month and year order for date format. The field separator can be any of the characters .-/. - - - Date format - - - - - 20 - 40 - 100 - 27 - - - - - dd.mm.yyyy - - - - - mm/dd/yyyy - - - - - yyyy-mm-dd - - - - - - - - - - 0 - 0 - - - - - 0 - 70 - - - - Units - - - - - - - Metric - - - - - Imperial - - - - - - - - - - - Field configuration - - - - - - Dive # - - - - - - - false - - - 1 - - - - - - - Max depth - - - - - - - false - - - 1 - - - - - - - Date in dd.mm.yyyy, yyyy-mm-dd or mm/dd/yyyy format - - - Date - - - - - - - false - - - Date in dd.mm.yyyy, yyyy-mm-dd or mm/dd/yyyy format - - - 1 - - - - - - - Mean depth - - - - - - - false - - - 1 - - - - - - - Time - - - - - - - false - - - 1 - - - - - - - Buddy - - - - - - - false - - - 1 - - - - - - - Dive duration in seconds or in min:sec format - - - Duration - - - - - - - false - - - Dive duration in seconds or in min:sec format - - - 1 - - - - - - - Notes - - - - - - - false - - - 1 - - - - - - - Location - - - - - - - false - - - 1 - - - - - - - Weight - - - - - - - false - - - 1 - - - - - - - GPS - - - - - - - false - - - 1 - - - - - - - Tags - - - - - - - false - - - 1 - - - - - - - Cyl size - - - - - - - false - - - 1 - - - - - - - Air temp - - - - - - - false - - - 1 - - - - - - - Start Pressure - - - - - - - false - - - 1 - - - - - - - Water temp - - - - - - - false - - - 1 - - - - - - - End Press - - - - - - - false - - - 1 - - - - - - - O₂ - - - - - - - false - - - 1 - - - - - - - He - - - - - - - false - - - 1 - - - - - - - - - - - 0 - 0 - - - - - 0 - 70 - - - - Choose duration format. - - - Duration format - - - - - 20 - 40 - 100 - 27 - - - - - Seconds - - - - - Minutes - - - - - Minutes:seconds - - - - - - - - - - 0 - 0 - - - - - 0 - 70 - - - - Field separator - - - - - - - - - - - - 0 - - 0 - - - 0 - - - 0 - - + 0 - - 0 - - - 0 - - - 0 - + + + + + + -1 + + + + + + + + + + + dd.mm.yyyy + + + + + mm/dd/yyyy + + + + + yyyy-mm-dd + + + + + + + + + Seconds + + + + + Minutes + + + + + Minutes:seconds + + + + + + + + + Metric + + + + + Imperial + + + + + + + + + + + 16777215 + 150 + + + + + + + + Drag the tags above to each corresponding column below + + + + + + @@ -848,19 +136,6 @@ - tabWidget - CSVTime - CSVDepth - temperatureCheckBox - CSVTemperature - po2CheckBox - CSVpo2 - cnsCheckBox - CSVcns - stopdepthCheckBox - CSVstopdepth - CSVSeparator - knownImports buttonBox @@ -897,373 +172,5 @@ - - temperatureCheckBox - clicked(bool) - CSVTemperature - setEnabled(bool) - - - 108 - 169 - - - 238 - 171 - - - - - po2CheckBox - clicked(bool) - CSVpo2 - setEnabled(bool) - - - 108 - 201 - - - 238 - 203 - - - - - cnsCheckBox - clicked(bool) - CSVcns - setEnabled(bool) - - - 108 - 233 - - - 238 - 235 - - - - - stopdepthCheckBox - clicked(bool) - CSVstopdepth - setEnabled(bool) - - - 108 - 265 - - - 238 - 267 - - - - - DiveNumberCheck - clicked(bool) - DiveNumber - setEnabled(bool) - - - 96 - 103 - - - 176 - 105 - - - - - DateCheck - clicked(bool) - Date - setEnabled(bool) - - - 96 - 135 - - - 176 - 137 - - - - - TimeCheck - clicked(bool) - Time - setEnabled(bool) - - - 96 - 167 - - - 176 - 169 - - - - - LocationCheck - clicked(bool) - Location - setEnabled(bool) - - - 96 - 231 - - - 176 - 233 - - - - - GpsCheck - clicked(bool) - Gps - setEnabled(bool) - - - 96 - 263 - - - 176 - 265 - - - - - MaxDepthCheck - clicked(bool) - MaxDepth - setEnabled(bool) - - - 185 - 103 - - - 296 - 105 - - - - - MeanDepthCheck - clicked(bool) - MeanDepth - setEnabled(bool) - - - 185 - 135 - - - 296 - 137 - - - - - BuddyCheck - clicked(bool) - Buddy - setEnabled(bool) - - - 185 - 167 - - - 296 - 169 - - - - - NotesCheck - clicked(bool) - Notes - setEnabled(bool) - - - 185 - 199 - - - 296 - 201 - - - - - TagsCheck - clicked(bool) - Tags - setEnabled(bool) - - - 185 - 263 - - - 296 - 265 - - - - - WeightCheck - clicked(bool) - Weight - setEnabled(bool) - - - 185 - 231 - - - 296 - 233 - - - - - DurationCheck - clicked(bool) - Duration - setEnabled(bool) - - - 96 - 199 - - - 176 - 201 - - - - - CylinderSizeCheck - clicked(bool) - CylinderSize - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - StartPressureCheck - clicked(bool) - StartPressure - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - EndPressureCheck - clicked(bool) - EndPressure - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - O2Check - clicked(bool) - O2 - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - HeCheck - clicked(bool) - He - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - AirTempCheck - clicked(bool) - AirTemp - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - WaterTempCheck - clicked(bool) - WaterTemp - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - -- cgit v1.2.3-70-g09d2