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 <[email protected]>
This commit is contained in:
@@ -911,25 +911,49 @@ PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info)
|
|||||||
void
|
void
|
||||||
PackageInfo::ClearScreenshots()
|
PackageInfo::ClearScreenshots()
|
||||||
{
|
{
|
||||||
if (!fScreenshots.IsEmpty()) {
|
if (!fScreenshots.empty()) {
|
||||||
fScreenshots.Clear();
|
fScreenshots.clear();
|
||||||
_NotifyListeners(PKG_CHANGED_SCREENSHOTS);
|
_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
|
bool
|
||||||
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
||||||
{
|
{
|
||||||
if (!fScreenshots.Add(screenshot))
|
if (_HasScreenshot(screenshot))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
fScreenshots.push_back(screenshot);
|
||||||
_NotifyListeners(PKG_CHANGED_SCREENSHOTS);
|
_NotifyListeners(PKG_CHANGED_SCREENSHOTS);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
PackageInfo::CountScreenshots() const
|
||||||
|
{
|
||||||
|
return fScreenshots.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BitmapRef
|
||||||
|
PackageInfo::ScreenshotAtIndex(int32 index) const
|
||||||
|
{
|
||||||
|
return fScreenshots[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageInfo::SetSize(int64 size)
|
PackageInfo::SetSize(int64 size)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -329,8 +329,8 @@ public:
|
|||||||
|
|
||||||
void ClearScreenshots();
|
void ClearScreenshots();
|
||||||
bool AddScreenshot(const BitmapRef& screenshot);
|
bool AddScreenshot(const BitmapRef& screenshot);
|
||||||
const BitmapList& Screenshots() const
|
int32 CountScreenshots() const;
|
||||||
{ return fScreenshots; }
|
const BitmapRef ScreenshotAtIndex(int32 index) const;
|
||||||
|
|
||||||
void SetSize(int64 size);
|
void SetSize(int64 size);
|
||||||
int64 Size() const
|
int64 Size() const
|
||||||
@@ -353,6 +353,8 @@ private:
|
|||||||
void _NotifyListeners(uint32 changes);
|
void _NotifyListeners(uint32 changes);
|
||||||
void _NotifyListenersImmediate(uint32 changes);
|
void _NotifyListenersImmediate(uint32 changes);
|
||||||
|
|
||||||
|
bool _HasScreenshot(const BitmapRef& screenshot);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fName;
|
BString fName;
|
||||||
BString fTitle;
|
BString fTitle;
|
||||||
@@ -368,7 +370,8 @@ private:
|
|||||||
RatingSummary fCachedRatingSummary;
|
RatingSummary fCachedRatingSummary;
|
||||||
int64 fProminence;
|
int64 fProminence;
|
||||||
ScreenshotInfoList fScreenshotInfos;
|
ScreenshotInfoList fScreenshotInfos;
|
||||||
BitmapList fScreenshots;
|
std::vector<BitmapRef>
|
||||||
|
fScreenshots;
|
||||||
PackageState fState;
|
PackageState fState;
|
||||||
PackageInstallationLocationSet
|
PackageInstallationLocationSet
|
||||||
fInstallationLocations;
|
fInstallationLocations;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "DataIOUtils.h"
|
#include "DataIOUtils.h"
|
||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
#include "List.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "ServerSettings.h"
|
#include "ServerSettings.h"
|
||||||
#include "ServerHelper.h"
|
#include "ServerHelper.h"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <package/PackageVersion.h>
|
#include <package/PackageVersion.h>
|
||||||
|
|
||||||
#include "List.h"
|
|
||||||
#include "UserCredentials.h"
|
#include "UserCredentials.h"
|
||||||
#include "UserDetail.h"
|
#include "UserDetail.h"
|
||||||
#include "UserUsageConditions.h"
|
#include "UserUsageConditions.h"
|
||||||
|
|||||||
@@ -823,15 +823,21 @@ public:
|
|||||||
fWebsiteIconView->SetBitmap(&fWebsiteIcon, BITMAP_SIZE_16);
|
fWebsiteIconView->SetBitmap(&fWebsiteIcon, BITMAP_SIZE_16);
|
||||||
_SetContactInfo(fWebsiteLinkView, package.Publisher().Website());
|
_SetContactInfo(fWebsiteLinkView, package.Publisher().Website());
|
||||||
|
|
||||||
|
int32 countScreenshots = package.CountScreenshots();
|
||||||
bool hasScreenshot = false;
|
bool hasScreenshot = false;
|
||||||
const BitmapList& screenShots = package.Screenshots();
|
if (countScreenshots > 0) {
|
||||||
if (screenShots.CountItems() > 0) {
|
const BitmapRef& bitmapRef = package.ScreenshotAtIndex(0);
|
||||||
const BitmapRef& bitmapRef = screenShots.ItemAtFast(0);
|
|
||||||
if (bitmapRef.Get() != NULL) {
|
if (bitmapRef.Get() != NULL) {
|
||||||
|
HDDEBUG("did find screenshot for package [%s]",
|
||||||
|
package.Name().String());
|
||||||
hasScreenshot = true;
|
hasScreenshot = true;
|
||||||
fScreenshotView->SetBitmap(bitmapRef);
|
fScreenshotView->SetBitmap(bitmapRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
HDTRACE("did not find screenshots for package [%s]",
|
||||||
|
package.Name().String());
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasScreenshot)
|
if (!hasScreenshot)
|
||||||
fScreenshotView->UnsetBitmap();
|
fScreenshotView->UnsetBitmap();
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
#include "List.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
@@ -55,7 +54,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
typedef BReference<SharedBitmap> BitmapRef;
|
typedef BReference<SharedBitmap> BitmapRef;
|
||||||
typedef List<BitmapRef, false> BitmapList;
|
|
||||||
|
|
||||||
|
|
||||||
#endif // SHARED_BITMAP_H
|
#endif // SHARED_BITMAP_H
|
||||||
|
|||||||
Reference in New Issue
Block a user