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
This commit is contained in:
Rene Gollent
2008-11-19 06:04:53 +00:00
parent 4e0a1b40ad
commit 52a7c90673
+9 -1
View File
@@ -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