Fix some selection-related problems in BOutlineListView as well as

broken behavior in _RemoveItem that could potentially result in the wrong 
list items being removed/deleted depending on the expanded/collapsed state 
of higher items in the list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35360 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-01-31 17:32:12 +00:00
parent 23b7090f09
commit e917a2404d

View File

@ -854,12 +854,16 @@ BOutlineListView::ExpandOrCollapse(BListItem* item, bool expand)
_RecalcItemTops(startIndex);
// fix selection hints
// if the selected item was just removed by collapsing, select its
// parent
if (ListType() == B_SINGLE_SELECTION_LIST && selectionChanged)
fFirstSelected = fLastSelected = index;
if (index < fFirstSelected && index + count < fFirstSelected) {
// all items removed were higher than the selection range,
// adjust the indexes to correspond to their new visible positions
fFirstSelected -= count;
fLastSelected -= count;
}
// all items removed were higher than the selection range,
// adjust the indexes to correspond to their new visible positions
fFirstSelected -= count;
fLastSelected -= count;
}
int32 maxIndex = fList.CountItems() - 1;
if (fFirstSelected > maxIndex)
@ -1113,8 +1117,8 @@ BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex)
if (item->IsItemVisible()) {
// remove children, too
while (fullIndex + 1 < CountItems()) {
BListItem* subItem = ItemAt(fullIndex + 1);
while (fullIndex + 1 < FullListCountItems()) {
BListItem* subItem = FullListItemAt(fullIndex + 1);
if (subItem->OutlineLevel() <= level)
break;