aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-17 19:53:18 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-19 21:13:40 -0800
commit3003c6e1eed330978193d6859eca2f79ee68aa54 (patch)
tree1baeb54aeca0eda10d273779cf3704095a170d2e /qt-models/divetripmodel.h
parent9ffafbc326b38bd2d0bb870fa4721b6c94280c28 (diff)
downloadsubsurface-3003c6e1eed330978193d6859eca2f79ee68aa54.tar.gz
Filter: move recalculation of filter from FilterModel to TripModel
The way this was accessed via Qt's model semantics was horrible. This gives arguably more readable code, since we don't have to shoehorn things through QVariants. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r--qt-models/divetripmodel.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index 6b3f26fd7..94278229d 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -78,8 +78,7 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
DiveTripModelBase(QObject *parent = 0);
int columnCount(const QModelIndex&) const;
- virtual void filterFinished() = 0;
- virtual bool setShown(const QModelIndex &idx, bool shown) = 0;
+ virtual void recalculateFilter() = 0;
// Used for sorting. This is a bit of a layering violation, as sorting should be performed
// by the higher-up QSortFilterProxyModel, but it makes things so much easier!
@@ -123,11 +122,10 @@ private:
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
- void filterFinished() override;
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
void divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &);
dive *diveOrNull(const QModelIndex &index) const override;
- bool setShown(const QModelIndex &idx, bool shown);
+ void recalculateFilter();
void divesChangedTrip(dive_trip *trip, const QVector<dive *> &dives);
void divesTimeChangedTrip(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives);
@@ -189,10 +187,9 @@ private:
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
- void filterFinished() override;
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
dive *diveOrNull(const QModelIndex &index) const override;
- bool setShown(const QModelIndex &idx, bool shown);
+ void recalculateFilter();
std::vector<dive *> items; // TODO: access core data directly
};