From 44145c740532b46317e4a19e0ad1f88b5072be65 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 3 Aug 2009 19:46:00 +0000 Subject: [PATCH] Fixed two more peculiarities in ListView: * when items are removed, the anchor may need adjustment (fixes the problem in Beam reported by Stippi) * the check for needed adjustment of fLastSelected in _Select(from, to, extend) was broken, as it needs to be independent of fFirstSelected - this fixes broken navigation after doing a select-all git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32099 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 796c643432..d5e4526a48 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -671,6 +671,9 @@ BListView::RemoveItem(int32 index) if (fLastSelected != -1 && index < fLastSelected) fLastSelected--; + if (fAnchorIndex != -1 && index < fAnchorIndex) + fAnchorIndex--; + _RecalcItemTops(index); _InvalidateFrom(index); @@ -696,6 +699,9 @@ BListView::RemoveItems(int32 index, int32 count) if (index < 0) return false; + if (fAnchorIndex != -1 && index < fAnchorIndex) + fAnchorIndex = index; + fList.RemoveItems(index, count); if (index < fList.CountItems()) _RecalcItemTops(index); @@ -1479,10 +1485,12 @@ BListView::_Select(int32 from, int32 to, bool extend) if (fFirstSelected == -1) { fFirstSelected = from; fLastSelected = to; - } else if (from < fFirstSelected) - fFirstSelected = from; - else if (to > fLastSelected) - fLastSelected = to; + } else { + if (from < fFirstSelected) + fFirstSelected = from; + if (to > fLastSelected) + fLastSelected = to; + } for (int32 i = from; i <= to; ++i) { BListItem *item = ItemAt(i);