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>
This commit is contained in:
Lubomir I. Ivanov 2013-06-25 13:35:04 +03:00 committed by Dirk Hohndel
parent 48ba01b807
commit 488ff19fd9

View file

@ -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()