diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-12-27 10:06:11 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-01-07 09:33:52 -0800 |
commit | f1fc89b978c178fcd0f4f3ddb7629dc7df0d939d (patch) | |
tree | 14290d807253d3fc222da25ae9a283c365c59ca6 /qt-models/filtermodels.h | |
parent | b5704ddb57d905e66f5f71558bb07b2f165913a9 (diff) | |
download | subsurface-f1fc89b978c178fcd0f4f3ddb7629dc7df0d939d.tar.gz |
Dive list: split DiveTripModel into distinct models (tree and list)
The DiveTripModel was used to represent both, trip and list views.
Thus many functions had conditionals checking for the current mode
and both modes had to be represented by the same data structure.
Instead, split the model in two and derive them from a base class,
which implements common functions and defines an interface.
The model can be switched by a call to resetModel(), which invalidates
any pointer obtained by instance(). This is quite surprising
behavior. To handle it, straighten out the control flow:
DiveListView --> MultiFilterSortModel --> DiveTripModelBase
Before, DiveListView accessed DiveTripModelBase directly.
A goal of this commit is to enable usage of the same model by mobile
and desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.h')
-rw-r--r-- | qt-models/filtermodels.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 442bdec5e..a8a601ecc 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -2,7 +2,7 @@ #ifndef FILTERMODELS_H #define FILTERMODELS_H -#include "divetripmodel.h" // For DiveTripModel::Layout. TODO: remove in due course +#include "divetripmodel.h" #include <QStringListModel> #include <QSortFilterProxyModel> @@ -13,7 +13,6 @@ struct dive; struct dive_trip; -class DiveTripModel; struct FilterData { bool validFilter = false; @@ -49,7 +48,7 @@ slots: void startFilterDiveSite(struct dive_site *ds); void stopFilterDiveSite(); void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles); - void setLayout(DiveTripModel::Layout layout); + void resetModel(DiveTripModelBase::Layout layout); void filterDataChanged(const FilterData& data); signals: |