From 71307bce42af3070c9f2ff32f52e289cb6c3a64d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 9 Dec 2019 09:46:08 +0100 Subject: Dive list: don't handle selection changes on filter-change in view The selection changes upon completing the filter are handled by the core. Don't do this explicitly in the DiveListView. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'desktop-widgets/divelistview.cpp') diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index ee0c1c98f..76fa8fbd8 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -49,9 +49,6 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), resetModel(); - // Update selection if all selected dives were hidden by filter - connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveListView::filterFinished); - connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveListView::tripChanged); header()->setStretchLastSection(true); @@ -273,26 +270,6 @@ void DiveListView::selectTrip(dive_trip_t *trip) expand(idx); } -// this is an odd one - when filtering the dive list the selection status of the trips -// is kept - but all other selections are lost. That's gets us into rather inconsistent state -// we call this function which clears the selection state of the trips as well, but does so -// without updating our internal "->selected" state. So once we called this function we can -// go back and select those dives that are still visible under the filter and everything -// works as expected -void DiveListView::clearTripSelection() -{ - // This marks the selection change as being internal - ie. we don't process it further. - // TODO: This should probably be done differently. - auto marker = diveListNotifier.enterCommand(); - - // we want to make sure no trips are selected - Q_FOREACH (const QModelIndex &index, selectionModel()->selectedRows()) { - if (!index.data(DiveTripModelBase::IS_TRIP_ROLE).toBool()) - continue; - selectionModel()->select(index, QItemSelectionModel::Deselect); - } -} - void DiveListView::unselectDives() { // make sure we don't try to redraw the dives during the selection change @@ -1019,19 +996,6 @@ void DiveListView::loadImageFromURL(QUrl url) } } -void DiveListView::filterFinished() -{ - // first make sure the trips are no longer shown as selected - // (but without updating the selection state of the dives... this just cleans - // up an oddity in the filter handling) - clearTripSelection(); - - // If there are no more selected dives, select the first visible dive - if (!selectionModel()->hasSelection()) - select_newest_visible_dive(); - emit divesSelected(); -} - QString DiveListView::lastUsedImageDir() { QSettings settings; -- cgit v1.2.3-70-g09d2