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/mainwindow.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/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c6e05faa4..cf97ca1f0 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -857,10 +857,24 @@ void MainWindow::loadFiles(const QStringList fileNames) void MainWindow::on_actionImportDiveLog_triggered() { - DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(); - diveLogImport->show(); - process_dives(TRUE, FALSE); - refreshDisplay(); + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), lastUsedDir(), tr("Dive Log Files (*.xml *.uddf *.udcf *.csv *.jlb *.dld *.sde *.db);;XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;JDiveLog Files(*.jlb);;Suunto Files(*.sde *.db);;CSV Files(*.csv);;All Files(*)")); + + if (fileNames.isEmpty()) + return; + updateLastUsedDir(QFileInfo(fileNames[0]).dir().path()); + + QStringList logFiles = fileNames.filter( QRegExp("^.*\\.(?!csv)", Qt::CaseInsensitive) ) ; + QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive); + if (logFiles.size()) { + importFiles(logFiles); + } + + if (csvFiles.size()) { + DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(&csvFiles); + diveLogImport->show(); + process_dives(TRUE, FALSE); + refreshDisplay(); + } } void MainWindow::editCurrentDive() |