[haiku-commits] haiku: hrev46126 - src/apps/haiku-depot

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 29 Sep 2013 11:43:05 +0200 (CEST)

hrev46126 adds 1 changeset to branch 'master'
old head: 735ec4c01829f7acdb91486188e60f57fcf1f047
new head: cb67ac016364dc1ed7d947d52d9388f51bb9f086
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=cb67ac0+%5E735ec4c

----------------------------------------------------------------------------

cb67ac0: HaikuDepot: Avoid showing ugly rating info when there are no ratings.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46126
Commit:      cb67ac016364dc1ed7d947d52d9388f51bb9f086
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cb67ac0
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Sep 29 09:41:24 2013 UTC

----------------------------------------------------------------------------

1 file changed, 16 insertions(+), 11 deletions(-)
src/apps/haiku-depot/PackageInfoView.cpp | 27 ++++++++++++++++-----------

----------------------------------------------------------------------------

diff --git a/src/apps/haiku-depot/PackageInfoView.cpp 
b/src/apps/haiku-depot/PackageInfoView.cpp
index fe41690..bcb573a 100644
--- a/src/apps/haiku-depot/PackageInfoView.cpp
+++ b/src/apps/haiku-depot/PackageInfoView.cpp
@@ -442,17 +442,22 @@ public:
 
                fRatingView->SetRating(ratingSummary.averageRating);
 
-               BString avgRating;
-               avgRating.SetToFormat("%.1f", ratingSummary.averageRating);
-               fAvgRating->SetText(avgRating);
-
-               BString votes;
-               votes.SetToFormat("%d", ratingSummary.ratingCount);
-
-               BString voteInfo(B_TRANSLATE("(%Votes%)"));
-               voteInfo.ReplaceAll("%Votes%", votes);
-
-               fVoteInfo->SetText(voteInfo);
+               if (ratingSummary.ratingCount > 0) {
+                       BString avgRating;
+                       avgRating.SetToFormat("%.1f", 
ratingSummary.averageRating);
+                       fAvgRating->SetText(avgRating);
+       
+                       BString votes;
+                       votes.SetToFormat("%d", ratingSummary.ratingCount);
+       
+                       BString voteInfo(B_TRANSLATE("(%Votes%)"));
+                       voteInfo.ReplaceAll("%Votes%", votes);
+
+                       fVoteInfo->SetText(voteInfo);
+               } else {
+                       fAvgRating->SetText("");
+                       fVoteInfo->SetText(B_TRANSLATE("n/a"));
+               }
 
                InvalidateLayout();
                Invalidate();


Other related posts:

  • » [haiku-commits] haiku: hrev46126 - src/apps/haiku-depot - superstippi