HaikuDepot: Added PackagesListView::Select(PackageInfo)

which also scrolls the row into view (if it exists).
This commit is contained in:
Stephan Aßmus 2014-12-26 22:41:10 +01:00
parent ede65a8f9b
commit b2843daed7
2 changed files with 17 additions and 0 deletions

View File

@ -758,6 +758,21 @@ PackageListView::AddPackage(const PackageInfoRef& package)
}
void
PackageListView::SelectPackage(const PackageInfoRef& package)
{
PackageRow* row = _FindRow(package);
BRow* selected = CurrentSelection();
if (row != selected)
DeselectAll();
if (row != NULL) {
AddToSelection(row);
SetFocusRow(row, false);
ScrollTo(row);
}
}
PackageRow*
PackageListView::_FindRow(const PackageInfoRef& package, PackageRow* parent)
{

View File

@ -32,6 +32,8 @@ public:
virtual void Clear();
void AddPackage(const PackageInfoRef& package);
void SelectPackage(const PackageInfoRef& package);
private:
PackageRow* _FindRow(const PackageInfoRef& package,
PackageRow* parent = NULL);