selection: avoid select_dive() and deselect_dive calls in dive list

Each of these calls recalculates the current dive and divecomputer.
Instead, collect the dives to be selected/deselected and (de)select
them at once.

This needs some code refactoring in the core, because we need a
function that
1) doesn't send a signal by itself.
2) doesn't clear the trip-selection.

This contains some reorganization of the selection functions
signatures: The filter code is the only caller that keeps the
selected dive and the only caller that cares about whether the
current dive changed. So let only the function that keeps the
selected dive return whether the current dive changed.

It's all very fragile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-05-21 20:38:17 +02:00 committed by bstoeger
parent 6df1c62dfc
commit 487974ea91
6 changed files with 76 additions and 57 deletions

View file

@ -49,9 +49,6 @@ extern dive_trip_t *get_trip_for_new_dive(struct dive *new_dive, bool *allocated
extern dive_trip_t *get_trip_by_uniq_id(int tripId);
extern bool trips_overlap(const struct dive_trip *t1, const struct dive_trip *t2);
extern void select_dives_in_trip(struct dive_trip *trip);
extern void deselect_dives_in_trip(struct dive_trip *trip);
extern dive_trip_t *combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b);
extern bool is_trip_before_after(const struct dive *dive, bool before);
extern bool trip_is_single_day(const struct dive_trip *trip);