diff options
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 19 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 3 |
2 files changed, 6 insertions, 16 deletions
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; } diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 74addbc50..b1bdfd2b7 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -19,6 +19,8 @@ #include "core/settings/qPrefCloudStorage.h" #include "core/subsurface-qt/divelistnotifier.h" +class QAction; + class QMLManager : public QObject { Q_OBJECT Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged) @@ -264,6 +266,7 @@ private: bool m_showNonDiveComputers; struct dive *m_copyPasteDive = NULL; struct dive_components what; + QAction *undoAction; bool verifyCredentials(QString email, QString password, QString pin); |