mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
selection: create global single_selected_trip() function
The DiveListView had a singleSelectedTrip function that returns the selected trip if exactly one trip is selected. This could be very slow if numerous non-trip items were selected, because all the selection indices were back- translated by the proxy model. This could make selection changes very slow, because the MainTab used said function to determine whether it should show trip or dive data.. Indeed, with a 3500 dive test log, when selecting all dives in tree mode, the updating of the TabWidgets is sped up from 130 ms to 5 ms this commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5147131701
commit
769915f3fe
5 changed files with 17 additions and 23 deletions
|
|
@ -254,6 +254,18 @@ extern "C" void deselect_trip(struct dive_trip *trip)
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" struct dive_trip *single_selected_trip()
|
||||
{
|
||||
if (amount_trips_selected != 1)
|
||||
return NULL;
|
||||
for (int i = 0; i < trip_table.nr; ++i) {
|
||||
if (trip_table.trips[i]->selected)
|
||||
return trip_table.trips[i];
|
||||
}
|
||||
fprintf(stderr, "warning: found no selected trip even though one should be selected\n");
|
||||
return NULL; // shouldn't happen
|
||||
}
|
||||
|
||||
extern "C" void clear_selection(void)
|
||||
{
|
||||
current_dive = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue