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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-11-22 23:11:23 +01:00 committed by Dirk Hohndel
parent 68414531ad
commit 70897dd1b7
5 changed files with 40 additions and 25 deletions

View file

@ -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<dive_trip *>(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))