aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-23 13:39:40 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-23 14:07:49 +0100
commit2772ab8764ff1bab1baf77f13ebb0845db21a7d4 (patch)
treece52117eb02f21493312bfaceab3a71e6ff72f0f /qt-mobile
parentae22b7cae00bc3f55e3144a0122eb3279332ad41 (diff)
downloadsubsurface-2772ab8764ff1bab1baf77f13ebb0845db21a7d4.tar.gz
Add helper to delete dive from QML
Once again we make this save the changes to the local cache without being prompted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/qmlmanager.cpp18
-rw-r--r--qt-mobile/qmlmanager.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index aa804d51a..663463b80 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -606,11 +606,27 @@ void QMLManager::saveChanges()
return;
}
- appendTextToLog("Dive saved.");
+ appendTextToLog("Updated dive list saved.");
set_filename(fileName.toUtf8().data(), true);
mark_divelist_changed(false);
}
+void QMLManager::deleteDive(int id)
+{
+ struct dive *d = get_dive_by_uniq_id(id);
+ if (!d) {
+ qDebug() << "oops, trying to delete non-existing dive";
+ return;
+ }
+ DiveListModel::instance()->removeDiveById(id);
+ delete_single_dive(get_idx_by_uniq_id(id));
+ prefs.cloud_background_sync = false;
+ prefs.git_local_only = true;
+ saveChanges();
+ prefs.cloud_background_sync = true;
+ prefs.git_local_only = false;
+}
+
QString QMLManager::addDive()
{
appendTextToLog("Adding new dive.");
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 433001a5a..fec29c13c 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -91,6 +91,7 @@ public slots:
QString startpressure, QString endpressure, QString gasmix);
void saveChanges();
+ void deleteDive(int id);
QString addDive();
void addDiveAborted(int id);
void applyGpsData();