From bef8dc6f4b462472dbcced0ea59cac5727bb45be Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 17 Sep 2014 17:31:09 -0300 Subject: [PATCH] Implement trip-filtering. Trips will be filtered if it doesn't find any tags for dives. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index f1f1f636c..e170c4d04 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2162,8 +2162,14 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); struct dive* d = (struct dive* ) diveVariant.value(); - if(!d) + + if (!d) { // It's a trip, only show the ones that have dives to be shown. + for(int i = 0; i < sourceModel()->rowCount(index0); i++){ + if (filterAcceptsRow(i, index0)) + return true; + } return false; + } // Checked means 'Show', Unchecked means 'Hide'. struct tag_entry *head = d->tag_list;