Upon undoing a dive deletion select that dive

Before it had the next dive still selected.

Fixes #1053

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert Helling 2016-04-11 21:10:46 +02:00 committed by Dirk Hohndel
parent e1af20728e
commit 7bca367c57
3 changed files with 6 additions and 4 deletions

View file

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

View file

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

View file

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