summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-14 17:52:03 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-14 17:58:14 +0900
commitdfd17c7a7fd1f5dd85f61a6feef96c616e02cfcb (patch)
tree1a319e3029bd13436ae266f7f1658a8ccd9bb92f /qt-ui/maintab.cpp
parent179615f3a9a7a657f9039e124865b2f449ddb703 (diff)
downloadsubsurface-dfd17c7a7fd1f5dd85f61a6feef96c616e02cfcb.tar.gz
Maintain the selection when aborting "dive add"
We remember what was selected before and restore it. Maybe there's a more "Qt way" of doing this, but my implementation appears to work :-) Also remove unconditional debug output that snuck into an earlier commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index bd10ed356..005efe496 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -493,7 +493,6 @@ void MainTab::acceptChanges()
}
}
- save_dive(stdout, current_dive);
if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) {
// clean up the dive data (get duration, depth information from samples)
fixup_dive(current_dive);
@@ -558,7 +557,6 @@ void MainTab::rejectChanges()
if (lastMode == ADD) {
// clean up
DivePlannerPointsModel::instance()->cancelPlan();
- delete_single_dive(selected_dive);
} else if (lastMode == MANUALLY_ADDED_DIVE ) {
DivePlannerPointsModel::instance()->undoEdition(); // that's BOGUS... just copy the original dive back and be done with it...
}
@@ -609,6 +607,11 @@ void MainTab::rejectChanges()
}
}
updateGpsCoordinates(curr);
+ if (lastMode == ADD) {
+ delete_single_dive(selected_dive);
+ mainWindow()->dive_list()->reload(DiveTripModel::CURRENT);
+ mainWindow()->dive_list()->restoreSelection();
+ }
if (selected_dive >= 0) {
multiEditEquipmentPlaceholder = *get_dive(selected_dive);
cylindersModel->setDive(&multiEditEquipmentPlaceholder);
@@ -627,14 +630,15 @@ void MainTab::rejectChanges()
ui.equipmentButtonBox->hide();
notesBackup.clear();
resetPallete();
+ editMode = NONE;
if (lastMode == ADD || lastMode == MANUALLY_ADDED_DIVE) {
// more clean up
updateDiveInfo(selected_dive);
mainWindow()->showProfile();
- mainWindow()->refreshDisplay();
+ // we already reloaded the divelist above, so don't recreate it or we'll lose the selection
+ mainWindow()->refreshDisplay(false);
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
}
- editMode = NONE;
}
#undef EDIT_TEXT2