summaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-09 22:47:47 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-02-22 15:18:31 -0800
commit7633d5feecf3cf2129f41b10ea293beb4c483d02 (patch)
tree9bd0b86187fa7bcaaf8f1863bbeeeae6900a5989 /qt-models/divetripmodel.h
parente761d00ddd68560e0f2b9d2f8650594978fa1168 (diff)
downloadsubsurface-7633d5feecf3cf2129f41b10ea293beb4c483d02.tar.gz
Dive list: filter dives at DiveTripModel level
We use a QFilterProxyModel to filter out dives that are hidden according to the current filter-criterion. Instead, filter the dives already at the DiveTripModel level. Filter out hidden dives immediately when receiving them. The only difficult case is when dives are changed, because then visibility can change. This means that we have three cases to consider: 1) Visibility unchanged -> send change signal 2) Change from hidden to unhidden -> add dives to model 3) Change from unhidden to hidden -> remove dives from model Things get complicated by the fact that the tree-version of the model might have to add/remove full trips! Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r--qt-models/divetripmodel.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index 2787012c4..72362f938 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -124,6 +124,8 @@ private:
void divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &);
dive *diveOrNull(const QModelIndex &index) const override;
void divesChangedTrip(dive_trip *trip, const QVector<dive *> &dives);
+ void divesShown(dive_trip *trip, const QVector<dive *> &dives);
+ void divesHidden(dive_trip *trip, const QVector<dive *> &dives);
void divesTimeChangedTrip(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives);
bool calculateFilterForTrip(const std::vector<dive *> &dives, const DiveFilter *filter, quintptr parentIndex);
@@ -151,8 +153,13 @@ private:
dive_or_trip tripOrDive(const QModelIndex &index) const;
// Returns either a pointer to a trip or a dive, or twice null of index is invalid
// null, something is really wrong
- // Addition and deletion of dives
+ // Addition and deletion of dives and trips
+ void addTrip(dive_trip *trip, const QVector<dive *> &dives);
void addDivesToTrip(int idx, const QVector<dive *> &dives);
+ void addDivesTopLevel(const QVector<dive *> &dives);
+ void removeDivesFromTrip(int idx, const QVector<dive *> &dives);
+ void removeDivesTopLevel(const QVector<dive *> &dives);
+ void removeTrip(int idx);
void topLevelChanged(int idx);
// Access trips and dives
@@ -190,6 +197,8 @@ private:
QVariant data(const QModelIndex &index, int role) const override;
bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
dive *diveOrNull(const QModelIndex &index) const override;
+ void addDives(QVector<dive *> &dives);
+ void removeDives(QVector<dive *> &dives);
std::vector<dive *> items; // TODO: access core data directly
};