mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: update statistics if dive changed
On undo/redo, the dive statistics tab was not updated even if a selected dive was changed. Fix that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c479c5ca36
commit
5c4d163a41
2 changed files with 28 additions and 0 deletions
|
@ -21,6 +21,8 @@ TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new
|
|||
ui->timeLimits->overrideMinToolTipText(tr("Shortest dive"));
|
||||
ui->timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives"));
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveStatistics::divesChanged);
|
||||
|
||||
const auto l = findChildren<QLabel *>(QString(), Qt::FindDirectChildrenOnly);
|
||||
for (QLabel *label: l) {
|
||||
label->setAlignment(Qt::AlignHCenter);
|
||||
|
@ -42,6 +44,28 @@ void TabDiveStatistics::clear()
|
|||
ui->timeLimits->clear();
|
||||
}
|
||||
|
||||
// This function gets called if a field gets updated by an undo command.
|
||||
// Refresh the corresponding UI field.
|
||||
void TabDiveStatistics::divesChanged(const QVector<dive *> &dives, DiveField field)
|
||||
{
|
||||
// If none of the changed dives is selected, do nothing
|
||||
if (std::none_of(dives.begin(), dives.end(), [] (const dive *d) { return d->selected; }))
|
||||
return;
|
||||
|
||||
// TODO: make this more fine grained. Currently, the core can only calculate *all* statistics.
|
||||
switch(field) {
|
||||
case DiveField::DURATION:
|
||||
case DiveField::DEPTH:
|
||||
case DiveField::MODE:
|
||||
case DiveField::AIR_TEMP:
|
||||
case DiveField::WATER_TEMP:
|
||||
updateData();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TabDiveStatistics::updateData()
|
||||
{
|
||||
stats_t stats_selection;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue