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

@ -69,7 +69,7 @@ QString DiveTripModelBase::tripShortDate(const dive_trip *trip)
{
if (!trip)
return QString();
QDateTime firstTime = timestampToDateTime(trip_date(trip));
QDateTime firstTime = timestampToDateTime(trip_date(*trip));
QString firstMonth = firstTime.toString("MMM");
return QStringLiteral("%1\n'%2").arg(firstMonth,firstTime.toString("yy"));
}
@ -85,7 +85,7 @@ QString DiveTripModelBase::tripTitle(const dive_trip *trip)
if (title.isEmpty()) {
// so use the date range
QDateTime firstTime = timestampToDateTime(trip_date(trip));
QDateTime firstTime = timestampToDateTime(trip_date(*trip));
QString firstMonth = firstTime.toString("MMM");
QString firstYear = firstTime.toString("yyyy");
QDateTime lastTime = timestampToDateTime(trip->dives.dives[0]->when);
@ -128,7 +128,7 @@ QVariant DiveTripModelBase::tripData(const dive_trip *trip, int column, int role
int countShown = trip_shown_dives(trip);
if (countShown < trip->dives.nr)
shownText = tr("(%1 shown)").arg(countShown);
return formatTripTitleWithDives(trip) + " " + shownText;
return formatTripTitleWithDives(*trip) + " " + shownText;
}
}
@ -817,7 +817,7 @@ dive *DiveTripModelTree::Item::getDive() const
timestamp_t DiveTripModelTree::Item::when() const
{
return d_or_t.trip ? trip_date(d_or_t.trip) : d_or_t.dive->when;
return d_or_t.trip ? trip_date(*d_or_t.trip) : d_or_t.dive->when;
}
dive_or_trip DiveTripModelTree::tripOrDive(const QModelIndex &index) const