diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index b56c3ec098..8846780f24 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -911,25 +911,49 @@ PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info) void PackageInfo::ClearScreenshots() { - if (!fScreenshots.IsEmpty()) { - fScreenshots.Clear(); + if (!fScreenshots.empty()) { + fScreenshots.clear(); _NotifyListeners(PKG_CHANGED_SCREENSHOTS); } } +bool +PackageInfo::_HasScreenshot(const BitmapRef& screenshot) +{ + std::vector::iterator it = std::find( + fScreenshots.begin(), fScreenshots.end(), screenshot); + return it != fScreenshots.end(); +} + + bool PackageInfo::AddScreenshot(const BitmapRef& screenshot) { - if (!fScreenshots.Add(screenshot)) + if (_HasScreenshot(screenshot)) return false; + fScreenshots.push_back(screenshot); _NotifyListeners(PKG_CHANGED_SCREENSHOTS); return true; } +int32 +PackageInfo::CountScreenshots() const +{ + return fScreenshots.size(); +} + + +const BitmapRef +PackageInfo::ScreenshotAtIndex(int32 index) const +{ + return fScreenshots[index]; +} + + void PackageInfo::SetSize(int64 size) { diff --git a/src/apps/haikudepot/model/PackageInfo.h b/src/apps/haikudepot/model/PackageInfo.h index 0c10686a2c..df59c11964 100644 --- a/src/apps/haikudepot/model/PackageInfo.h +++ b/src/apps/haikudepot/model/PackageInfo.h @@ -329,8 +329,8 @@ public: void ClearScreenshots(); bool AddScreenshot(const BitmapRef& screenshot); - const BitmapList& Screenshots() const - { return fScreenshots; } + int32 CountScreenshots() const; + const BitmapRef ScreenshotAtIndex(int32 index) const; void SetSize(int64 size); int64 Size() const @@ -353,6 +353,8 @@ private: void _NotifyListeners(uint32 changes); void _NotifyListenersImmediate(uint32 changes); + bool _HasScreenshot(const BitmapRef& screenshot); + private: BString fName; BString fTitle; @@ -368,7 +370,8 @@ private: RatingSummary fCachedRatingSummary; int64 fProminence; ScreenshotInfoList fScreenshotInfos; - BitmapList fScreenshots; + std::vector + fScreenshots; PackageState fState; PackageInstallationLocationSet fInstallationLocations; diff --git a/src/apps/haikudepot/server/WebAppInterface.cpp b/src/apps/haikudepot/server/WebAppInterface.cpp index 62ecf2fcef..0828437e55 100644 --- a/src/apps/haikudepot/server/WebAppInterface.cpp +++ b/src/apps/haikudepot/server/WebAppInterface.cpp @@ -21,7 +21,6 @@ #include "DataIOUtils.h" #include "HaikuDepotConstants.h" -#include "List.h" #include "Logger.h" #include "ServerSettings.h" #include "ServerHelper.h" diff --git a/src/apps/haikudepot/server/WebAppInterface.h b/src/apps/haikudepot/server/WebAppInterface.h index 5692211b42..d36adcfcc7 100644 --- a/src/apps/haikudepot/server/WebAppInterface.h +++ b/src/apps/haikudepot/server/WebAppInterface.h @@ -12,7 +12,6 @@ #include #include -#include "List.h" #include "UserCredentials.h" #include "UserDetail.h" #include "UserUsageConditions.h" diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index 55d81829da..925d191e74 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -823,15 +823,21 @@ public: fWebsiteIconView->SetBitmap(&fWebsiteIcon, BITMAP_SIZE_16); _SetContactInfo(fWebsiteLinkView, package.Publisher().Website()); + int32 countScreenshots = package.CountScreenshots(); bool hasScreenshot = false; - const BitmapList& screenShots = package.Screenshots(); - if (screenShots.CountItems() > 0) { - const BitmapRef& bitmapRef = screenShots.ItemAtFast(0); + if (countScreenshots > 0) { + const BitmapRef& bitmapRef = package.ScreenshotAtIndex(0); if (bitmapRef.Get() != NULL) { + HDDEBUG("did find screenshot for package [%s]", + package.Name().String()); hasScreenshot = true; fScreenshotView->SetBitmap(bitmapRef); } } + else { + HDTRACE("did not find screenshots for package [%s]", + package.Name().String()); + } if (!hasScreenshot) fScreenshotView->UnsetBitmap(); diff --git a/src/apps/haikudepot/ui_generic/SharedBitmap.h b/src/apps/haikudepot/ui_generic/SharedBitmap.h index 52f6c2af8b..3ed7c4cd4f 100644 --- a/src/apps/haikudepot/ui_generic/SharedBitmap.h +++ b/src/apps/haikudepot/ui_generic/SharedBitmap.h @@ -11,7 +11,6 @@ #include #include "HaikuDepotConstants.h" -#include "List.h" class BBitmap; @@ -55,7 +54,6 @@ private: typedef BReference BitmapRef; -typedef List BitmapList; #endif // SHARED_BITMAP_H