void PackageListView::MessageReceived(BMessage* message) { switch (message->what) { case MSG_UPDATE_PACKAGE: { BString title; uint32 changes; if (message->FindString("title", &title) != B_OK || message->FindUInt32("changes", &changes) != B_OK) { break; } BAutolock _(fModelLock); PackageRow* row = _FindRow(title); if (row != NULL) { if ((changes & PKG_CHANGED_RATINGS) != 0) row->UpdateRating(); if ((changes & PKG_CHANGED_STATE) != 0) row->UpdateState(); } break; } default: BColumnListView::MessageReceived(message); break; } }
void PackageListView::RemovePackage(const PackageInfoRef& package) { PackageRow* packageRow = _FindRow(package); if (packageRow == NULL) return; RemoveRow(packageRow); delete packageRow; fItemCountView->SetItemCount(CountRows()); }
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); } }
nwxGridCellValidator *nwxGridCellValidatorCollection::Find( int nRow, int nCol) { nwxGridCellValidator *pRtn = NULL; if((pRtn = _FindCell(nRow,nCol)) != NULL) {} else if((pRtn = _FindRow(nRow)) != NULL) {} else if((pRtn = _FindCol(nCol)) != NULL) {} else { pRtn = m_pDefaultValidator; } return pRtn; }
PackageRow* PackageListView::_FindRow(const PackageInfoRef& package, PackageRow* parent) { for (int32 i = CountRows(parent) - 1; i >= 0; i--) { PackageRow* row = dynamic_cast<PackageRow*>(RowAt(i, parent)); if (row != NULL && row->Package() == package) return row; if (CountRows(row) > 0) { // recurse into child rows row = _FindRow(package, row); if (row != NULL) return row; } } return NULL; }
PackageRow* PackageListView::_FindRow(const BString& packageTitle, PackageRow* parent) { for (int32 i = CountRows(parent) - 1; i >= 0; i--) { PackageRow* row = dynamic_cast<PackageRow*>(RowAt(i, parent)); if (row != NULL && row->Package().Get() != NULL && row->Package()->Title() == packageTitle) { return row; } if (CountRows(row) > 0) { // recurse into child rows row = _FindRow(packageTitle, row); if (row != NULL) return row; } } return NULL; }
void PackageListView::AddPackage(const PackageInfoRef& package) { PackageRow* packageRow = _FindRow(package); // forget about it if this package is already in the listview if (packageRow != NULL) return; BAutolock _(fModelLock); // create the row for this package packageRow = new PackageRow(package, fPackageListener); // add the row, parent may be NULL (add at top level) AddRow(packageRow); // make sure the row is initially expanded ExpandOrCollapse(packageRow, true); fItemCountView->SetItemCount(CountRows()); }