selection: introduce clear_selection() function

The DiveListView would touch the selection-innards directly.
Let's encapsulate that. Moreover, take care to reset the trip
selection when resetting the core data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-02 14:41:52 +02:00 committed by Dirk Hohndel
parent 09b7fcbcf4
commit f961ec7a8b
4 changed files with 16 additions and 12 deletions

View file

@ -253,3 +253,16 @@ extern "C" void deselect_trip(struct dive_trip *trip)
amount_trips_selected--;
}
}
extern "C" void clear_selection(void)
{
current_dive = nullptr;
amount_selected = 0;
amount_trips_selected = 0;
int i;
struct dive *dive;
for_each_dive (i, dive)
dive->selected = false;
for (int i = 0; i < trip_table.nr; ++i)
trip_table.trips[i]->selected = false;
}