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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user