From 5a7dbf02258d1c5b12f9db01c275e4a0bbe97aff Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Sun, 16 Aug 2015 11:57:18 +0300 Subject: QML UI: Use AddDive instead of clear dive No need to clear the dives when adding a new one. Signed-off-by: Grace Karanja --- qt-mobile/qmlmanager.cpp | 3 ++- qt-models/divelistmodel.cpp | 7 +++++-- qt-models/divelistmodel.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 763de1b46..021c9c0d0 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -129,7 +129,8 @@ void QMLManager::saveChanges() void QMLManager::addDive() { - DiveListModel::instance()->clearDives(); + showMessage("Adding new dive."); + DiveListModel::instance()->startAddDive(); } bool QMLManager::saveCloudPassword() const diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 837b75f14..7b7102f7b 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -338,9 +338,12 @@ QHash DiveListModel::roleNames() const return roles; } -void DiveListModel::clearDives() +void DiveListModel::startAddDive() { - m_dives.clear(); + struct dive *d; + d = alloc_dive(); + add_single_dive(get_divenr(d), d); + addDive(d); } DiveListModel *DiveListModel::instance() diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index ad7eb99b6..68022812c 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(); + void startAddDive(); private: QList m_dives; static DiveListModel *m_instance; -- cgit v1.2.3-70-g09d2