summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-02 18:44:05 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 15:57:39 -0800
commit975c123a30de95eafd9b3c2ce2a625a1d05a79dc (patch)
tree55134e97aefe351ab76c08b427e9b6fd7eb5b20e /profile-widget
parent233e686b92e172d4d29357b5e02d440144595130 (diff)
downloadsubsurface-975c123a30de95eafd9b3c2ce2a625a1d05a79dc.tar.gz
profile: remove redundant code in DiveCalculatedCeiling
The DiveCalculatedCeiling profile-item has a recalc() function, which calls "dataModel->calculateDecompression()". This is a questionable reversal of control-flow: The profile-item should paint the model-data not change it. The code was supposed to be called under two conditions: 1) The value of the calcceiling3m preferences flag changed. This code was buggy for two reasons: Firstly, the cached value was always initialized to false, which means that sometimes the first call was missed. Secondly, the settingsChanged() functions was only called when closing the preferences window, not when changing the flag in the profile widgets. 2) The datetime of the dive changed. The whole control-flow is pretty absurd (due to "bit rot"): - The replan-dive command sends a date-time changed signal. - The main tab changes the date-time and informs the profile. - The profile sends a signal to the item. - The item instructs the model to recalculate the decompression. - The model causes the profile to be redrawn. In any case, the whole thing is moot, because the decompression is recalculated for *every* profile plot in create_plot_info_new(). Let's remove the code from the DiveCalculatedCeiling profile-item and the calculateDecompression() function, which is now not used anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp21
-rw-r--r--profile-widget/diveprofileitem.h6
2 files changed, 1 insertions, 26 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index c6df6ee50..138dbbc49 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -820,8 +820,7 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
}
DiveCalculatedCeiling::DiveCalculatedCeiling(ProfileWidget2 *widget) :
- profileWidget(widget),
- is3mIncrement(false)
+ profileWidget(widget)
{
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::calcceilingChanged, this, &DiveCalculatedCeiling::setVisible);
setVisible(prefs.calcceiling);
@@ -830,8 +829,6 @@ DiveCalculatedCeiling::DiveCalculatedCeiling(ProfileWidget2 *widget) :
void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- connect(profileWidget, SIGNAL(dateTimeChangedItems()), this, SLOT(recalc()), Qt::UniqueConnection);
-
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
return;
@@ -914,22 +911,6 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo
setBrush(pat);
}
-void DiveCalculatedCeiling::recalc()
-{
-#ifndef SUBSURFACE_MOBILE
- dataModel->calculateDecompression();
-#endif
-}
-
-void DiveCalculatedCeiling::settingsChanged()
-{
- if (dataModel && is3mIncrement != prefs.calcceiling3m) {
- // recalculate that part.
- recalc();
- }
- is3mIncrement = prefs.calcceiling3m;
-}
-
void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (polygon().isEmpty())
diff --git a/profile-widget/diveprofileitem.h b/profile-widget/diveprofileitem.h
index df46b6e12..58e16190b 100644
--- a/profile-widget/diveprofileitem.h
+++ b/profile-widget/diveprofileitem.h
@@ -177,15 +177,9 @@ public:
DiveCalculatedCeiling(ProfileWidget2 *profileWidget);
void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
- void settingsChanged() override;
-
-public
-slots:
- void recalc();
private:
ProfileWidget2 *profileWidget;
- bool is3mIncrement;
};
class DiveReportedCeiling : public AbstractProfilePolygonItem {