diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divetripmodel.cpp | 11 | ||||
-rw-r--r-- | qt-models/divetripmodel.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index d2e6a634d..bcdf14377 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -376,6 +376,7 @@ void DiveTripModelBase::clear() { beginResetModel(); clear_dive_file_data(); + clearData(); emit diveListNotifier.divesSelected({}, nullptr); // Inform profile, etc of changed selection endResetModel(); } @@ -607,6 +608,11 @@ int DiveTripModelTree::rowCount(const QModelIndex &parent) const return entry.d_or_t.trip ? entry.dives.size() : 0; } +void DiveTripModelList::clearData() +{ + items.clear(); +} + static const quintptr noParent = ~(quintptr)0; // This is the "internalId" marker for top-level item QModelIndex DiveTripModelTree::index(int row, int column, const QModelIndex &parent) const @@ -1238,6 +1244,11 @@ int DiveTripModelList::rowCount(const QModelIndex &parent) const return parent.isValid() ? 0 : items.size(); } +void DiveTripModelTree::clearData() +{ + items.clear(); +} + QModelIndex DiveTripModelList::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) 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; |