diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index fc454ab2f..0655e7a40 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -86,7 +86,7 @@ void MainWindow::redrawProfile() void MainWindow::on_actionNew_triggered() { - qDebug("actionNew"); + on_actionClose_triggered(); } void MainWindow::on_actionOpen_triggered() @@ -120,6 +120,7 @@ void MainWindow::on_actionOpen_triggered() char *error = NULL; parse_file(fileNamePtr.data(), &error); set_filename(fileNamePtr.data(), TRUE); + setTitle(MWTF_FILENAME); if (error != NULL) { showError(error); @@ -164,13 +165,49 @@ void MainWindow::on_actionClose_triggered() ui->ProfileWidget->clear(); ui->ListWidget->reload(DiveTripModel::TREE); ui->globe->reload(); + setTitle(MWTF_DEFAULT); clear_events(); } 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() @@ -295,8 +332,8 @@ void MainWindow::on_actionViewInfo_triggered() void MainWindow::on_actionViewGlobe_triggered() { - ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); - ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); + ui->mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui->listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); } #undef BEHAVIOR @@ -638,6 +675,7 @@ void MainWindow::file_save_as(void) if (!filename.isNull() && !filename.isEmpty()) { save_dives(filename.toUtf8().data()); set_filename(filename.toUtf8().data(), TRUE); + setTitle(MWTF_FILENAME); mark_divelist_changed(FALSE); } } @@ -670,3 +708,18 @@ void MainWindow::showError(QString message) ui->mainErrorMessage->setMessageType(KMessageWidget::Error); ui->mainErrorMessage->animatedShow(); } + +void MainWindow::setTitle(enum MainWindowTitleFormat format) +{ + switch (format) { + case MWTF_DEFAULT: + setWindowTitle("Subsurface"); + break; + case MWTF_FILENAME: + QFile f(existing_filename); + QFileInfo fileInfo(f); + QString fileName(fileInfo.fileName()); + setWindowTitle("Subsurface: " + fileName); + break; + } +} |