aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-11-22 23:11:23 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-11-23 13:22:24 -0800
commit70897dd1b7d33f3d1f6b47acc587a7f33a176a04 (patch)
treed2304bd23c797d558b709dfa20d9a5afef2cd286 /qt-models/divetripmodel.cpp
parent68414531adeb68f7ad01c98bbac4d4d950409f02 (diff)
downloadsubsurface-70897dd1b7d33f3d1f6b47acc587a7f33a176a04.tar.gz
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>
Diffstat (limited to 'qt-models/divetripmodel.cpp')
-rw-r--r--qt-models/divetripmodel.cpp10
1 files changed, 2 insertions, 8 deletions
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<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))