diff --git a/src/apps/haikudepot/HaikuDepotConstants.h b/src/apps/haikudepot/HaikuDepotConstants.h index ec701da93b..0fdeb11386 100644 --- a/src/apps/haikudepot/HaikuDepotConstants.h +++ b/src/apps/haikudepot/HaikuDepotConstants.h @@ -98,9 +98,14 @@ enum UserUsageConditionsSelectionMode { #define STR_MDASH "\xE2\x80\x94" -#define ALERT_MSG_LOGS_USER_GUIDE "\nInformation about how to view the logs is " \ - "available in the HaikuDepot section of the user guide." +#define ALERT_MSG_LOGS_USER_GUIDE "\nInformation about how to view the logs " \ + "is available in the HaikuDepot section of the user guide." #define CACHE_DIRECTORY_APP "HaikuDepot" +#define PROMINANCE_ORDERING_PROMINENT_MAX 200 + // any prominence ordering value greater than this is not prominent. +#define PROMINANCE_ORDERING_MAX 1000 + // this is the highest prominence value possible. + #endif // HAIKU_DEPOT_CONSTANTS_H \ No newline at end of file diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index ebb56d947c..773ab61bf6 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -241,8 +241,8 @@ public: if (package.Get() == NULL) return false; // Every search term must be found in one of the package texts - for (int32 i = fSearchTerms.CountItems() - 1; i >= 0; i--) { - const BString& term = fSearchTerms.ItemAtFast(i); + for (int32 i = fSearchTerms.CountStrings() - 1; i >= 0; i--) { + const BString& term = fSearchTerms.StringAt(i); if (!_TextContains(package->Name(), term) && !_TextContains(package->Title(), term) && !_TextContains(package->Publisher().Name(), term) @@ -257,8 +257,8 @@ public: BString SearchTerms() const { BString searchTerms; - for (int32 i = 0; i < fSearchTerms.CountItems(); i++) { - const BString& term = fSearchTerms.ItemAtFast(i); + for (int32 i = 0; i < fSearchTerms.CountStrings(); i++) { + const BString& term = fSearchTerms.StringAt(i); if (term.IsEmpty()) continue; if (!searchTerms.IsEmpty()) @@ -277,7 +277,7 @@ private: } private: - StringList fSearchTerms; + BStringList fSearchTerms; }; diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index 96a724dc04..cb7b25489b 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -883,7 +883,7 @@ PackageInfo::CalculateRatingSummary() const void -PackageInfo::SetProminence(float prominence) +PackageInfo::SetProminence(int64 prominence) { if (fProminence != prominence) { fProminence = prominence; @@ -895,7 +895,7 @@ PackageInfo::SetProminence(float prominence) bool PackageInfo::IsProminent() const { - return HasProminence() && Prominence() <= 200; + return HasProminence() && Prominence() <= PROMINANCE_ORDERING_PROMINENT_MAX; } diff --git a/src/apps/haikudepot/model/PackageInfo.h b/src/apps/haikudepot/model/PackageInfo.h index fb74afa57d..af6773ea6a 100644 --- a/src/apps/haikudepot/model/PackageInfo.h +++ b/src/apps/haikudepot/model/PackageInfo.h @@ -333,11 +333,11 @@ public: void SetRatingSummary(const RatingSummary& summary); RatingSummary CalculateRatingSummary() const; - void SetProminence(float prominence); - float Prominence() const + void SetProminence(int64 prominence); + int64 Prominence() const { return fProminence; } bool HasProminence() const - { return fProminence != 0.0f; } + { return fProminence != 0; } bool IsProminent() const; void ClearScreenshotInfos(); @@ -383,7 +383,7 @@ private: CategoryList fCategories; UserRatingList fUserRatings; RatingSummary fCachedRatingSummary; - float fProminence; + int64 fProminence; ScreenshotInfoList fScreenshotInfos; BitmapList fScreenshots; PackageState fState; @@ -461,7 +461,4 @@ private: typedef List DepotList; -typedef List StringList; - - #endif // PACKAGE_INFO_H diff --git a/src/apps/haikudepot/server/WebAppInterface.h b/src/apps/haikudepot/server/WebAppInterface.h index 38f10c35ac..5692211b42 100644 --- a/src/apps/haikudepot/server/WebAppInterface.h +++ b/src/apps/haikudepot/server/WebAppInterface.h @@ -22,8 +22,6 @@ class BDataIO; class BMessage; using BPackageKit::BPackageVersion; -typedef List StringList; - /*! These are error codes that are sent back to the client from the server */ diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index eed6702a4b..854d88f3e8 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -224,6 +224,20 @@ public: } + static int _CmpProminences(int64 a, int64 b) + { + if (a <= 0) + a = PROMINANCE_ORDERING_MAX; + if (b <= 0) + b = PROMINANCE_ORDERING_MAX; + if (a == b) + return 0; + if (a > b) + return 1; + return -1; + } + + /*! This method will return true if the packageA is ordered before packageB. */ @@ -233,12 +247,15 @@ public: { if (packageA.Get() == NULL || packageB.Get() == NULL) debugger("unexpected NULL reference in a referencable"); - int c = packageA->Title().ICompare(packageB->Title()); + int c = _CmpProminences(packageA->Prominence(), packageB->Prominence()); + if (c == 0) + c = packageA->Title().ICompare(packageB->Title()); if (c == 0) c = packageA->Name().Compare(packageB->Name()); return c < 0; } + void AddPackage(const PackageInfoRef& package) { // fPackages is sorted and for this reason it is possible to find the