selection: pass down selection to tab widgets

On selection change, pass down selection (including current
dive and dc) to the tab widgets. Ultimately, this should
remove access to global variables. A number of new accesses
are marked as TODO. They shall be removed in due course.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-09-04 11:04:01 +02:00 committed by bstoeger
parent 908da77863
commit cded7ef5fe
16 changed files with 62 additions and 55 deletions

View file

@ -191,7 +191,7 @@ void TabDiveNotes::updateDiveSite(struct dive *d)
ui.locationTags->show();
}
void TabDiveNotes::updateData()
void TabDiveNotes::updateData(const std::vector<dive *> &, dive *currentDive, int currentDC)
{
ui.location->refreshDiveSiteCache();
@ -246,25 +246,25 @@ void TabDiveNotes::updateData()
ui.timeLabel->setVisible(true);
ui.timeEdit->setVisible(true);
/* and fill them from the dive */
ui.rating->setCurrentStars(current_dive->rating);
ui.rating->setCurrentStars(currentDive->rating);
// reset labels in case we last displayed trip notes
ui.LocationLabel->setText(tr("Location"));
ui.NotesLabel->setText(tr("Notes"));
ui.tagWidget->setText(get_taglist_string(current_dive->tag_list));
bool isManual = is_manually_added_dc(&current_dive->dc);
ui.tagWidget->setText(get_taglist_string(currentDive->tag_list));
bool isManual = is_manually_added_dc(&currentDive->dc);
ui.depth->setVisible(isManual);
ui.depthLabel->setVisible(isManual);
ui.duration->setVisible(isManual);
ui.durationLabel->setVisible(isManual);
updateNotes(current_dive);
updateDiveSite(current_dive);
updateDateTime(current_dive);
ui.diveguide->setText(current_dive->diveguide);
ui.buddy->setText(current_dive->buddy);
updateNotes(currentDive);
updateDiveSite(currentDive);
updateDateTime(currentDive);
ui.diveguide->setText(currentDive->diveguide);
ui.buddy->setText(currentDive->buddy);
}
ui.duration->setText(render_seconds_to_string(current_dive->duration.seconds));
ui.depth->setText(get_depth_string(current_dive->maxdepth, true));
ui.duration->setText(render_seconds_to_string(currentDive->duration.seconds));
ui.depth->setText(get_depth_string(currentDive->maxdepth, true));
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
/* unset the special value text for date and time, just in case someone dove at midnight */