diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-05-25 15:19:36 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-26 13:18:22 -0700 |
commit | 777f04724717513c7a0e14b13aa66934328c8245 (patch) | |
tree | 0c27bb049656f27b0f22c1c63fcad0f8618cca19 /qt-ui/mainwindow.cpp | |
parent | dcd83817648ed227a4a3453923e29a662fa2cc67 (diff) | |
download | subsurface-777f04724717513c7a0e14b13aa66934328c8245.tar.gz |
Small code cleanup.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 25 |
1 files changed, 16 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(); |