From 488ff19fd92dc648dc1672bd9cd83ee99cb8d128 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 25 Jun 2013 13:35:04 +0300 Subject: Add the 'Import files' functionality Similar to File->Open but for multiple files and without calling on_actionClose_triggered(). Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index fc454ab2f..1144fa18f 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -170,7 +170,42 @@ void MainWindow::on_actionClose_triggered() void MainWindow::on_actionImport_triggered() { - qDebug("actionImport"); + QSettings settings; + QString lastDir = QDir::homePath(); + + settings.beginGroup("FileDialog"); + if (settings.contains("LastDir")) + if (QDir::setCurrent(settings.value("LastDir").toString())) + lastDir = settings.value("LastDir").toString(); + settings.endGroup(); + + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import Files"), lastDir, filter()); + if (!fileNames.size()) + return; // no selection + + // Keep last open dir + QFileInfo fileInfo(fileNames.at(0)); + settings.beginGroup("FileDialog"); + settings.setValue("LastDir", fileInfo.dir().path()); + settings.endGroup(); + + QByteArray fileNamePtr; + char *error = NULL; + for (int i = 0; i < fileNames.size(); ++i) { + fileNamePtr = fileNames.at(i).toLocal8Bit(); + parse_file(fileNamePtr.data(), &error); + if (error != NULL) { + showError(error); + free(error); + error = NULL; + } + } + process_dives(FALSE, FALSE); + + ui->InfoWidget->reload(); + ui->globe->reload(); + ui->ListWidget->reload(DiveTripModel::TREE); + ui->ListWidget->setFocus(); } void MainWindow::on_actionExportUDDF_triggered() -- cgit v1.2.3-70-g09d2