From 74faca5d43f856b9f72a9023ef0b5b1ace238285 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 27 Dec 2013 08:18:53 -0800 Subject: Handle editing a manually added dive consistently Regardless of whether the user clicks in the info tab, makes a change to equipment or starts by editing the profile (i.e., clicking on the little penguin), we should get into the same state and behave the same way. This means that when editing a manually added dive we are always in editMode == MANUALLY_ADDED_DIVE - and editMode == DIVE means we are editing a dive that came from another source. Fixes #379 Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ae4cf534c..40dcf9b48 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -178,8 +178,7 @@ void MainTab::toggleTriggeredColumn() void MainTab::addDiveStarted() { - enableEdition(); - editMode = ADD; + enableEdition(ADD); } void MainTab::addMessageAction(QAction* action) @@ -221,9 +220,15 @@ void MainTab::displayMessage(QString str) void MainTab::enableEdition(EditMode newEditMode) { - if (selected_dive < 0 || editMode != NONE) + if (current_dive == NULL || editMode != NONE) return; - + if ((newEditMode == DIVE || newEditMode == NONE) && + strcmp(current_dive->dc.model, "manually added dive") == 0) { + // editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE + // so exit this function here after editCurrentDive() returns + mainWindow()->editCurrentDive(); + return; + } mainWindow()->dive_list()->setEnabled(false); mainWindow()->globe()->prepareForGetDiveCoordinates(); // We may be editing one or more dives here. backup everything. @@ -915,7 +920,7 @@ void MainTab::on_notes_textChanged() // we are editing a trip dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips().begin(); EDIT_TEXT(currentTrip->notes, ui.notes->toPlainText()); - } else if (editMode == DIVE || editMode == ADD) { + } else if (editMode == DIVE || editMode == ADD || editMode == MANUALLY_ADDED_DIVE) { EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui.notes->toPlainText()) ); } markChangedWidget(ui.notes); -- cgit v1.2.3-70-g09d2