summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-20 11:56:06 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-10-21 19:57:49 +0300
commit9829e49815de1b81b5c9848b71eaa810faab2bcf (patch)
treef95e3c46c00912a6aee699cb23803f74b173628a /qt-models/filtermodels.cpp
parent2f81890f496a21c852513a26b728e04e03c4f01e (diff)
downloadsubsurface-9829e49815de1b81b5c9848b71eaa810faab2bcf.tar.gz
Dive list: move dive-selection code from filter to list
After invalidating the filter, the dive-selection was modified to ensure that at least one dive is selected. This was done in the filter code, but it seems preferrable to do this in the dive-list code, which has direct access to the selection-model. Therefore, move the code from MultiFilterSortModel to DiveListView. While doing so, split the code in DiveListView into more functions to: 1) Get the index of the first dive (if any). 2) Select the first dive (if any). This allows a distinct size reduction of conditional compilation in MultiFilterSortModel (accesses to MainWindow are not possible in mobile code). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r--qt-models/filtermodels.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index fb513f250..58d0277bd 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -641,10 +641,8 @@ void MultiFilterSortModel::filterChanged(const QModelIndex &from, const QModelIn
void MultiFilterSortModel::myInvalidate()
{
-#if !defined(SUBSURFACE_MOBILE)
int i;
struct dive *d;
- DiveListView *dlv = MainWindow::instance()->diveList;
divesDisplayed = 0;
@@ -658,33 +656,11 @@ void MultiFilterSortModel::myInvalidate()
invalidateFilter();
- // 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)
- // TODO: This should go internally to DiveList, to be triggered after a filter is due.
- dlv->clearTripSelection();
-
- // if we have no more selected dives, clean up the display - this later triggers us
- // to pick one of the dives that are shown in the list as selected dive which is the
- // natural behavior
- if (amount_selected == 0) {
- MainWindow::instance()->cleanUpEmpty();
- } 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)
- curSelectedDives.append(get_divenr(d));
- }
- dlv->selectDives(curSelectedDives);
- }
-
emit filterFinished();
- if (curr_dive_site) {
- dlv->expandAll();
- }
+#if !defined(SUBSURFACE_MOBILE)
+ if (curr_dive_site)
+ MainWindow::instance()->diveList->expandAll();
#endif
}