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; diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index be61619e5..86be642b8 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -30,7 +30,6 @@ public: void reload(); // Call to reload model data bool eventFilter(QObject *, QEvent *); void unselectDives(); - void clearTripSelection(); void selectDive(QModelIndex index, bool scrollto = false); void selectDive(int dive_table_idx, bool scrollto = false); void selectDives(const QList &newDiveSelection); @@ -63,7 +62,6 @@ slots: void loadWebImages(); void diveSelectionChanged(const QVector &indexes); void currentDiveChanged(QModelIndex index); - void filterFinished(); void tripChanged(dive_trip *trip, TripField); private: void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override;