diff options
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 4 | ||||
-rw-r--r-- | qt-models/divelistmodel.cpp | 7 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 858f2c730..126cca7b8 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -277,7 +277,7 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state) void QMLManager::openLocalThenRemote(QString url) { - clear_dive_file_data(); + DiveListModel::instance()->clear(); setNotificationText(tr("Open local dive data file")); QByteArray fileNamePrt = QFile::encodeName(url); bool glo = git_local_only; @@ -730,7 +730,7 @@ void QMLManager::loadDivesWithValidCredentials() // if we aren't switching from no-cloud mode, let's clear the dive data if (!noCloudToCloud) { appendTextToLog("Clear out in memory dive data"); - clear_dive_file_data(); + DiveListModel::instance()->clear(); } else { appendTextToLog("Switching from no cloud mode; keep in memory dive data"); } diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 779e695ab..6f7d69412 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -171,6 +171,13 @@ void DiveListModel::updateDive(int i, dive *d) insertDive(i); } +void DiveListModel::clear() +{ + beginResetModel(); + clear_dive_file_data(); + endResetModel(); +} + void DiveListModel::reload() { beginResetModel(); diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index d6eb07463..686dcd1c3 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -62,6 +62,7 @@ public: QHash<int, QByteArray> roleNames() const; QString startAddDive(); void resetInternalData(); + void clear(); // Clear all dives in core Q_INVOKABLE DiveObjectHelper at(int i); private: static DiveListModel *m_instance; |