aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-06-25 13:35:04 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-27 07:22:00 +0800
commit488ff19fd92dc648dc1672bd9cd83ee99cb8d128 (patch)
tree6578704f32bd8b193ffe6846935c24ebb7a10782
parent48ba01b807cc993e5689abe2ff781d31deb4c91a (diff)
downloadsubsurface-488ff19fd92dc648dc1672bd9cd83ee99cb8d128.tar.gz
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 <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/mainwindow.cpp37
1 files changed, 36 insertions, 1 deletions
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()