diff options
-rw-r--r-- | qt-ui/mainwindow.cpp | 25 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 2 |
2 files changed, 18 insertions, 9 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 801268a08..a10dac2e4 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -355,15 +355,24 @@ void MainWindow::on_actionEditDeviceNames_triggered() DiveComputerManagementDialog::instance()->show(); } -void MainWindow::on_actionDivePlanner_triggered() +bool MainWindow::plannerStateClean() { - int i; - struct dive *dive; if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to plan a dive.")); - return; + QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive.")); + return false; } + return true; +} + +void MainWindow::on_actionDivePlanner_triggered() +{ + if (!plannerStateClean()) + return; + + int i; + struct dive *dive; + disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); DivePlannerPointsModel::instance()->clear(); @@ -381,11 +390,9 @@ void MainWindow::on_actionDivePlanner_triggered() void MainWindow::on_actionAddDive_triggered() { - if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive.")); + if(!plannerStateClean()) return; - } + dive_list()->rememberSelection(); dive_list()->unselectDives(); disableDcShortcuts(); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index a658fe3cc..667e3810a 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -172,6 +172,8 @@ private: void updateLastUsedDir(const QString &s); bool filesAsArguments; UpdateManager *updateManager; + + bool plannerStateClean(); }; #endif // MAINWINDOW_H |