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>
This commit is contained in:
Dirk Hohndel 2016-02-23 13:39:40 +01:00
parent ae22b7cae0
commit 2772ab8764
2 changed files with 18 additions and 1 deletions

View file

@ -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.");

View file

@ -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();