From e917a2404dee2e7e9839e3dbc6910759526061b7 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 31 Jan 2010 17:32:12 +0000 Subject: [PATCH] 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 --- src/kits/interface/OutlineListView.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/OutlineListView.cpp b/src/kits/interface/OutlineListView.cpp index d3a497cb2d..510ce30ad4 100644 --- a/src/kits/interface/OutlineListView.cpp +++ b/src/kits/interface/OutlineListView.cpp @@ -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;