Dive list: remove global pointer to DiveTrip model

This part of the code had that horrible pattern, where reseting
the model would invalidate all pointers to the DiveTrip model.
Internalize these complexities in the MultiFilterSortModel.
All accesses are now performed via that proxy model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-12-09 15:37:26 +01:00 committed by Dirk Hohndel
parent 0f417a3bc1
commit 6ec82a3c80
4 changed files with 16 additions and 41 deletions

View file

@ -5,7 +5,10 @@
#include "divetripmodel.h"
#include <QSortFilterProxyModel>
#include <memory>
// This proxy model sits on top of either a DiveTripList or DiveTripTree model
// and does filtering and/or sorting.
class MultiFilterSortModel : public QSortFilterProxyModel {
Q_OBJECT
public:
@ -23,6 +26,7 @@ private slots:
void currentDiveChangedSlot(QModelIndex index);
private:
MultiFilterSortModel(QObject *parent = 0);
std::unique_ptr<DiveTripModelBase> model;
};
#endif