From 9fb52cc45c22191b26c4d1f8ce98e9d88a5bee83 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 14 Nov 2019 22:19:58 +0100 Subject: mobile/undo: create undo-action and connect to undo of dive deletion Still buggy: Removing a dive followed by undo shows the wrong dive in the list. But clicking on it gives the correct dive. Signed-off-by: Berthold Stoeger Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'mobile-widgets/qmlmanager.cpp') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 3e3fb7a0c..aef961a49 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -155,6 +155,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), alreadySaving(false), m_pluggedInDeviceName(""), m_showNonDiveComputers(false), + undoAction(Command::undoAction(this)), m_oldStatus(qPrefCloudStorage::CS_UNKNOWN) { m_instance = this; @@ -1383,24 +1384,10 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync) git_local_only = glo; } -bool QMLManager::undoDelete(int id) +bool QMLManager::undoDelete(int) { - if (!deletedDive || deletedDive->id != id) { - appendTextToLog("Trying to undo delete but can't find the deleted dive"); - return false; - } - if (deletedTrip) - insert_trip(deletedTrip, &trip_table); - if (deletedDive->divetrip) { - struct dive_trip *trip = deletedDive->divetrip; - deletedDive->divetrip = NULL; - add_dive_to_trip(deletedDive, trip); - } - record_dive(deletedDive); - DiveListModel::instance()->insertDive(get_idx_by_uniq_id(deletedDive->id)); + undoAction->activate(QAction::Trigger); changesNeedSaving(); - deletedDive = NULL; - deletedTrip = NULL; return true; } -- cgit v1.2.3-70-g09d2