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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-05 11:55:23 +02:00 committed by Dirk Hohndel
parent 16a35a8bbe
commit 9298466037
3 changed files with 13 additions and 0 deletions

View file

@ -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<QLabel *>(QString(), Qt::FindDirectChildrenOnly);
for (QLabel *label: l) {
@ -57,6 +60,14 @@ void TabDiveStatistics::divesChanged(const QVector<dive *> &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;