[PATCH 5/5] Planner: update cylinder mixes and MND and MOD when prefs are changed
Rick Walsh
rickmwalsh at gmail.com
Fri Jul 1 00:26:10 PDT 2016
Signed-off-by: Rick Walsh <rickmwalsh at gmail.com>
---
desktop-widgets/diveplanner.cpp | 3 +++
qt-models/cylindermodel.cpp | 7 ++++---
qt-models/cylindermodel.h | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 0455573..ba1ee54 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -21,6 +21,7 @@
#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
static DivePlannerPointsModel* plannerModel = DivePlannerPointsModel::instance();
+static CylindersModel* cylinderModel = CylindersModel::instance();
DiveHandler::DiveHandler() : QGraphicsEllipseItem()
{
@@ -351,8 +352,10 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescRate(int)));
connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
connect(ui.bottompo2, SIGNAL(valueChanged(double)), this, SLOT(setBottomPo2(double)));
+ connect(ui.bottompo2, SIGNAL(valueChanged(double)), cylinderModel, SLOT(updateBestMixes()));
connect(ui.decopo2, SIGNAL(valueChanged(double)), this, SLOT(setDecoPo2(double)));
connect(ui.bestmixEND, SIGNAL(valueChanged(int)), this, SLOT(setBestmixEND(int)));
+ connect(ui.bestmixEND, SIGNAL(valueChanged(int)), cylinderModel, SLOT(updateBestMixes()));
connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool)));
connect(ui.bottomSAC, SIGNAL(valueChanged(double)), this, SLOT(bottomSacChanged(double)));
connect(ui.decoStopSAC, SIGNAL(valueChanged(double)), this, SLOT(decoSacChanged(double)));
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index a7ab3e1..3672320 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -491,9 +491,10 @@ bool CylindersModel::updateBestMixes()
gasUpdated = true;
}
}
- if (gasUpdated) {
+ if (gasUpdated)
DivePlannerPointsModel::instance()->tanksUpdated();
- emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
- }
+ /* This slot is called when the bottom pO2 and END preferences are updated, we want to
+ * emit dataChanged so MOD and MND are refreshed, even if the gas mix hasn't been changed */
+ emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
return gasUpdated;
}
diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h
index d0ca714..dc1ec5f 100644
--- a/qt-models/cylindermodel.h
+++ b/qt-models/cylindermodel.h
@@ -37,13 +37,13 @@ public:
void clear();
void updateDive();
void copyFromDive(struct dive *d);
- bool updateBestMixes();
cylinder_t *cylinderAt(const QModelIndex &index);
bool changed;
public
slots:
void remove(const QModelIndex &index);
+ bool updateBestMixes();
private:
int rows;
--
2.7.4
More information about the subsurface
mailing list