From 0b0e6672d5622238c2fb583dad6b51813b9338b3 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 27 Jan 2021 23:41:51 +0100 Subject: profile: detect dive-mode change in profile The profile must be replotted when the dive mode changes. Weirdly, this was routed via the dive-information tab (making it inherently non-mobile compatible). Detect such a change directly in the profile. Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 12 +++++++++++- profile-widget/profilewidget2.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 128793fd9..5d37496e3 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -32,7 +32,6 @@ #include "core/gettextfromc.h" #include "core/imagedownloader.h" #endif -#include "core/subsurface-qt/divelistnotifier.h" #include #include @@ -174,6 +173,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &ProfileWidget2::profileChanged); connect(&diveListNotifier, &DiveListNotifier::eventsChanged, this, &ProfileWidget2::profileChanged); connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &ProfileWidget2::pictureOffsetChanged); + connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &ProfileWidget2::divesChanged); #endif // SUBSURFACE_MOBILE #if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE) @@ -814,6 +814,16 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict } } +void ProfileWidget2::divesChanged(const QVector &dives, DiveField field) +{ + // If the mode of the currently displayed dive changed, replot + if (field.mode && + std::any_of(dives.begin(), dives.end(), + [id = displayed_dive.id] (const dive *d) + { return d->id == id; } )) + replot(); +} + void ProfileWidget2::actionRequestedReplot(bool) { settingsChanged(); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index be40694a7..b2632d511 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -22,6 +22,7 @@ #include "core/color.h" #include "core/pictureobj.h" #include "core/units.h" +#include "core/subsurface-qt/divelistnotifier.h" class RulerItem2; struct dive; @@ -102,6 +103,7 @@ public slots: // Necessary to call from QAction's signals. void settingsChanged(); void actionRequestedReplot(bool triggered); + void divesChanged(const QVector &dives, DiveField field); void setEmptyState(); void setProfileState(); #ifndef SUBSURFACE_MOBILE -- cgit v1.2.3-70-g09d2