diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-12-03 20:34:05 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-03 18:48:17 -0800 |
commit | d128b74a8a05fda4cd43583ecc2323fd2d38f032 (patch) | |
tree | 9f1731748ebcd44672df6d780effe56156def65f /qt-ui | |
parent | 04bbfe2ab18223c8a6d39683212c6eaefbdf66f2 (diff) | |
download | subsurface-d128b74a8a05fda4cd43583ecc2323fd2d38f032.tar.gz |
Select the newly added dive after adding it.
Selects the newly added dive after adding it, it uses a
rather ugly hack that forced a unselected dive to be
marked as 'selected' so we can remember what was the
newly added dive, and select it after.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index a36cb9130..c91870f46 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -618,16 +618,26 @@ void MainTab::acceptChanges() fixup_dive(d); } - editMode = NONE; - resetPallete(); - // now comes the scary moment... we need to re-sort dive table in case this dive wasn't the last - // so now all pointers become invalid - // fingers crossed that we aren't holding on to anything here - mainWindow()->dive_list()->rememberSelection(); - sort_table(&dive_table); - mainWindow()->refreshDisplay(); - mainWindow()->dive_list()->restoreSelection(); + if(editMode == ADD){ + mainWindow()->dive_list()->unselectDives(); + struct dive *d = get_dive(dive_table.nr -1 ); + // HACK. this shouldn't be here. but apparently it's + // how we can know what was the newly added dive. + d->selected = true; + sort_table(&dive_table); + int i = 0; + for_each_dive(i,d){ + if (d->selected) break; + } + mainWindow()->dive_list()->selectDive( i, true ); + }else{ + mainWindow()->dive_list()->rememberSelection(); + sort_table(&dive_table); + mainWindow()->refreshDisplay(); + mainWindow()->dive_list()->restoreSelection(); + } + editMode = NONE; } void MainTab::resetPallete() |