summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-17 18:13:55 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-19 21:13:40 -0800
commitb76f2071589d6a7f45ec2845afa8b49110da608b (patch)
tree1b7176f4bf706803160c9dc007a7c524dbc59bd2 /qt-models/filtermodels.h
parent6d6d10f03a92a9bac5394fc226c398af61f29d66 (diff)
downloadsubsurface-b76f2071589d6a7f45ec2845afa8b49110da608b.tar.gz
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>
Diffstat (limited to 'qt-models/filtermodels.h')
-rw-r--r--qt-models/filtermodels.h65
1 files changed, 2 insertions, 63 deletions
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index d4a03d134..d279470b1 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -11,67 +11,16 @@
#include <stdint.h>
#include <vector>
-struct dive;
-struct dive_trip;
-
-struct FilterData {
- // The mode ids are chosen such that they can be directly converted from / to combobox indices.
- enum class Mode {
- ALL_OF = 0,
- ANY_OF = 1,
- NONE_OF = 2
- };
-
- bool validFilter = false;
- int minVisibility = 0;
- int maxVisibility = 5;
- int minRating = 0;
- int maxRating = 5;
- // The default minimum and maximum temperatures are set such that all
- // physically reasonable dives are shown. Note that these values should
- // work for both Celcius and Fahrenheit scales.
- double minWaterTemp = -10;
- double maxWaterTemp = 200;
- double minAirTemp = -50;
- double maxAirTemp = 200;
- QDateTime fromDate = QDateTime(QDate(1980,1,1));
- QTime fromTime = QTime(0,0);
- QDateTime toDate = QDateTime::currentDateTime();
- QTime toTime = QTime::currentTime();
- QStringList tags;
- QStringList people;
- QStringList location;
- QStringList suit;
- QStringList dnotes;
- QStringList equipment;
- Mode tagsMode = Mode::ALL_OF;
- Mode peopleMode = Mode::ALL_OF;
- Mode locationMode = Mode::ANY_OF;
- Mode dnotesMode = Mode::ALL_OF;
- Mode suitMode = Mode::ANY_OF;
- Mode equipmentMode = Mode::ALL_OF;
- bool logged = true;
- bool planned = true;
-};
-
class MultiFilterSortModel : public QSortFilterProxyModel {
Q_OBJECT
public:
static MultiFilterSortModel *instance();
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
- bool showDive(const struct dive *d) const;
bool updateDive(struct dive *d); // returns true if visibility status changed
bool lessThan(const QModelIndex &, const QModelIndex &) const override;
- bool diveSiteMode() const; // returns true if we're filtering on dive site
- const QVector<dive_site *> &filteredDiveSites() const;
-public
-slots:
- void myInvalidate();
- void startFilterDiveSites(QVector<dive_site *> ds);
- void setFilterDiveSite(QVector<dive_site *> ds);
- void stopFilterDiveSites();
+
void resetModel(DiveTripModelBase::Layout layout);
- void filterDataChanged(const FilterData &data);
+ void myInvalidate();
signals:
void filterFinished();
@@ -79,17 +28,7 @@ signals:
private:
MultiFilterSortModel(QObject *parent = 0);
// Dive site filtering has priority over other filters
- QVector<dive_site *> dive_sites;
void countsChanged();
- FilterData filterData;
-
- // We use ref-counting for the dive site mode. The reason is that when switching
- // between two tabs that both need dive site mode, the following course of
- // events may happen:
- // 1) The new tab appears -> enter dive site mode.
- // 2) The old tab gets its hide() signal -> exit dive site mode.
- // The filter is now not in dive site mode, even if it should
- int diveSiteRefCount;
};
#endif