summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qml/DiveDetails.qml3
-rw-r--r--mobile-widgets/qmlmanager.cpp5
-rw-r--r--mobile-widgets/qmlmanager.h2
3 files changed, 6 insertions, 4 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
index 3d146ce46..d562e0a98 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -54,11 +54,12 @@ Kirigami.Page {
onTriggered: {
contextDrawer.close()
var deletedId = diveDetailsListView.currentItem.modelData.dive.id
+ var deletedIndex = diveDetailsListView.currentIndex
manager.deleteDive(deletedId)
stackView.pop()
showPassiveNotification("Dive deleted", 3000, "Undo",
function() {
- manager.undoDelete(deletedId)
+ diveDetailsListView.currentIndex = manager.undoDelete(deletedId) ? deletedIndex : diveDetailsListView.currentIndex
});
}
}
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 6ea9b57f2..c225f689e 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -816,11 +816,11 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
alreadySaving = false;
}
-void QMLManager::undoDelete(int id)
+bool QMLManager::undoDelete(int id)
{
if (!deletedDive || deletedDive->id != id) {
qDebug() << "can't find the deleted dive";
- return;
+ return false;
}
if (deletedTrip)
insert_trip(&deletedTrip);
@@ -840,6 +840,7 @@ void QMLManager::undoDelete(int id)
changesNeedSaving();
deletedDive = NULL;
deletedTrip = NULL;
+ return true;
}
void QMLManager::deleteDive(int id)
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 9609baddf..6a0ba455b 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -103,7 +103,7 @@ public slots:
void saveChangesLocal();
void saveChangesCloud(bool forceRemoteSync);
void deleteDive(int id);
- void undoDelete(int id);
+ bool undoDelete(int id);
QString addDive();
void addDiveAborted(int id);
void applyGpsData();