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 /desktop-widgets/divelistview.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 'desktop-widgets/divelistview.h')
-rw-r--r-- | desktop-widgets/divelistview.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 85d8bd21c..830447d92 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -68,7 +68,7 @@ slots: private: bool mouseClickSelection; QList<int> expandedRows; - DiveTripModel::Layout currentLayout; + DiveTripModelBase::Layout currentLayout; QModelIndex contextMenuIndex; bool dontEmitDiveChangedSignal; bool selectionSaved; @@ -77,6 +77,7 @@ private: /* if dive_trip_t is null, there's no problem. */ QMultiHash<dive_trip_t *, int> selectedDives; + void resetModel(); // Call after model changed void merge_trip(const QModelIndex &a, const int offset); void setColumnWidths(); void calculateInitialColumnWidth(int col); |