HaikuDepot: Clean up how PackageInfo is populated

* Remove the stuff from constructor, which cannot be known at the time
   (icon and changelog).
 * Added setters for those and notification handling (not yet in the
   listeners).
 * Add more PackageInfoListener flags.
 * Populate categories and dummy user ratings for "wonderbrush". This
   code was still in from testing, but the package name is actually
   different in real PM.
This commit is contained in:
Stephan Aßmus
2013-12-10 22:36:48 +01:00
parent eb8e4edca5
commit a60a23f886
6 changed files with 69 additions and 66 deletions
+5 -3
View File
@@ -363,7 +363,9 @@ void
MainWindow::_AdoptPackage(const PackageInfoRef& package) MainWindow::_AdoptPackage(const PackageInfoRef& package)
{ {
fPackageInfoView->SetPackage(package); fPackageInfoView->SetPackage(package);
fModel.PopulatePackage(package); fModel.PopulatePackage(package,
Model::POPULATE_USER_RATINGS | Model::POPULATE_SCREEN_SHOTS
| Model::POPULATE_CHANGELOG | Model::POPULATE_CATEGORIES);
} }
@@ -501,12 +503,12 @@ MainWindow::_RefreshPackageList()
BString publisherName = repoPackageInfo.Vendor(); BString publisherName = repoPackageInfo.Vendor();
if (rightsList.CountStrings() > 0) if (rightsList.CountStrings() > 0)
publisherName = rightsList.StringAt(0); publisherName = rightsList.StringAt(0);
modelInfo.SetTo(new(std::nothrow) PackageInfo(NULL, modelInfo.SetTo(new(std::nothrow) PackageInfo(
repoPackageInfo.Name(), repoPackageInfo.Name(),
repoPackageInfo.Version().ToString(), repoPackageInfo.Version().ToString(),
PublisherInfo(BitmapRef(), publisherName, PublisherInfo(BitmapRef(), publisherName,
"", publisherURL), repoPackageInfo.Summary(), "", publisherURL), repoPackageInfo.Summary(),
repoPackageInfo.Description(), "", repoPackageInfo.Description(),
repoPackageInfo.Flags()), repoPackageInfo.Flags()),
true); true);
+16 -52
View File
@@ -417,7 +417,7 @@ Model::SetShowDevelopPackages(bool show)
void void
Model::PopulatePackage(const PackageInfoRef& package) Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
{ {
if (fPopulatedPackages.Contains(package)) if (fPopulatedPackages.Contains(package))
return; return;
@@ -439,59 +439,23 @@ Model::PopulatePackage(const PackageInfoRef& package)
fPopulatedPackages.Add(package); fPopulatedPackages.Add(package);
if (package->Title() == "WonderBrush") { if (package->Title() == "wonderbrush") {
package->AddUserRating( if ((flags & POPULATE_CATEGORIES) != 0) {
UserRating(UserInfo("humdinger"), 4.5f, package->AddCategory(CategoryGraphics());
"Awesome!", "en", "2.1.2", 0, 0) package->AddCategory(CategoryProductivity());
); }
package->AddUserRating(
UserRating(UserInfo("bonefish"), 5.0f,
"The best!", "en", "2.1.2", 3, 1)
);
package->AddScreenshot(
BitmapRef(new SharedBitmap(603), true));
} else if (package->Title() == "Paladin") { if ((flags & POPULATE_USER_RATINGS) != 0) {
package->AddUserRating(
package->AddUserRating( UserRating(UserInfo("binky"), 4.5f,
UserRating(UserInfo("stippi"), 3.5f, "Awesome!", "en", "2.1.2", 0, 0)
"Could be more integrated from the sounds of it.", );
"en", "1.2.0", 0, 1) package->AddUserRating(
); UserRating(UserInfo("twinky"), 5.0f,
package->AddUserRating( "The best!", "en", "2.1.2", 3, 1)
UserRating(UserInfo("mmadia"), 5.0f, );
"It rocks! Give a try", }
"en", "1.1.0", 1, 0)
);
package->AddUserRating(
UserRating(UserInfo("bonefish"), 2.0f,
"It just needs to use my jam-rewrite 'ham' and it will be great.",
"en", "1.1.0", 3, 1)
);
package->AddScreenshot(
BitmapRef(new SharedBitmap(605), true));
} else if (package->Title() == "Sequitur") {
package->AddUserRating(
UserRating(UserInfo("pete"), 4.5f,
"I can weave a web of sound! And it connects to PatchBay. Check "
"it out, I can wholeheartly recommend this app!! This rating "
"comment is of course only so long, because the new TextView "
"layout needs some testing. Oh, and did I mention it works with "
"custom installed sound fonts? Reading through this comment I find "
"that I did not until now. Hopefully there are enough lines now to "
"please the programmer with the text layouting and scrolling of "
"long ratings!", "en", "2.1.0", 4, 1)
);
package->AddUserRating(
UserRating(UserInfo("stippi"), 3.5f,
"It seems very capable. Still runs fine on Haiku. The interface "
"is composed of many small, hard to click items. But you can "
"configure a tool for each mouse button, which is great for the "
"work flow.", "en", "2.1.0", 2, 1)
);
} }
} }
+9 -1
View File
@@ -76,7 +76,15 @@ public:
{ return fShowDevelopPackages; } { return fShowDevelopPackages; }
// Retrieve package information // Retrieve package information
void PopulatePackage(const PackageInfoRef& package); static const uint32 POPULATE_CACHED_RATING = 1 << 0;
static const uint32 POPULATE_CACHED_ICON = 1 << 1;
static const uint32 POPULATE_USER_RATINGS = 1 << 2;
static const uint32 POPULATE_SCREEN_SHOTS = 1 << 3;
static const uint32 POPULATE_CHANGELOG = 1 << 4;
static const uint32 POPULATE_CATEGORIES = 1 << 5;
void PopulatePackage(const PackageInfoRef& package,
uint32 flags);
private: private:
BLocker fLock; BLocker fLock;
+29 -5
View File
@@ -456,18 +456,18 @@ PackageInfo::PackageInfo()
} }
PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title, PackageInfo::PackageInfo(const BString& title,
const BString& version, const PublisherInfo& publisher, const BString& version, const PublisherInfo& publisher,
const BString& shortDescription, const BString& fullDescription, const BString& shortDescription, const BString& fullDescription,
const BString& changelog, int32 flags) int32 flags)
: :
fIcon(icon), fIcon(),
fTitle(title), fTitle(title),
fVersion(version), fVersion(version),
fPublisher(publisher), fPublisher(publisher),
fShortDescription(shortDescription), fShortDescription(shortDescription),
fFullDescription(fullDescription), fFullDescription(fullDescription),
fChangelog(changelog), fChangelog(),
fCategories(), fCategories(),
fUserRatings(), fUserRatings(),
fScreenshots(), fScreenshots(),
@@ -549,6 +549,26 @@ PackageInfo::operator!=(const PackageInfo& other) const
} }
void
PackageInfo::SetIcon(const BitmapRef& icon)
{
if (fIcon != icon) {
fIcon = icon;
_NotifyListeners(PKG_CHANGED_ICON);
}
}
void
PackageInfo::SetChangelog(const BString& changelog)
{
if (fChangelog != changelog) {
fChangelog = changelog;
_NotifyListeners(PKG_CHANGED_CHANGELOG);
}
}
bool bool
PackageInfo::IsSystemPackage() const PackageInfo::IsSystemPackage() const
{ {
@@ -559,7 +579,11 @@ PackageInfo::IsSystemPackage() const
bool bool
PackageInfo::AddCategory(const CategoryRef& category) PackageInfo::AddCategory(const CategoryRef& category)
{ {
return fCategories.Add(category); if (fCategories.Add(category)) {
_NotifyListeners(PKG_CHANGED_CATEGORIES);
return true;
}
return false;
} }
+6 -4
View File
@@ -199,13 +199,12 @@ enum PackageState {
class PackageInfo : public BReferenceable { class PackageInfo : public BReferenceable {
public: public:
PackageInfo(); PackageInfo();
PackageInfo(const BitmapRef& icon, PackageInfo(
const BString& title, const BString& title,
const BString& version, const BString& version,
const PublisherInfo& publisher, const PublisherInfo& publisher,
const BString& shortDescription, const BString& shortDescription,
const BString& fullDescription, const BString& fullDescription,
const BString& changelog,
int32 packageFlags); int32 packageFlags);
PackageInfo(const PackageInfo& other); PackageInfo(const PackageInfo& other);
@@ -213,8 +212,6 @@ public:
bool operator==(const PackageInfo& other) const; bool operator==(const PackageInfo& other) const;
bool operator!=(const PackageInfo& other) const; bool operator!=(const PackageInfo& other) const;
const BitmapRef& Icon() const
{ return fIcon; }
const BString& Title() const const BString& Title() const
{ return fTitle; } { return fTitle; }
const BString& Version() const const BString& Version() const
@@ -225,6 +222,11 @@ public:
{ return fFullDescription; } { return fFullDescription; }
const PublisherInfo& Publisher() const const PublisherInfo& Publisher() const
{ return fPublisher; } { return fPublisher; }
void SetIcon(const BitmapRef& icon);
const BitmapRef& Icon() const
{ return fIcon; }
void SetChangelog(const BString& changelog);
const BString& Changelog() const const BString& Changelog() const
{ return fChangelog; } { return fChangelog; }
+4 -1
View File
@@ -13,7 +13,10 @@ enum {
PKG_CHANGED_DESCRIPTION = 1 << 0, PKG_CHANGED_DESCRIPTION = 1 << 0,
PKG_CHANGED_RATINGS = 1 << 1, PKG_CHANGED_RATINGS = 1 << 1,
PKG_CHANGED_SCREENSHOTS = 1 << 2, PKG_CHANGED_SCREENSHOTS = 1 << 2,
PKG_CHANGED_STATE = 1 << 3 PKG_CHANGED_STATE = 1 << 3,
PKG_CHANGED_ICON = 1 << 4,
PKG_CHANGED_CHANGELOG = 1 << 5,
PKG_CHANGED_CATEGORIES = 1 << 6
// ... // ...
}; };