diff --git a/src/apps/haikudepot/Model.cpp b/src/apps/haikudepot/Model.cpp index 1810edc9e3..a05e71fc24 100644 --- a/src/apps/haikudepot/Model.cpp +++ b/src/apps/haikudepot/Model.cpp @@ -558,6 +558,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags) && result.FindMessage("items", &items) == B_OK) { BAutolock locker(&fLock); + package->ClearUserRatings(); int index = 0; while (true) { @@ -622,6 +623,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags) { BAutolock locker(&fLock); screenshotInfos = package->ScreenshotInfos(); + package->ClearScreenshots(); } for (int i = 0; i < screenshotInfos.CountItems(); i++) { const ScreenshotInfo& info = screenshotInfos.ItemAtFast(i); @@ -910,6 +912,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data) if (categories.FindString(name, &category) != B_OK) break; + package->ClearCategories(); for (int i = fCategories.CountItems() - 1; i >= 0; i--) { const CategoryRef& categoryRef = fCategories.ItemAtFast(i); if (categoryRef->Name() == category) { @@ -940,6 +943,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data) BMessage screenshots; if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) { + package->ClearScreenshotInfos(); bool foundScreenshot = false; int32 index = 0; while (true) { diff --git a/src/apps/haikudepot/PackageInfo.cpp b/src/apps/haikudepot/PackageInfo.cpp index 3b3c012599..5c8eade63a 100644 --- a/src/apps/haikudepot/PackageInfo.cpp +++ b/src/apps/haikudepot/PackageInfo.cpp @@ -813,6 +813,16 @@ PackageInfo::IsSystemPackage() const } +void +PackageInfo::ClearCategories() +{ + if (!fCategories.IsEmpty()) { + fCategories.Clear(); + _NotifyListeners(PKG_CHANGED_CATEGORIES); + } +} + + bool PackageInfo::AddCategory(const CategoryRef& category) { @@ -861,6 +871,16 @@ PackageInfo::SetDownloadProgress(float progress) } +void +PackageInfo::ClearUserRatings() +{ + if (!fUserRatings.IsEmpty()) { + fUserRatings.Clear(); + _NotifyListeners(PKG_CHANGED_RATINGS); + } +} + + bool PackageInfo::AddUserRating(const UserRating& rating) { @@ -930,6 +950,13 @@ PackageInfo::CalculateRatingSummary() const } +void +PackageInfo::ClearScreenshotInfos() +{ + fScreenshotInfos.Clear(); +} + + bool PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info) { @@ -937,6 +964,16 @@ PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info) } +void +PackageInfo::ClearScreenshots() +{ + if (!fScreenshots.IsEmpty()) { + fScreenshots.Clear(); + _NotifyListeners(PKG_CHANGED_SCREENSHOTS); + } +} + + bool PackageInfo::AddScreenshot(const BitmapRef& screenshot) { diff --git a/src/apps/haikudepot/PackageInfo.h b/src/apps/haikudepot/PackageInfo.h index ddbd988d04..f54646ac50 100644 --- a/src/apps/haikudepot/PackageInfo.h +++ b/src/apps/haikudepot/PackageInfo.h @@ -312,20 +312,24 @@ public: { return fDownloadProgress; } void SetDownloadProgress(float progress); + void ClearCategories(); bool AddCategory(const CategoryRef& category); const CategoryList& Categories() const { return fCategories; } + void ClearUserRatings(); bool AddUserRating(const UserRating& rating); const UserRatingList& UserRatings() const { return fUserRatings; } void SetRatingSummary(const RatingSummary& summary); RatingSummary CalculateRatingSummary() const; + void ClearScreenshotInfos(); bool AddScreenshotInfo(const ScreenshotInfo& info); const ScreenshotInfoList& ScreenshotInfos() const { return fScreenshotInfos; } + void ClearScreenshots(); bool AddScreenshot(const BitmapRef& screenshot); const BitmapList& Screenshots() const { return fScreenshots; }