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:
parent
eb8e4edca5
commit
a60a23f886
@ -363,7 +363,9 @@ void
|
||||
MainWindow::_AdoptPackage(const PackageInfoRef& 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();
|
||||
if (rightsList.CountStrings() > 0)
|
||||
publisherName = rightsList.StringAt(0);
|
||||
modelInfo.SetTo(new(std::nothrow) PackageInfo(NULL,
|
||||
modelInfo.SetTo(new(std::nothrow) PackageInfo(
|
||||
repoPackageInfo.Name(),
|
||||
repoPackageInfo.Version().ToString(),
|
||||
PublisherInfo(BitmapRef(), publisherName,
|
||||
"", publisherURL), repoPackageInfo.Summary(),
|
||||
repoPackageInfo.Description(), "",
|
||||
repoPackageInfo.Description(),
|
||||
repoPackageInfo.Flags()),
|
||||
true);
|
||||
|
||||
|
@ -417,7 +417,7 @@ Model::SetShowDevelopPackages(bool show)
|
||||
|
||||
|
||||
void
|
||||
Model::PopulatePackage(const PackageInfoRef& package)
|
||||
Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
||||
{
|
||||
if (fPopulatedPackages.Contains(package))
|
||||
return;
|
||||
@ -439,59 +439,23 @@ Model::PopulatePackage(const PackageInfoRef& package)
|
||||
|
||||
fPopulatedPackages.Add(package);
|
||||
|
||||
if (package->Title() == "WonderBrush") {
|
||||
if (package->Title() == "wonderbrush") {
|
||||
|
||||
package->AddUserRating(
|
||||
UserRating(UserInfo("humdinger"), 4.5f,
|
||||
"Awesome!", "en", "2.1.2", 0, 0)
|
||||
);
|
||||
package->AddUserRating(
|
||||
UserRating(UserInfo("bonefish"), 5.0f,
|
||||
"The best!", "en", "2.1.2", 3, 1)
|
||||
);
|
||||
package->AddScreenshot(
|
||||
BitmapRef(new SharedBitmap(603), true));
|
||||
if ((flags & POPULATE_CATEGORIES) != 0) {
|
||||
package->AddCategory(CategoryGraphics());
|
||||
package->AddCategory(CategoryProductivity());
|
||||
}
|
||||
|
||||
} else if (package->Title() == "Paladin") {
|
||||
|
||||
package->AddUserRating(
|
||||
UserRating(UserInfo("stippi"), 3.5f,
|
||||
"Could be more integrated from the sounds of it.",
|
||||
"en", "1.2.0", 0, 1)
|
||||
);
|
||||
package->AddUserRating(
|
||||
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)
|
||||
);
|
||||
if ((flags & POPULATE_USER_RATINGS) != 0) {
|
||||
package->AddUserRating(
|
||||
UserRating(UserInfo("binky"), 4.5f,
|
||||
"Awesome!", "en", "2.1.2", 0, 0)
|
||||
);
|
||||
package->AddUserRating(
|
||||
UserRating(UserInfo("twinky"), 5.0f,
|
||||
"The best!", "en", "2.1.2", 3, 1)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,15 @@ public:
|
||||
{ return fShowDevelopPackages; }
|
||||
|
||||
// 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:
|
||||
BLocker fLock;
|
||||
|
@ -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& shortDescription, const BString& fullDescription,
|
||||
const BString& changelog, int32 flags)
|
||||
int32 flags)
|
||||
:
|
||||
fIcon(icon),
|
||||
fIcon(),
|
||||
fTitle(title),
|
||||
fVersion(version),
|
||||
fPublisher(publisher),
|
||||
fShortDescription(shortDescription),
|
||||
fFullDescription(fullDescription),
|
||||
fChangelog(changelog),
|
||||
fChangelog(),
|
||||
fCategories(),
|
||||
fUserRatings(),
|
||||
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
|
||||
PackageInfo::IsSystemPackage() const
|
||||
{
|
||||
@ -559,7 +579,11 @@ PackageInfo::IsSystemPackage() const
|
||||
bool
|
||||
PackageInfo::AddCategory(const CategoryRef& category)
|
||||
{
|
||||
return fCategories.Add(category);
|
||||
if (fCategories.Add(category)) {
|
||||
_NotifyListeners(PKG_CHANGED_CATEGORIES);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,13 +199,12 @@ enum PackageState {
|
||||
class PackageInfo : public BReferenceable {
|
||||
public:
|
||||
PackageInfo();
|
||||
PackageInfo(const BitmapRef& icon,
|
||||
PackageInfo(
|
||||
const BString& title,
|
||||
const BString& version,
|
||||
const PublisherInfo& publisher,
|
||||
const BString& shortDescription,
|
||||
const BString& fullDescription,
|
||||
const BString& changelog,
|
||||
int32 packageFlags);
|
||||
PackageInfo(const PackageInfo& other);
|
||||
|
||||
@ -213,8 +212,6 @@ public:
|
||||
bool operator==(const PackageInfo& other) const;
|
||||
bool operator!=(const PackageInfo& other) const;
|
||||
|
||||
const BitmapRef& Icon() const
|
||||
{ return fIcon; }
|
||||
const BString& Title() const
|
||||
{ return fTitle; }
|
||||
const BString& Version() const
|
||||
@ -225,6 +222,11 @@ public:
|
||||
{ return fFullDescription; }
|
||||
const PublisherInfo& Publisher() const
|
||||
{ return fPublisher; }
|
||||
|
||||
void SetIcon(const BitmapRef& icon);
|
||||
const BitmapRef& Icon() const
|
||||
{ return fIcon; }
|
||||
void SetChangelog(const BString& changelog);
|
||||
const BString& Changelog() const
|
||||
{ return fChangelog; }
|
||||
|
||||
|
@ -13,7 +13,10 @@ enum {
|
||||
PKG_CHANGED_DESCRIPTION = 1 << 0,
|
||||
PKG_CHANGED_RATINGS = 1 << 1,
|
||||
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
|
||||
// ...
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user