summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-09-06 09:52:02 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commit7150d1c6f61631079e7620901fd1939bbc54e621 (patch)
treef87e4bebdad98cffb7e1db7e675a1fc278e77b02 /qt-models/filtermodels.h
parent11e0b7ac0a6db1a6f2d96ca4cb1f035f42181634 (diff)
downloadsubsurface-7150d1c6f61631079e7620901fd1939bbc54e621.tar.gz
Filter: Make filters aware of added / removed dives
Instead of reloading all the filter, only increment / decrement the count of the entries of added / removed dives. Originally, this was planned to be done via the signals from the divelist, but it turned out that this was suboptimal, because if the filter decides that the new item is selected, this has to be done *before* adding the dive. Otherwise, it wouldn't be shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.h')
-rw-r--r--qt-models/filtermodels.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 08e99fd93..3f5ca5f01 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -8,6 +8,7 @@
#include <vector>
struct dive;
+struct dive_trip;
class FilterModelBase : public QAbstractListModel {
Q_OBJECT
@@ -23,8 +24,12 @@ protected:
int indexOf(const QString &name) const;
void addItem(const QString &name, bool checked, int count);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ void decreaseCount(const QString &d);
+ void increaseCount(const QString &d);
public:
virtual bool doFilter(const dive *d) const = 0;
+ virtual void diveAdded(const dive *d) = 0;
+ virtual void diveDeleted(const dive *d) = 0;
void clearFilter();
void selectAll();
void invertSelection();
@@ -56,6 +61,8 @@ slots:
private:
explicit TagFilterModel(QObject *parent = 0);
int countDives(const char *) const;
+ void diveAdded(const dive *d);
+ void diveDeleted(const dive *d);
};
class BuddyFilterModel : public FilterModelBase {
@@ -70,6 +77,8 @@ slots:
private:
explicit BuddyFilterModel(QObject *parent = 0);
int countDives(const char *) const;
+ void diveAdded(const dive *d);
+ void diveDeleted(const dive *d);
};
class LocationFilterModel : public FilterModelBase {
@@ -85,6 +94,8 @@ slots:
private:
explicit LocationFilterModel(QObject *parent = 0);
int countDives(const char *) const;
+ void diveAdded(const dive *d);
+ void diveDeleted(const dive *d);
};
class SuitsFilterModel : public FilterModelBase {
@@ -99,6 +110,8 @@ slots:
private:
explicit SuitsFilterModel(QObject *parent = 0);
int countDives(const char *) const;
+ void diveAdded(const dive *d);
+ void diveDeleted(const dive *d);
};
class MultiFilterSortModel : public QSortFilterProxyModel {
@@ -108,6 +121,8 @@ public:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
void addFilterModel(FilterModelBase *model);
void removeFilterModel(FilterModelBase *model);
+ void divesAdded(const QVector<dive *> &dives);
+ void divesDeleted(const QVector<dive *> &dives);
bool showDive(const struct dive *d) const;
int divesDisplayed;
public