From 243962a67a41c71f39a098e8f18dafdcd9adb37e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 10 Nov 2018 09:07:42 +0100 Subject: Dive list: move sort-functionality into core To make sorting more controlled, move all sorting functions into the core. For this, introduce a "dive_or_trip" structure, which represents a top-level item. Adapt the DiveTripModel accordingly. There are now three sorting functions: 1) dive_less_than 2) trip_less_than 3) dive_or_trip_less_than These should be used by all sorting code. By moving them to a single place, the mess can hopefully be cleaned up. Signed-off-by: Berthold Stoeger --- core/dive.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/dive.h') diff --git a/core/dive.h b/core/dive.h index 7356f91a1..76f01a8c0 100644 --- a/core/dive.h +++ b/core/dive.h @@ -338,6 +338,12 @@ struct dive { unsigned char git_id[20]; }; +/* For the top-level list: an entry is either a dive or a trip */ +struct dive_or_trip { + struct dive *dive; + struct dive_trip *trip; +}; + extern void invalidate_dive_cache(struct dive *dive); extern bool dive_cache_is_valid(const struct dive *dive); @@ -557,6 +563,7 @@ extern int legacy_format_o2pressures(const struct dive *dive, const struct divec extern bool dive_less_than(const struct dive *a, const struct dive *b); extern bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b); +extern bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b); extern void sort_table(struct dive_table *table); extern struct dive *fixup_dive(struct dive *dive); extern void fixup_dc_duration(struct divecomputer *dc); -- cgit v1.2.3-70-g09d2