QML UI: introduce "add" state and correctly clean up when canceled

Adding a dive is just like editing it, except that canceling the operation
has different consequences. Instead of trying to figure this out by some
inference on other state, let's just make it explicit and then clean up
after ourselves if the user canceled a manual dive add.

This also switches to use the properties that we defined in order for the
main menu to be able to setup these values. Makes the code easier to read
and is more consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-29 06:47:27 -08:00
parent 9f7ecbb53e
commit 0eae59bcd2
2 changed files with 30 additions and 16 deletions

View file

@ -66,7 +66,7 @@ MobileComponents.ApplicationWindow {
Action {
text: "Add dive manually"
onTriggered: {
detailsWindow.state = "edit"
detailsWindow.state = "add"
detailsWindow.dive_id = manager.addDive();
detailsWindow.number = manager.getNumber(detailsWindow.dive_id)
detailsWindow.date = manager.getDate(detailsWindow.dive_id)