core: turn trip-table into our own sorted_owning_table

Since the sorted_owning_table depends on the fact that
different elements never compare as equal, make the
comparison function safer in that respect. If all failes,
compare the pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-01 22:05:57 +02:00 committed by bstoeger
parent 1cebafb08f
commit eacad89531
21 changed files with 217 additions and 305 deletions

View file

@ -74,8 +74,8 @@ struct TripWrapper {
QString name;
timestamp_t date;
TripWrapper(const dive_trip *t) : t(t),
name(formatTripTitle(t)), // safe to pass null
date(trip_date(t)) // safe to pass null
name(t ? formatTripTitle(*t) : QString()),
date(t ? trip_date(*t) : 0)
{
}
bool operator<(const TripWrapper &t2) const {
@ -1868,7 +1868,7 @@ struct TripVariable : public StatsVariableTemplate<StatsVariable::Type::Discrete
return StatsTranslations::tr("Dive trip");
}
QString diveCategories(const dive *d) const override {
return formatTripTitle(d->divetrip);
return d->divetrip ? formatTripTitle(*d->divetrip) : QString();
}
std::vector<const StatsBinner *> binners() const override {
return { &trip_binner };