diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index 4093cea9b0..3188b24189 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -439,15 +439,8 @@ Model::CreatePackageList() const for (int32 j = 0; j < packages.CountItems(); j++) { const PackageInfoRef& package = packages.ItemAtFast(j); - if (fCategoryFilter->AcceptsPackage(package) - && fSearchTermsFilter->AcceptsPackage(package) - && fIsFeaturedFilter->AcceptsPackage(package) - && (fShowAvailablePackages || package->State() != NONE) - && (fShowInstalledPackages || package->State() != ACTIVATED) - && (fShowSourcePackages || !is_source_package(package)) - && (fShowDevelopPackages || !is_develop_package(package))) { + if (MatchesFilter(package)) resultList.Add(package); - } } } @@ -455,6 +448,19 @@ Model::CreatePackageList() const } +bool +Model::MatchesFilter(const PackageInfoRef& package) const +{ + return fCategoryFilter->AcceptsPackage(package) + && fSearchTermsFilter->AcceptsPackage(package) + && fIsFeaturedFilter->AcceptsPackage(package) + && (fShowAvailablePackages || package->State() != NONE) + && (fShowInstalledPackages || package->State() != ACTIVATED) + && (fShowSourcePackages || !is_source_package(package)) + && (fShowDevelopPackages || !is_develop_package(package)); +} + + bool Model::AddDepot(const DepotInfo& depot) { diff --git a/src/apps/haikudepot/model/Model.h b/src/apps/haikudepot/model/Model.h index fa852b176a..a4baa39841 100644 --- a/src/apps/haikudepot/model/Model.h +++ b/src/apps/haikudepot/model/Model.h @@ -72,6 +72,9 @@ public: // !Returns new PackageInfoList from current parameters PackageList CreatePackageList() const; + bool MatchesFilter( + const PackageInfoRef& package) const; + bool AddDepot(const DepotInfo& depot); bool HasDepot(const BString& name) const; const DepotList& Depots() const diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index 3a8fdd1193..bc8d021bdf 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -487,8 +487,7 @@ MainWindow::MessageReceived(BMessage* message) BAutolock locker(fModel.Lock()); // The package didn't get a chance yet to be in the // visible package list - PackageList visiblePackages = fModel.CreatePackageList(); - isVisible = visiblePackages.Contains(ref); + isVisible = fModel.MatchesFilter(ref); // Transfer this single package, otherwise we miss // other packages if they appear or disappear along