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
|
App.cpp
|
||||||
FilterView.cpp
|
FilterView.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
|
Model.cpp
|
||||||
PackageInfoView.cpp
|
PackageInfoView.cpp
|
||||||
PackageListView.cpp
|
PackageListView.cpp
|
||||||
PackageManager.cpp
|
PackageManager.cpp
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ MainWindow::_InitDummyModel()
|
|||||||
);
|
);
|
||||||
wonderbrush.AddScreenshot(
|
wonderbrush.AddScreenshot(
|
||||||
BitmapRef(new SharedBitmap(603), true));
|
BitmapRef(new SharedBitmap(603), true));
|
||||||
|
wonderbrush.AddCategory(fModel.CategoryGraphics());
|
||||||
|
wonderbrush.AddCategory(fModel.CategoryProductivity());
|
||||||
|
|
||||||
depot.AddPackage(wonderbrush);
|
depot.AddPackage(wonderbrush);
|
||||||
|
|
||||||
@@ -210,6 +212,8 @@ MainWindow::_InitDummyModel()
|
|||||||
);
|
);
|
||||||
paladin.AddScreenshot(
|
paladin.AddScreenshot(
|
||||||
BitmapRef(new SharedBitmap(604), true));
|
BitmapRef(new SharedBitmap(604), true));
|
||||||
|
paladin.AddCategory(fModel.CategoryDevelopment());
|
||||||
|
|
||||||
depot.AddPackage(paladin);
|
depot.AddPackage(paladin);
|
||||||
|
|
||||||
fModel.AddDepot(depot);
|
fModel.AddDepot(depot);
|
||||||
|
|||||||
@@ -7,11 +7,36 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "Model"
|
||||||
|
|
||||||
|
|
||||||
Model::Model()
|
Model::Model()
|
||||||
:
|
:
|
||||||
fSearchTerms(),
|
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);
|
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:
|
private:
|
||||||
BString fSearchTerms;
|
BString fSearchTerms;
|
||||||
|
|
||||||
DepotInfoList fDepots;
|
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)
|
SharedBitmap::SharedBitmap(BBitmap* bitmap)
|
||||||
:
|
:
|
||||||
|
BReferenceable(),
|
||||||
fResourceID(-1),
|
fResourceID(-1),
|
||||||
fMimeType()
|
fMimeType()
|
||||||
{
|
{
|
||||||
@@ -33,6 +34,7 @@ SharedBitmap::SharedBitmap(BBitmap* bitmap)
|
|||||||
|
|
||||||
SharedBitmap::SharedBitmap(int32 resourceID)
|
SharedBitmap::SharedBitmap(int32 resourceID)
|
||||||
:
|
:
|
||||||
|
BReferenceable(),
|
||||||
fResourceID(resourceID),
|
fResourceID(resourceID),
|
||||||
fMimeType()
|
fMimeType()
|
||||||
{
|
{
|
||||||
@@ -44,6 +46,7 @@ SharedBitmap::SharedBitmap(int32 resourceID)
|
|||||||
|
|
||||||
SharedBitmap::SharedBitmap(const char* mimeType)
|
SharedBitmap::SharedBitmap(const char* mimeType)
|
||||||
:
|
:
|
||||||
|
BReferenceable(),
|
||||||
fResourceID(-1),
|
fResourceID(-1),
|
||||||
fMimeType(mimeType)
|
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
|
// #pragma mark - PackageInfo
|
||||||
|
|
||||||
|
|
||||||
@@ -391,6 +453,7 @@ PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title,
|
|||||||
fShortDescription(shortDescription),
|
fShortDescription(shortDescription),
|
||||||
fFullDescription(fullDescription),
|
fFullDescription(fullDescription),
|
||||||
fChangelog(changelog),
|
fChangelog(changelog),
|
||||||
|
fCategories(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fScreenshots()
|
fScreenshots()
|
||||||
{
|
{
|
||||||
@@ -406,6 +469,7 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
|||||||
fShortDescription(other.fShortDescription),
|
fShortDescription(other.fShortDescription),
|
||||||
fFullDescription(other.fFullDescription),
|
fFullDescription(other.fFullDescription),
|
||||||
fChangelog(other.fChangelog),
|
fChangelog(other.fChangelog),
|
||||||
|
fCategories(other.fCategories),
|
||||||
fUserRatings(other.fUserRatings),
|
fUserRatings(other.fUserRatings),
|
||||||
fScreenshots(other.fScreenshots)
|
fScreenshots(other.fScreenshots)
|
||||||
{
|
{
|
||||||
@@ -422,6 +486,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
|||||||
fShortDescription = other.fShortDescription;
|
fShortDescription = other.fShortDescription;
|
||||||
fFullDescription = other.fFullDescription;
|
fFullDescription = other.fFullDescription;
|
||||||
fChangelog = other.fChangelog;
|
fChangelog = other.fChangelog;
|
||||||
|
fCategories = other.fCategories;
|
||||||
fUserRatings = other.fUserRatings;
|
fUserRatings = other.fUserRatings;
|
||||||
fScreenshots = other.fScreenshots;
|
fScreenshots = other.fScreenshots;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -438,6 +503,7 @@ PackageInfo::operator==(const PackageInfo& other) const
|
|||||||
&& fShortDescription == other.fShortDescription
|
&& fShortDescription == other.fShortDescription
|
||||||
&& fFullDescription == other.fFullDescription
|
&& fFullDescription == other.fFullDescription
|
||||||
&& fChangelog == other.fChangelog
|
&& fChangelog == other.fChangelog
|
||||||
|
&& fCategories == other.fCategories
|
||||||
&& fUserRatings == other.fUserRatings
|
&& fUserRatings == other.fUserRatings
|
||||||
&& fScreenshots == other.fScreenshots;
|
&& fScreenshots == other.fScreenshots;
|
||||||
}
|
}
|
||||||
@@ -450,6 +516,13 @@ PackageInfo::operator!=(const PackageInfo& other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PackageInfo::AddCategory(const CategoryRef& category)
|
||||||
|
{
|
||||||
|
return fCategories.Add(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageInfo::AddUserRating(const UserRating& rating)
|
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 {
|
class PackageInfo {
|
||||||
public:
|
public:
|
||||||
PackageInfo();
|
PackageInfo();
|
||||||
@@ -176,15 +205,16 @@ public:
|
|||||||
const BString& Changelog() const
|
const BString& Changelog() const
|
||||||
{ return fChangelog; }
|
{ 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
|
const UserRatingList& UserRatings() const
|
||||||
{ return fUserRatings; }
|
{ return fUserRatings; }
|
||||||
|
|
||||||
RatingSummary CalculateRatingSummary() const;
|
RatingSummary CalculateRatingSummary() const;
|
||||||
|
|
||||||
bool AddScreenshot(const BitmapRef& screenshot);
|
bool AddScreenshot(const BitmapRef& screenshot);
|
||||||
|
|
||||||
const BitmapList& Screenshots() const
|
const BitmapList& Screenshots() const
|
||||||
{ return fScreenshots; }
|
{ return fScreenshots; }
|
||||||
|
|
||||||
@@ -196,6 +226,7 @@ private:
|
|||||||
BString fShortDescription;
|
BString fShortDescription;
|
||||||
BString fFullDescription;
|
BString fFullDescription;
|
||||||
BString fChangelog;
|
BString fChangelog;
|
||||||
|
CategoryList fCategories;
|
||||||
UserRatingList fUserRatings;
|
UserRatingList fUserRatings;
|
||||||
BitmapList fScreenshots;
|
BitmapList fScreenshots;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user