From a3bdf49b84d8a30a22e05bc965e98f5e7914f637 Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Wed, 12 Aug 2015 15:01:39 +0300 Subject: QML UI: Clear divelist model before starting new dive When user clicks on AddDive, we should clear the model. Signed-off-by: Grace Karanja --- qt-mobile/qmlmanager.cpp | 2 +- qt-models/divelistmodel.cpp | 5 +++++ qt-models/divelistmodel.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 69282ee90..763de1b46 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -129,7 +129,7 @@ void QMLManager::saveChanges() void QMLManager::addDive() { - + DiveListModel::instance()->clearDives(); } bool QMLManager::saveCloudPassword() const diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 4019bee8b..837b75f14 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -338,6 +338,11 @@ QHash DiveListModel::roleNames() const return roles; } +void DiveListModel::clearDives() +{ + m_dives.clear(); +} + DiveListModel *DiveListModel::instance() { return m_instance; diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index de96480bd..ad7eb99b6 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -128,7 +128,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QHash roleNames() const; - + void clearDives(); private: QList m_dives; static DiveListModel *m_instance; -- cgit v1.2.3-70-g09d2