From 16a35a8bbe2bd16398667795fe3f5c4a41beaf3e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 May 2020 11:51:20 +0200 Subject: desktop: update information tab when cylinders change The SAC rate, etc were only updated when switching between dives. They should always be updated when an undo command changes (adds, edits, removes) the cylinders of a dive. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/TabDiveInformation.cpp | 11 +++++++++++ desktop-widgets/tab-widgets/TabDiveInformation.h | 1 + 2 files changed, 12 insertions(+) (limited to 'desktop-widgets/tab-widgets') diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index a91151fed..e73de4148 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -21,6 +21,9 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne { ui->setupUi(this); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveInformation::divesChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &TabDiveInformation::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &TabDiveInformation::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &TabDiveInformation::cylinderChanged); QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("Use DC")}; ui->atmPressType->insertItems(0, atmPressTypes); pressTypeIndex = 0; @@ -292,6 +295,14 @@ void TabDiveInformation::on_waterTypeCombo_activated(int index) { ui->salinityOverWrittenIcon->setVisible(true); } +void TabDiveInformation::cylinderChanged(dive *d) +{ + // If this isn't the current dive, do nothing + if (current_dive != d) + return; + updateProfile(); +} + // This function gets called if a field gets updated by an undo command. // Refresh the corresponding UI field. void TabDiveInformation::divesChanged(const QVector &dives, DiveField field) diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index f7c9022c9..8efa71d44 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -18,6 +18,7 @@ public: void clear() override; private slots: void divesChanged(const QVector &dives, DiveField field); + void cylinderChanged(dive *d); void diveModeChanged(int index); void on_atmPressVal_editingFinished(); void on_atmPressType_currentIndexChanged(int index); -- cgit v1.2.3-70-g09d2