summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-12 14:21:50 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-12 14:21:50 +0900
commita683a217b9cbc402a7db0eb77071d1d8151c03cf (patch)
tree70feca17903583297e9247eed332a8d4a76223fe /qt-ui/maintab.cpp
parent94222fbe4905ea3f0e982b61a69290439c7f4e2d (diff)
downloadsubsurface-a683a217b9cbc402a7db0eb77071d1d8151c03cf.tar.gz
First steps to make add dive work with the correct infrastructure
This just makes sure that we do the right thing with the staging drive, that we don't mess up the selection, the we are smart about using our helper functions, etc. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index aa9dc6295..d5199d447 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -497,9 +497,15 @@ void MainTab::acceptChanges()
fixup_dive(current_dive);
if (dive_table.nr == 1)
current_dive->number = 1;
- else if (current_dive == get_dive(dive_table.nr - 1) && get_dive(dive_table.nr - 2)->number)
+ else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number)
current_dive->number = get_dive(dive_table.nr - 2)->number + 1;
DivePlannerPointsModel::instance()->cancelPlan();
+ // now make sure the selection logic is in a sane state
+ // it's ok to hold on to the dive pointer for this short stretch of code
+ // unselectDives() doesn't mess with the dive_table at all
+ struct dive *addedDive = current_dive;
+ mainWindow()->dive_list()->unselectDives();
+ mainWindow()->dive_list()->selectDive(addedDive, true, true);
mainWindow()->showProfile();
mainWindow()->refreshDisplay();
mark_divelist_changed(TRUE);
@@ -548,8 +554,8 @@ void MainTab::rejectChanges()
} else {
if (editMode == ADD) {
// clean up
- delete_single_dive(selected_dive);
DivePlannerPointsModel::instance()->cancelPlan();
+ delete_single_dive(selected_dive);
} else if (editMode == MANUALLY_ADDED_DIVE ) {
DivePlannerPointsModel::instance()->undoEdition(); // that's BOGUS... just copy the original dive back and be done with it...
}