summaryrefslogtreecommitdiffstats
path: root/profile-widget/divecartesianaxis.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-29 22:49:40 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 15:57:39 -0800
commitdd0939b6f5c9c7399183f2a36b2be77521886ef0 (patch)
treed8e6fec81774da585c55432be19f414e6ad20f41 /profile-widget/divecartesianaxis.cpp
parentf4103e4998d0a2512b6b8db931a81911b3e908a0 (diff)
downloadsubsurface-dd0939b6f5c9c7399183f2a36b2be77521886ef0.tar.gz
profile: explicitly update gas-axis
On each profile replot, the gas axis was implicitly reset by calling "dataModel->emitDataChanged()", which would send a signal recieved by the axis. To make the code less confusing and, more importantly, make order of execution deterministic, explicitly reset the axis. Rename the function that resets the axis from "settingsChanged" to "update" to reflect its usage. Moreover, remove the "setModel()" function and pass the model to the constructore. Make it a const reference to make clear that it can't change during the life time of the axis. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/divecartesianaxis.cpp')
-rw-r--r--profile-widget/divecartesianaxis.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp
index 8ee74e7f1..33b09b615 100644
--- a/profile-widget/divecartesianaxis.cpp
+++ b/profile-widget/divecartesianaxis.cpp
@@ -413,34 +413,27 @@ QString TemperatureAxis::textForValue(double value) const
return QString::number(mkelvin_to_C((int)value));
}
-PartialGasPressureAxis::PartialGasPressureAxis(ProfileWidget2 *widget) :
+PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, ProfileWidget2 *widget) :
DiveCartesianAxis(widget),
- model(NULL)
+ model(model)
{
- connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::settingsChanged);
+ connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::update);
}
-void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
-{
- model = m;
- connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(settingsChanged()));
- settingsChanged();
-}
-
-void PartialGasPressureAxis::settingsChanged()
+void PartialGasPressureAxis::update()
{
bool showPhe = prefs.pp_graphs.phe;
bool showPn2 = prefs.pp_graphs.pn2;
bool showPo2 = prefs.pp_graphs.po2;
setVisible(showPhe || showPn2 || showPo2);
- if (!model->rowCount())
+ if (!model.rowCount())
return;
- double max = showPhe ? model->pheMax() : -1;
- if (showPn2 && model->pn2Max() > max)
- max = model->pn2Max();
- if (showPo2 && model->po2Max() > max)
- max = model->po2Max();
+ double max = showPhe ? model.pheMax() : -1;
+ if (showPn2 && model.pn2Max() > max)
+ max = model.pn2Max();
+ if (showPo2 && model.po2Max() > max)
+ max = model.po2Max();
qreal pp = floor(max * 10.0) / 10.0 + 0.2;
if (IS_FP_SAME(maximum(), pp))