selection: remove current_dive and dc_number access from tabwidgets

An attempt at limitting accesses to the globals current_dive and
dc_number. These globals do not make sense on mobile.

The parent widget of the tab-widgets remembers the currently
displayer dive and dive computer and the individual widgets
access these values from there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-09-17 16:21:17 +02:00 committed by bstoeger
parent 8cd191c271
commit 6f03fc9689
8 changed files with 125 additions and 96 deletions

View file

@ -114,12 +114,11 @@ TabDiveEquipment::~TabDiveEquipment()
// Refresh the corresponding UI field.
void TabDiveEquipment::divesChanged(const QVector<dive *> &dives, DiveField field)
{
// If the current dive is not in list of changed dives, do nothing
if (!current_dive || !dives.contains(current_dive))
if (!parent.includesCurrentDive(dives))
return;
if (field.suit)
ui.suit->setText(QString(current_dive->suit));
ui.suit->setText(QString(parent.currentDive->suit));
}
void TabDiveEquipment::toggleTriggeredColumn()
@ -209,7 +208,7 @@ void TabDiveEquipment::divesEdited(int i)
void TabDiveEquipment::on_suit_editingFinished()
{
if (!current_dive)
if (!parent.currentDive)
return;
divesEdited(Command::editSuit(ui.suit->text(), false));
}