From 70897dd1b7d33f3d1f6b47acc587a7f33a176a04 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 22 Nov 2018 23:11:23 +0100 Subject: Core: move is-single-day-trip and count-shown functions into core These functionality was used by the desktop filter. To unify desktop and mobile, move it into two new functions in divelist.c Since one of them is the only caller of is_same_day() move that likewise into divelist.c and make it of static linkage. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'qt-models/divetripmodel.cpp') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 51284c41d..ae7641ba2 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -48,7 +48,6 @@ static QVariant dive_table_alignment(int column) QVariant DiveTripModel::tripData(const dive_trip *trip, int column, int role) { - bool oneDayTrip=true; if (role == TRIP_ROLE) return QVariant::fromValue(const_cast(trip)); // Not nice: casting away a const @@ -57,13 +56,8 @@ QVariant DiveTripModel::tripData(const dive_trip *trip, int column, int role) switch (column) { case DiveTripModel::NR: QString shownText; - int countShown = 0; - for (int i = 0; i < trip->dives.nr; ++i) { - struct dive *d = trip->dives.dives[i]; - if (!d->hidden_by_filter) - countShown++; - oneDayTrip &= is_same_day(trip_date(trip), d->when); - } + bool oneDayTrip = trip_is_single_day(trip); + int countShown = trip_shown_dives(trip); if (countShown < trip->dives.nr) shownText = tr("(%1 shown)").arg(countShown); if (!empty_string(trip->location)) -- cgit v1.2.3-70-g09d2