Filter: split out filter from model

Split out the actual filtering from the MultiFilterSortModel.
Create a DiveFilter class that does the actual filtering.
Currently, mobile and desktop have their own version of this
class, though ultimately we may want to merge them.

The idea here is that the trip-model and undo-commands have
direct access to the filter-function and thus can take care
of keeping track of the number of shown dives, etc.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-17 18:13:55 +01:00 committed by Dirk Hohndel
parent 6d6d10f03a
commit b76f207158
16 changed files with 369 additions and 308 deletions

View file

@ -10,6 +10,7 @@
#include "desktop-widgets/mainwindow.h"
#include "desktop-widgets/divepicturewidget.h"
#include "core/display.h"
#include "core/divefilter.h"
#include <unistd.h>
#include <QSettings>
#include <QKeyEvent>
@ -463,7 +464,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
// But don't do this if we are in divesite mode, because then
// the dive-site selection is controlled by the filter not
// by the selected dives.
if (!MultiFilterSortModel::instance()->diveSiteMode()) {
if (!DiveFilter::instance()->diveSiteMode()) {
QVector<dive_site *> selectedSites;
for (int idx: newDiveSelection) {
dive *d = get_dive(idx);
@ -698,7 +699,7 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
// But don't do this if we are in divesite mode, because then
// the dive-site selection is controlled by the filter not
// by the selected dives.
if (!MultiFilterSortModel::instance()->diveSiteMode()) {
if (!DiveFilter::instance()->diveSiteMode()) {
QVector<dive_site *> selectedSites;
for (QModelIndex index: selectionModel()->selection().indexes()) {
const QAbstractItemModel *model = index.model();