From 52a7c906730d0436e344fc2de002ce696adba5c9 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 19 Nov 2008 06:04:53 +0000 Subject: [PATCH] Position-based binary searching can only be used if the view has been attached to a window already. If not, we fall back to using the BList-based search. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28696 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 8b5025f1f9..3b2e0ad595 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -733,6 +733,14 @@ BListView::ItemAt(int32 index) const int32 BListView::IndexOf(BListItem *item) const { + if (Window()) { + if (item != NULL) { + int32 index = IndexOf(BPoint(0.0, item->Top())); + if (index >= 0 && fList.ItemAt(index) == item) + return index; + return -1; + } + } return fList.IndexOf(item); } @@ -779,7 +787,7 @@ BListView::LastItem() const bool BListView::HasItem(BListItem *item) const { - return fList.HasItem(item); + return IndexOf(item) != -1; } // CountItems