mobile: clear internal data when edit/add dive is finished

When editing (or adding) a dive, the internal data containing the
attributes on the edit page was not cleared when editing was
finished (in any way, by saving the edit or by cancelling it).
As long as the user only edits existing dives, all this poses
no problem, as at the start of a dive edit, the data is filled
from the dive to be edited. However, when adding a dive, data
coming from previous edits shows up. This not clearing data
also causes the strange effect as written in issue #950: adding
a dive, deleting it, and adding a dive again, added the first
added dive data, without the edit screen being shown.

All this can be solved by clearing the data from the edit when
editing is done.

Fixes: #950

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2017-12-15 17:13:15 +01:00 committed by Dirk Hohndel
parent 9e165602c4
commit ef543da5af
2 changed files with 20 additions and 0 deletions

View file

@ -207,6 +207,7 @@ Kirigami.Page {
state = "view";
focus = false;
Qt.inputMethod.hide();
detailsEdit.clearDetailsEdit();
}
function startEditMode() {

View file

@ -39,6 +39,24 @@ Item {
property int rating
property int visibility
function clearDetailsEdit() {
detailsEdit.dive_id = 0
detailsEdit.number = 0
detailsEdit.dateText = ""
detailsEdit.locationText = ""
detailsEdit.durationText = ""
detailsEdit.depthText = ""
detailsEdit.airtempText = ""
detailsEdit.watertempText = ""
suitBox.currentIndex = -1
buddyBox.currentIndex = -1
divemasterBox.currentIndex = -1
cylinderBox.currentIndex = -1
detailsEdit.notesText = ""
detailsEdit.rating = 0
detailsEdit.visibility = 0
}
function saveData() {
diveDetailsPage.state = "view" // run the transition
// apply the changes to the dive_table
@ -71,6 +89,7 @@ Item {
Qt.inputMethod.hide()
// now make sure we directly show the saved dive (this may be a new dive, or it may have moved)
showDiveIndex(newIdx)
clearDetailsEdit()
}
height: editArea.height