From 89b914e47dc2f996e5bd0d80dfba5e9b00b28631 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Wed, 19 Apr 2017 08:05:28 +0200 Subject: Preserve dive mode when planning a dive Data such as cilinders and used gasses are populated fromn the currently selected dive when starting the planner. It is more logical to use the dive mode (OC, CCR, pSCR) of the currently selected dive as well. This commits changes this. Signed-off-by: Jan Mulder --- desktop-widgets/diveplanner.cpp | 5 +++++ desktop-widgets/diveplanner.h | 1 + desktop-widgets/mainwindow.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 9dce53da8..3b4a5484b 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -186,6 +186,11 @@ void DivePlannerWidget::setSurfacePressure(int surface_pressure) ui.ATMPressure->setValue(surface_pressure); } +void PlannerSettingsWidget::setDiveMode(int mode) +{ + ui.rebreathermode->setCurrentIndex(mode); +} + void DivePlannerWidget::setSalinity(int salinity) { ui.salinity->setValue(salinity / 10000.0); diff --git a/desktop-widgets/diveplanner.h b/desktop-widgets/diveplanner.h index f0cae3e5b..0c8d29b42 100644 --- a/desktop-widgets/diveplanner.h +++ b/desktop-widgets/diveplanner.h @@ -85,6 +85,7 @@ slots: void setBestmixEND(int depth); void setBackgasBreaks(bool dobreaks); void disableDecoElements(int mode); + void setDiveMode(int mode); private: Ui::plannerSettingsWidget ui; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 259db6a33..0ce5ef648 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -908,6 +908,7 @@ void MainWindow::setupForAddAndPlan(const char *model) // setup the dive cylinders DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->setupCylinders(); + } void MainWindow::on_actionReplanDive_triggered() @@ -951,6 +952,8 @@ void MainWindow::on_actionDivePlanner_triggered() setupForAddAndPlan("planned dive"); // don't translate, stored in XML file DivePlannerPointsModel::instance()->setupStartTime(); DivePlannerPointsModel::instance()->createSimpleDive(); + // plan the dive in the same mode as the currently selected one + divePlannerSettingsWidget()->setDiveMode(current_dive->dc.divemode); DivePictureModel::instance()->updateDivePictures(); divePlannerWidget()->setReplanButton(false); } -- cgit v1.2.3-70-g09d2