summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-11 22:59:04 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-12 14:07:07 -0800
commit0b318540318ffa62318f0d9b74c2b14306bd0d97 (patch)
treede4469dfe207955093c2e057b82012c956cc28f1 /qt-ui
parent71b6de05238907dfa602cd583c5904dd7e6cb8fc (diff)
downloadsubsurface-0b318540318ffa62318f0d9b74c2b14306bd0d97.tar.gz
Deselect dives that are no longer shown as the dive list is filtered
This cleans up the way we ensure that all dives are handled as the dive list is filtered. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp5
-rw-r--r--qt-ui/models.cpp14
2 files changed, 11 insertions, 8 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 0d7c4fa6d..f250e901a 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -314,6 +314,8 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
void DiveListView::selectDives(const QList<int> &newDiveSelection)
{
int firstInList, newSelection;
+ struct dive *d;
+
if (!newDiveSelection.count())
return;
@@ -335,7 +337,8 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
newSelection = dive_table.nr - 1;
if (newSelection == firstInList)
break;
- selectDive(newSelection);
+ if ((d = get_dive(newSelection)) != NULL && !d->hidden_by_filter)
+ selectDive(newSelection);
}
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
QModelIndexList idxList = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive);
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 5ad1c79c7..c7886d2b9 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -2366,7 +2366,9 @@ bool TagFilterModel::filterRow(int source_row, const QModelIndex &source_parent,
QVariant diveVariant = sourceModel->data(index0, DiveTripModel::DIVE_ROLE);
struct dive *d = (struct dive *)diveVariant.value<void *>();
- return doFilter(d, index0, sourceModel);
+ bool show = doFilter(d, index0, sourceModel);
+ filter_dive(d, show);
+ return show;
}
BuddyFilterModel::BuddyFilterModel(QObject *parent) : QStringListModel(parent)
@@ -2628,11 +2630,7 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
shouldShow = false;
}
// if it's a dive, mark it accordingly
- if (d) {
- if (d->selected)
- d->selected = shouldShow;
- d->hidden_by_filter = !shouldShow;
- }
+ filter_dive(d, shouldShow);
return shouldShow;
}
@@ -2656,10 +2654,12 @@ void MultiFilterSortModel::myInvalidate()
} else {
// otherwise find the dives that should still be selected (the filter above unselected any
// dive that's no longer visible) and select them again
+ QList<int>curSelectedDives;
for_each_dive (i, d) {
if(d->selected)
- dlv->selectDive(get_idx_by_uniq_id(d->id));
+ curSelectedDives.append(get_divenr(d));
}
+ dlv->selectDives(curSelectedDives);
}
}