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>
This commit is contained in:
Tomaz Canabrava 2013-12-03 20:34:05 -02:00 committed by Dirk Hohndel
parent 04bbfe2ab1
commit d128b74a8a

View file

@ -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()