summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2019-12-23 17:25:46 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-26 09:58:21 -0800
commit738ee360ba1b22c2be22fd7021205dd9dfae1f3d (patch)
treed9dc54243fb5f923e6085e9d1ad47d1f98fdebad
parentc4d9b737cdf0881a81c6ba635bd9dedbc3a1af26 (diff)
downloadsubsurface-738ee360ba1b22c2be22fd7021205dd9dfae1f3d.tar.gz
desktop-widgets: replace o2narcotic from plannerModel to plannerShared
Use plannerShared setter to update o2narcotic. This will also signal the cylindermodel to calculate a new bestmix. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--backend-shared/plannershared.cpp34
-rw-r--r--backend-shared/plannershared.h14
-rw-r--r--desktop-widgets/diveplanner.cpp9
-rw-r--r--desktop-widgets/diveplanner.h1
4 files changed, 48 insertions, 10 deletions
diff --git a/backend-shared/plannershared.cpp b/backend-shared/plannershared.cpp
index fe4e52443..d331f9d2b 100644
--- a/backend-shared/plannershared.cpp
+++ b/backend-shared/plannershared.cpp
@@ -222,3 +222,37 @@ void plannerShared::set_o2narcotic(bool value)
DivePlannerPointsModel::instance()->emitDataChanged();
CylindersModel::instance()->updateBestMixes();
}
+
+double plannerShared::bottompo2()
+{
+ return (qPrefDivePlanner::bottompo2() / 1000.0);
+}
+void plannerShared::set_bottompo2(double value)
+{
+ // NO conversion, this is done in the planner model.
+ qPrefDivePlanner::set_bottompo2((int) (value * 1000.0));
+ CylindersModel::instance()->updateBestMixes();
+}
+
+double plannerShared::decopo2()
+{
+ return qPrefDivePlanner::decopo2() / 1000;
+}
+void plannerShared::set_decopo2(double value)
+{
+ pressure_t olddecopo2;
+ olddecopo2.mbar = prefs.decopo2;
+ qPrefDivePlanner::instance()->set_decopo2((int) (value * 1000.0));
+ CylindersModel::instance()->updateDecoDepths(olddecopo2);
+ CylindersModel::instance()->updateBestMixes();
+}
+
+int plannerShared::bestmixend()
+{
+ return lrint(get_depth_units(prefs.bestmixend.mm, NULL, NULL));
+}
+void plannerShared::set_bestmixend(int value)
+{
+ qPrefDivePlanner::set_bestmixend(units_to_depth(value).mm);
+ CylindersModel::instance()->updateBestMixes();
+}
diff --git a/backend-shared/plannershared.h b/backend-shared/plannershared.h
index 7c446abc2..dcaf74049 100644
--- a/backend-shared/plannershared.h
+++ b/backend-shared/plannershared.h
@@ -44,6 +44,9 @@ class plannerShared: public QObject {
Q_PROPERTY(int problemsolvingtime READ problemsolvingtime WRITE set_problemsolvingtime NOTIFY problemsolvingtimeChanged);
Q_PROPERTY(double sacfactor READ sacfactor WRITE set_sacfactor NOTIFY sacfactorChanged);
Q_PROPERTY(bool o2narcotic READ o2narcotic WRITE set_o2narcotic NOTIFY o2narcoticChanged);
+ Q_PROPERTY(double bottompo2 READ bottompo2 WRITE set_bottompo2 NOTIFY bottompo2Changed);
+ Q_PROPERTY(double decopo2 READ decopo2 WRITE set_decopo2 NOTIFY decopo2Changed);
+ Q_PROPERTY(int bestmixend READ bestmixend WRITE set_bestmixend NOTIFY bestmixendChanged);
public:
static plannerShared *instance();
@@ -75,6 +78,9 @@ public:
static int problemsolvingtime();
static double sacfactor();
static bool o2narcotic();
+ static double bottompo2();
+ static double decopo2();
+ static int bestmixend();
public slots:
// Ascend/Descend data, converted to meter/feet depending on user selection
@@ -104,6 +110,9 @@ public slots:
static void set_problemsolvingtime(int value);
static void set_sacfactor(double value);
static void set_o2narcotic(bool value);
+ static void set_bottompo2(double value);
+ static void set_decopo2(double value);
+ static void set_bestmixend(int value);
signals:
// Ascend/Descend data, converted to meter/feet depending on user selection
@@ -115,12 +124,12 @@ signals:
// Planning data
void planner_deco_modeChanged(deco_mode value);
+ void dobailoutChanged(bool value);
void reserve_gasChanged(int value);
void safetystopChanged(bool value);
void gflowChanged(int value);
void gfhighChanged(int value);
void vpmb_conservatismChanged(int value);
- void dobailoutChanged(bool value);
void drop_stone_modeChanged(bool value);
void last_stopChanged(bool value);
void switch_at_req_stopChanged(bool value);
@@ -133,6 +142,9 @@ signals:
void problemsolvingtimeChanged(int value);
void sacfactorChanged(double value);
void o2narcoticChanged(bool value);
+ void bottompo2Changed(double value);
+ void decopo2Changed(double value);
+ void bestmixendChanged(int value);
private:
plannerShared() {}
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 8eea0bad8..b83fa0fa6 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -488,7 +488,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.vpmb_conservatism, SIGNAL(valueChanged(int)), plannerShared::instance(), SLOT(set_vpmb_conservatism(int)));
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
connect(ui.bailout, SIGNAL(toggled(bool)), plannerShared::instance(), SLOT(set_bailout(bool)));
- connect(ui.o2narcotic, SIGNAL(toggled(bool)), this, SLOT(setO2narcotic(bool)));
+ connect(ui.o2narcotic, SIGNAL(toggled(bool)), plannerShared::instance(), SLOT(set_o2narcotic(bool)));
connect(ui.switch_at_req_stop, SIGNAL(toggled(bool)), plannerShared::instance(), SLOT(set_switch_at_req_stop(bool)));
connect(ui.min_switch_duration, SIGNAL(valueChanged(int)), plannerShared::instance(), SLOT(set_min_switch_duration()(int)));
connect(ui.surface_segment, SIGNAL(valueChanged(int)), plannerModel, SLOT(setSurfaceSegment(int)));
@@ -497,7 +497,6 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.bottompo2, SIGNAL(valueChanged(double)), CylindersModel::instance(), SLOT(updateBestMixes()));
connect(ui.bestmixEND, SIGNAL(valueChanged(int)), CylindersModel::instance(), SLOT(updateBestMixes()));
- connect(ui.o2narcotic, SIGNAL(toggled(bool)), CylindersModel::instance(), SLOT(updateBestMixes()));
connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(disableDecoElements(int)));
connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerShared::instance(), SLOT(set_ascrate75(int)));
@@ -631,12 +630,6 @@ void PlannerSettingsWidget::setBackgasBreaks(bool dobreaks)
plannerShared::set_doo2breaks(dobreaks);
}
-void PlannerSettingsWidget::setO2narcotic(bool o2narcotic)
-{
- qPrefDivePlanner::instance()->set_o2narcotic(o2narcotic);
- plannerModel->emitDataChanged();
-}
-
void PlannerSettingsWidget::setBailoutVisibility(int mode)
{
ui.bailout->setDisabled(!(mode == CCR || mode == PSCR));
diff --git a/desktop-widgets/diveplanner.h b/desktop-widgets/diveplanner.h
index f8ad5dfba..9006e1692 100644
--- a/desktop-widgets/diveplanner.h
+++ b/desktop-widgets/diveplanner.h
@@ -76,7 +76,6 @@ slots:
void setDecoPo2(double po2);
void setBestmixEND(int depth);
void setBackgasBreaks(bool dobreaks);
- void setO2narcotic(bool o2narcotic);
void disableDecoElements(int mode);
void disableBackgasBreaks(bool enabled);
void setDiveMode(int mode);