diff options
-rw-r--r-- | qt-ui/csvimportdialog.h | 10 | ||||
-rw-r--r-- | qt-ui/divelogimportdialog.cpp (renamed from qt-ui/csvimportdialog.cpp) | 30 | ||||
-rw-r--r-- | qt-ui/divelogimportdialog.h | 53 | ||||
-rw-r--r-- | qt-ui/divelogimportdialog.ui (renamed from qt-ui/csvimportdialog.ui) | 10 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 17 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 3 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 23 | ||||
-rw-r--r-- | subsurface.pro | 6 |
8 files changed, 93 insertions, 59 deletions
diff --git a/qt-ui/csvimportdialog.h b/qt-ui/csvimportdialog.h index 90dd2ac48..f062d49fd 100644 --- a/qt-ui/csvimportdialog.h +++ b/qt-ui/csvimportdialog.h @@ -7,16 +7,16 @@ #include "../divelist.h" namespace Ui { -class CSVImportDialog; +class DiveLogImportDialog; } -class CSVImportDialog : public QDialog +class DiveLogImportDialog : public QDialog { Q_OBJECT public: - explicit CSVImportDialog(QWidget *parent = 0); - ~CSVImportDialog(); + explicit DiveLogImportDialog(QWidget *parent = 0); + ~DiveLogImportDialog(); private slots: void on_buttonBox_accepted(); @@ -33,7 +33,7 @@ private: void unknownImports(); bool selector; - Ui::CSVImportDialog *ui; + Ui::DiveLogImportDialog *ui; struct CSVAppConfig { QString name; diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 8ddf760f9..129dbd9d0 100644 --- a/qt-ui/csvimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -1,20 +1,20 @@ #include <QtDebug> #include <QFileDialog> -#include "csvimportdialog.h" +#include "divelogimportdialog.h" #include "mainwindow.h" -#include "ui_csvimportdialog.h" +#include "ui_divelogimportdialog.h" -const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = { +const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::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) : +DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) : QDialog(parent), selector(true), - ui(new Ui::CSVImportDialog) + ui(new Ui::DiveLogImportDialog) { ui->setupUi(this); @@ -38,13 +38,13 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) : connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool))); } -CSVImportDialog::~CSVImportDialog() +DiveLogImportDialog::~DiveLogImportDialog() { delete ui; } #define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1: -1) -void CSVImportDialog::on_buttonBox_accepted() +void DiveLogImportDialog::on_buttonBox_accepted() { char *error = NULL; @@ -89,7 +89,7 @@ void CSVImportDialog::on_buttonBox_accepted() mainWindow()->refreshDisplay(); } -void CSVImportDialog::on_CSVFileSelector_clicked() +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); @@ -103,7 +103,7 @@ void CSVImportDialog::on_CSVFileSelector_clicked() ui->BOX->setChecked(VAL >= 0);\ ui->CSV->blockSignals(false);\ }) -void CSVImportDialog::on_knownImports_currentIndexChanged(int index) +void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index) { if (index == 0) return; @@ -120,27 +120,27 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index) SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth); } -void CSVImportDialog::unknownImports(bool arg1) +void DiveLogImportDialog::unknownImports(bool arg1) { unknownImports(); } -void CSVImportDialog::unknownImports(int arg1) +void DiveLogImportDialog::unknownImports(int arg1) { unknownImports(); } -void CSVImportDialog::unknownImports() +void DiveLogImportDialog::unknownImports() { ui->knownImports->setCurrentIndex(0); } -void CSVImportDialog::on_CSVFile_textEdited() +void DiveLogImportDialog::on_CSVFile_textEdited() { ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty()); } -void CSVImportDialog::on_DiveLogFileSelector_clicked() +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(";")); @@ -150,7 +150,7 @@ void CSVImportDialog::on_DiveLogFileSelector_clicked() ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } -void CSVImportDialog::on_DiveLogFile_editingFinished() +void DiveLogImportDialog::on_DiveLogFile_editingFinished() { if (ui->DiveLogFile->text().size()) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h new file mode 100644 index 000000000..9ecf32410 --- /dev/null +++ b/qt-ui/divelogimportdialog.h @@ -0,0 +1,53 @@ +#ifndef DIVELOGIMPORTDIALOG_H +#define DIVELOGIMPORTDIALOG_H + +#include <QDialog> +#include <QModelIndex> +#include "../dive.h" +#include "../divelist.h" + +namespace Ui { +class DiveLogImportDialog; +} + +class DiveLogImportDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DiveLogImportDialog(QWidget *parent = 0); + ~DiveLogImportDialog(); + +private slots: + void on_buttonBox_accepted(); + void on_CSVFileSelector_clicked(); + void on_knownImports_currentIndexChanged(int index); + void on_CSVFile_textEdited(); + void unknownImports(int); + void unknownImports(bool); + + void on_DiveLogFileSelector_clicked(); + void on_DiveLogFile_editingFinished(); + +private: + void unknownImports(); + + bool selector; + Ui::DiveLogImportDialog *ui; + + struct CSVAppConfig { + QString name; + int time; + int depth; + int temperature; + int po2; + int cns; + int stopdepth; + QString separator; + }; + +#define CSVAPPS 4 + static const CSVAppConfig CSVApps[CSVAPPS]; +}; + +#endif // DIVELOGIMPORTDIALOG_H diff --git a/qt-ui/csvimportdialog.ui b/qt-ui/divelogimportdialog.ui index 68e95d0a0..ac2315636 100644 --- a/qt-ui/csvimportdialog.ui +++ b/qt-ui/divelogimportdialog.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>CSVImportDialog</class> - <widget class="QDialog" name="CSVImportDialog"> + <class>DiveLogImportDialog</class> + <widget class="QDialog" name="DiveLogImportDialog"> <property name="geometry"> <rect> <x>0</x> @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Import CSV file</string> + <string>Import dive log file</string> </property> <property name="windowIcon"> <iconset> @@ -362,7 +362,7 @@ <connection> <sender>buttonBox</sender> <signal>accepted()</signal> - <receiver>CSVImportDialog</receiver> + <receiver>DiveLogImportDialog</receiver> <slot>accept()</slot> <hints> <hint type="sourcelabel"> @@ -378,7 +378,7 @@ <connection> <sender>buttonBox</sender> <signal>rejected()</signal> - <receiver>CSVImportDialog</receiver> + <receiver>DiveLogImportDialog</receiver> <slot>reject()</slot> <hints> <hint type="sourcelabel"> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ad52c7d7f..c6e05faa4 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -35,7 +35,7 @@ #include "diveplanner.h" #include "about.h" #include "printdialog.h" -#include "csvimportdialog.h" +#include "divelogimportdialog.h" static MainWindow* instance = 0; @@ -167,15 +167,6 @@ void MainWindow::on_actionClose_triggered() clear_events(); } -void MainWindow::on_actionImport_triggered() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import Files"), lastUsedDir(), filter()); - if (!fileNames.size()) - return; // no selection - updateLastUsedDir(QFileInfo(fileNames.at(0)).dir().path()); - importFiles(fileNames); -} - QString MainWindow::lastUsedDir() { QSettings settings; @@ -864,10 +855,10 @@ void MainWindow::loadFiles(const QStringList fileNames) ui.actionAutoGroup->setChecked(autogroup); } -void MainWindow::on_actionImportCSV_triggered() +void MainWindow::on_actionImportDiveLog_triggered() { - CSVImportDialog *csvImport = new CSVImportDialog(); - csvImport->show(); + DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(); + diveLogImport->show(); process_dives(TRUE, FALSE); refreshDisplay(); } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index d4e10e822..83672eafa 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -62,7 +62,6 @@ private slots: void on_actionSave_triggered(); void on_actionSaveAs_triggered(); void on_actionClose_triggered(); - void on_actionImport_triggered(); void on_actionExportUDDF_triggered(); void on_actionPrint_triggered(); void on_actionPreferences_triggered(); @@ -102,7 +101,7 @@ private slots: void current_dive_changed(int divenr); void initialUiSetup(); - void on_actionImportCSV_triggered(); + void on_actionImportDiveLog_triggered(); void linkClickedSlot(QUrl url); protected: diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 60aa787e4..85896de75 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -197,8 +197,7 @@ <string>&Import</string> </property> <addaction name="actionDownloadDC"/> - <addaction name="actionImport"/> - <addaction name="actionImportCSV"/> + <addaction name="actionImportDiveLog"/> <addaction name="actionDownloadWeb"/> <addaction name="actionDivelogs_de"/> </widget> @@ -264,17 +263,6 @@ <string>Ctrl+W</string> </property> </action> - <action name="actionImport"> - <property name="text"> - <string>Import Files</string> - </property> - <property name="toolTip"> - <string>Import Files</string> - </property> - <property name="shortcut"> - <string>Ctrl+I</string> - </property> - </action> <action name="actionExportUDDF"> <property name="text"> <string>Export &UDDF</string> @@ -461,12 +449,15 @@ <string>Ctrl+L</string> </property> </action> - <action name="actionImportCSV"> + <action name="actionImportDiveLog"> <property name="text"> - <string>Import CSV</string> + <string>Import Files</string> </property> <property name="toolTip"> - <string>Import CS&V</string> + <string>Import Files</string> + </property> + <property name="shortcut"> + <string>Ctrl+I</string> </property> </action> <action name="actionDivelogs_de"> diff --git a/subsurface.pro b/subsurface.pro index 244359271..e40de0991 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -54,7 +54,7 @@ HEADERS = \ subsurfacestartup.h \ uemis.h \ webservice.h \ - qt-ui/csvimportdialog.h \ + qt-ui/divelogimportdialog.h \ qt-ui/tagwidget.h \ qt-ui/groupedlineedit.h @@ -103,7 +103,7 @@ SOURCES = \ time.c \ uemis.c \ uemis-downloader.c \ - qt-ui/csvimportdialog.cpp \ + qt-ui/divelogimportdialog.cpp \ qt-ui/tagwidget.cpp \ qt-ui/groupedlineedit.cpp @@ -124,7 +124,7 @@ FORMS = \ qt-ui/shifttimes.ui \ qt-ui/webservices.ui \ qt-ui/tableview.ui \ - qt-ui/csvimportdialog.ui + qt-ui/divelogimportdialog.ui RESOURCES = subsurface.qrc |