summaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-18 18:44:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-19 21:13:40 -0800
commit635d67ee7feed0ddc7a5e36d6a7f5c2ed1ee9ba1 (patch)
treeebb2ed05570cff1fd9d28efb4ae6bee29725febd /qt-models/divetripmodel.h
parent9f573df971d84a54d5b5daba73a2f9e1498d7ee2 (diff)
downloadsubsurface-635d67ee7feed0ddc7a5e36d6a7f5c2ed1ee9ba1.tar.gz
Dive list: clear internal data when clearing model
The DiveListModelBase::clear() implementation was flawed: It cleared the data in the core, but left the data in the model untouched. The code was relying on the fact that the caller would reset the model manually. Not a good idea. Therefore, clear the internal data to keep the model consistent at all times. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r--qt-models/divetripmodel.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index 94278229d..c7e488030 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -100,6 +100,7 @@ protected:
static QVariant tripData(const dive_trip *trip, int column, int role);
virtual dive *diveOrNull(const QModelIndex &index) const = 0; // Returns a dive if this index represents a dive, null otherwise
+ virtual void clearData() = 0;
};
class DiveTripModelTree : public DiveTripModelBase
@@ -119,6 +120,7 @@ public:
DiveTripModelTree(QObject *parent = nullptr);
private:
int rowCount(const QModelIndex &parent) const override;
+ void clearData() override;
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;
@@ -184,6 +186,7 @@ public:
DiveTripModelList(QObject *parent = nullptr);
private:
int rowCount(const QModelIndex &parent) const override;
+ void clearData() override;
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;