From 9298466037dd7ac80e65407eac93bfe62705f1ac Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 May 2020 11:55:23 +0200 Subject: desktop: update statistics tab when cylinders changed The cylinder-based statistics where not updated when an undo command edited cylinder data. Do so. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/TabDiveStatistics.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'desktop-widgets/tab-widgets/TabDiveStatistics.cpp') diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp index ffc2ad79e..83df3ab2c 100644 --- a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp +++ b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp @@ -22,6 +22,9 @@ TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new ui->timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives")); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveStatistics::divesChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &TabDiveStatistics::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &TabDiveStatistics::cylinderChanged); + connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &TabDiveStatistics::cylinderChanged); const auto l = findChildren(QString(), Qt::FindDirectChildrenOnly); for (QLabel *label: l) { @@ -57,6 +60,14 @@ void TabDiveStatistics::divesChanged(const QVector &dives, DiveField fie updateData(); } +void TabDiveStatistics::cylinderChanged(dive *d) +{ + // If the changed dive is not selected, do nothing + if (!d->selected) + return; + updateData(); +} + void TabDiveStatistics::updateData() { stats_t stats_selection; -- cgit v1.2.3-70-g09d2