HaikuDepot: Screenshot List
Remove the use of custom list class related to screenshots on a package. Relates To #15534 Change-Id: I8289c25ef0ab5a6715dd9c6c83b6602a25d2f544 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3549 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
8fe17af9a7
commit
cb8472235b
@ -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<BitmapRef>::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)
|
||||
{
|
||||
|
@ -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<BitmapRef>
|
||||
fScreenshots;
|
||||
PackageState fState;
|
||||
PackageInstallationLocationSet
|
||||
fInstallationLocations;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "DataIOUtils.h"
|
||||
#include "HaikuDepotConstants.h"
|
||||
#include "List.h"
|
||||
#include "Logger.h"
|
||||
#include "ServerSettings.h"
|
||||
#include "ServerHelper.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <String.h>
|
||||
#include <package/PackageVersion.h>
|
||||
|
||||
#include "List.h"
|
||||
#include "UserCredentials.h"
|
||||
#include "UserDetail.h"
|
||||
#include "UserUsageConditions.h"
|
||||
|
@ -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();
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <String.h>
|
||||
|
||||
#include "HaikuDepotConstants.h"
|
||||
#include "List.h"
|
||||
|
||||
|
||||
class BBitmap;
|
||||
@ -55,7 +54,6 @@ private:
|
||||
|
||||
|
||||
typedef BReference<SharedBitmap> BitmapRef;
|
||||
typedef List<BitmapRef, false> BitmapList;
|
||||
|
||||
|
||||
#endif // SHARED_BITMAP_H
|
||||
|
Loading…
Reference in New Issue
Block a user