HaikuDepot: Added the notion of package categories
* Defined PackageCategory class (icon, label and internal name) * Each PackageInfo has a list of PackageCategories * Model defines global PackageCategories, referenced by PackageInfos * Added Model.cpp to files needing translation * Added categories to dummy package infos
This commit is contained in:
@@ -24,6 +24,7 @@ DoCatalogs HaikuDepot :
|
||||
App.cpp
|
||||
FilterView.cpp
|
||||
MainWindow.cpp
|
||||
Model.cpp
|
||||
PackageInfoView.cpp
|
||||
PackageListView.cpp
|
||||
PackageManager.cpp
|
||||
|
||||
@@ -175,6 +175,8 @@ MainWindow::_InitDummyModel()
|
||||
);
|
||||
wonderbrush.AddScreenshot(
|
||||
BitmapRef(new SharedBitmap(603), true));
|
||||
wonderbrush.AddCategory(fModel.CategoryGraphics());
|
||||
wonderbrush.AddCategory(fModel.CategoryProductivity());
|
||||
|
||||
depot.AddPackage(wonderbrush);
|
||||
|
||||
@@ -210,6 +212,8 @@ MainWindow::_InitDummyModel()
|
||||
);
|
||||
paladin.AddScreenshot(
|
||||
BitmapRef(new SharedBitmap(604), true));
|
||||
paladin.AddCategory(fModel.CategoryDevelopment());
|
||||
|
||||
depot.AddPackage(paladin);
|
||||
|
||||
fModel.AddDepot(depot);
|
||||
|
||||
@@ -7,11 +7,36 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Model"
|
||||
|
||||
|
||||
Model::Model()
|
||||
:
|
||||
fSearchTerms(),
|
||||
fDepots()
|
||||
fDepots(),
|
||||
|
||||
fCategoryAudio(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Audio"), "audio"), true),
|
||||
fCategoryVideo(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Video"), "video"), true),
|
||||
fCategoryGraphics(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Graphics"), "graphics"), true),
|
||||
fCategoryProductivity(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Productivity"), "productivity"), true),
|
||||
fCategoryDevelopment(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Development"), "development"), true),
|
||||
fCategoryCommandLine(new PackageCategory(
|
||||
BitmapRef(),
|
||||
B_TRANSLATE("Command line"), "command-line"), true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,32 @@ public:
|
||||
|
||||
bool AddDepot(const DepotInfo& depot);
|
||||
|
||||
// Access to global categories
|
||||
const CategoryRef& CategoryAudio() const
|
||||
{ return fCategoryAudio; }
|
||||
const CategoryRef& CategoryVideo() const
|
||||
{ return fCategoryVideo; }
|
||||
const CategoryRef& CategoryGraphics() const
|
||||
{ return fCategoryGraphics; }
|
||||
const CategoryRef& CategoryProductivity() const
|
||||
{ return fCategoryProductivity; }
|
||||
const CategoryRef& CategoryDevelopment() const
|
||||
{ return fCategoryDevelopment; }
|
||||
const CategoryRef& CategoryCommandLine() const
|
||||
{ return fCategoryCommandLine; }
|
||||
|
||||
private:
|
||||
BString fSearchTerms;
|
||||
|
||||
DepotInfoList fDepots;
|
||||
|
||||
CategoryRef fCategoryAudio;
|
||||
CategoryRef fCategoryVideo;
|
||||
CategoryRef fCategoryGraphics;
|
||||
CategoryRef fCategoryProductivity;
|
||||
CategoryRef fCategoryDevelopment;
|
||||
CategoryRef fCategoryCommandLine;
|
||||
// TODO: More categories
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
SharedBitmap::SharedBitmap(BBitmap* bitmap)
|
||||
:
|
||||
BReferenceable(),
|
||||
fResourceID(-1),
|
||||
fMimeType()
|
||||
{
|
||||
@@ -33,6 +34,7 @@ SharedBitmap::SharedBitmap(BBitmap* bitmap)
|
||||
|
||||
SharedBitmap::SharedBitmap(int32 resourceID)
|
||||
:
|
||||
BReferenceable(),
|
||||
fResourceID(resourceID),
|
||||
fMimeType()
|
||||
{
|
||||
@@ -44,6 +46,7 @@ SharedBitmap::SharedBitmap(int32 resourceID)
|
||||
|
||||
SharedBitmap::SharedBitmap(const char* mimeType)
|
||||
:
|
||||
BReferenceable(),
|
||||
fResourceID(-1),
|
||||
fMimeType(mimeType)
|
||||
{
|
||||
@@ -361,6 +364,65 @@ PublisherInfo::operator!=(const PublisherInfo& other) const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - PackageCategory
|
||||
|
||||
|
||||
PackageCategory::PackageCategory()
|
||||
:
|
||||
BReferenceable(),
|
||||
fIcon(),
|
||||
fName()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PackageCategory::PackageCategory(const BitmapRef& icon, const BString& label,
|
||||
const BString& name)
|
||||
:
|
||||
BReferenceable(),
|
||||
fIcon(icon),
|
||||
fLabel(label),
|
||||
fName(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PackageCategory::PackageCategory(const PackageCategory& other)
|
||||
:
|
||||
BReferenceable(),
|
||||
fIcon(other.fIcon),
|
||||
fLabel(other.fLabel),
|
||||
fName(other.fName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PackageCategory&
|
||||
PackageCategory::operator=(const PackageCategory& other)
|
||||
{
|
||||
fIcon = other.fIcon;
|
||||
fName = other.fName;
|
||||
fLabel = other.fLabel;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageCategory::operator==(const PackageCategory& other) const
|
||||
{
|
||||
return fIcon == other.fIcon
|
||||
&& fLabel == other.fLabel
|
||||
&& fName == other.fName;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageCategory::operator!=(const PackageCategory& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - PackageInfo
|
||||
|
||||
|
||||
@@ -391,6 +453,7 @@ PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title,
|
||||
fShortDescription(shortDescription),
|
||||
fFullDescription(fullDescription),
|
||||
fChangelog(changelog),
|
||||
fCategories(),
|
||||
fUserRatings(),
|
||||
fScreenshots()
|
||||
{
|
||||
@@ -406,6 +469,7 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
||||
fShortDescription(other.fShortDescription),
|
||||
fFullDescription(other.fFullDescription),
|
||||
fChangelog(other.fChangelog),
|
||||
fCategories(other.fCategories),
|
||||
fUserRatings(other.fUserRatings),
|
||||
fScreenshots(other.fScreenshots)
|
||||
{
|
||||
@@ -422,6 +486,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
||||
fShortDescription = other.fShortDescription;
|
||||
fFullDescription = other.fFullDescription;
|
||||
fChangelog = other.fChangelog;
|
||||
fCategories = other.fCategories;
|
||||
fUserRatings = other.fUserRatings;
|
||||
fScreenshots = other.fScreenshots;
|
||||
return *this;
|
||||
@@ -438,6 +503,7 @@ PackageInfo::operator==(const PackageInfo& other) const
|
||||
&& fShortDescription == other.fShortDescription
|
||||
&& fFullDescription == other.fFullDescription
|
||||
&& fChangelog == other.fChangelog
|
||||
&& fCategories == other.fCategories
|
||||
&& fUserRatings == other.fUserRatings
|
||||
&& fScreenshots == other.fScreenshots;
|
||||
}
|
||||
@@ -450,6 +516,13 @@ PackageInfo::operator!=(const PackageInfo& other) const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddCategory(const CategoryRef& category)
|
||||
{
|
||||
return fCategories.Add(category);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddUserRating(const UserRating& rating)
|
||||
{
|
||||
|
||||
@@ -145,6 +145,35 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class PackageCategory : public BReferenceable {
|
||||
public:
|
||||
PackageCategory();
|
||||
PackageCategory(const BitmapRef& icon,
|
||||
const BString& label,
|
||||
const BString& name);
|
||||
PackageCategory(const PackageCategory& other);
|
||||
|
||||
PackageCategory& operator=(const PackageCategory& other);
|
||||
bool operator==(const PackageCategory& other) const;
|
||||
bool operator!=(const PackageCategory& other) const;
|
||||
|
||||
const BitmapRef& Icon() const
|
||||
{ return fIcon; }
|
||||
const BString& Label() const
|
||||
{ return fLabel; }
|
||||
const BString& Name() const
|
||||
{ return fName; }
|
||||
private:
|
||||
BitmapRef fIcon;
|
||||
BString fLabel;
|
||||
BString fName;
|
||||
};
|
||||
|
||||
|
||||
typedef BReference<PackageCategory> CategoryRef;
|
||||
typedef List<CategoryRef, false> CategoryList;
|
||||
|
||||
|
||||
class PackageInfo {
|
||||
public:
|
||||
PackageInfo();
|
||||
@@ -176,15 +205,16 @@ public:
|
||||
const BString& Changelog() const
|
||||
{ return fChangelog; }
|
||||
|
||||
bool AddUserRating(const UserRating& rating);
|
||||
bool AddCategory(const CategoryRef& category);
|
||||
const CategoryList& Categories() const
|
||||
{ return fCategories; }
|
||||
|
||||
bool AddUserRating(const UserRating& rating);
|
||||
const UserRatingList& UserRatings() const
|
||||
{ return fUserRatings; }
|
||||
|
||||
RatingSummary CalculateRatingSummary() const;
|
||||
|
||||
bool AddScreenshot(const BitmapRef& screenshot);
|
||||
|
||||
const BitmapList& Screenshots() const
|
||||
{ return fScreenshots; }
|
||||
|
||||
@@ -196,6 +226,7 @@ private:
|
||||
BString fShortDescription;
|
||||
BString fFullDescription;
|
||||
BString fChangelog;
|
||||
CategoryList fCategories;
|
||||
UserRatingList fUserRatings;
|
||||
BitmapList fScreenshots;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user