[haiku-commits] haiku: hrev47953 - src/apps/haikudepot/ui

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 2 Oct 2014 21:39:08 +0200 (CEST)

hrev47953 adds 1 changeset to branch 'master'
old head: c881fc09b0da2e8a5db06733e9298819193a3fb6
new head: b7b31be4004fdc9b32ec060451d9686a6fcb2ee4
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=b7b31be+%5Ec881fc0

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

b7b31be: HaikuDepot: Filter ratings by preferred languages
  
  Show only those user ratings which are in one of the
  languages configured in the Locale preflet's preferred
  languages list.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

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

Revision:    hrev47953
Commit:      b7b31be4004fdc9b32ec060451d9686a6fcb2ee4
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b7b31be
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Thu Oct  2 19:39:55 2014 UTC

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

1 file changed, 31 insertions(+), 2 deletions(-)
src/apps/haikudepot/ui/PackageInfoView.cpp | 33 ++++++++++++++++++++++++--

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

diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp 
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 8c492c5..1277978 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -18,6 +18,7 @@
 #include <GridView.h>
 #include <LayoutBuilder.h>
 #include <LayoutUtils.h>
+#include <LocaleRoster.h>
 #include <Message.h>
 #include <TabView.h>
 #include <ScrollView.h>
@@ -1171,6 +1172,8 @@ public:
                        .Add(scrollView, 1.0f)
                        .SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
                ;
+       
+               _InitPreferredLanguages();
        }
 
        virtual ~UserRatingsView()
@@ -1200,10 +1203,12 @@ public:
                }
 
                // TODO: Sort by age or usefullness rating
-               // TODO: Optionally hide ratings that are not in the system 
language
-
                for (int i = count - 1; i >= 0; i--) {
                        const UserRating& rating = userRatings.ItemAtFast(i);
+                       if (fPreferredLanguages.CountItems() > 0
+                               && 
!fPreferredLanguages.Contains(rating.Language())) {
+                               continue;
+                       }
                        RatingItemView* view = new RatingItemView(rating, 
fThumbsUpIcon,
                                fThumbsDownIcon);
                        fRatingContainerLayout->AddView(0, view);
@@ -1231,10 +1236,34 @@ public:
        }
 
 private:
+       void _InitPreferredLanguages()
+       {
+               fPreferredLanguages.Clear();
+
+               BLocaleRoster* localeRoster = BLocaleRoster::Default();
+               if (localeRoster == NULL)
+                       return;
+
+               BMessage preferredLanguages;
+               if (localeRoster->GetPreferredLanguages(&preferredLanguages) != 
B_OK) 
+                       return;
+
+               BString language;
+               int32 index = 0;
+               while (preferredLanguages.FindString("language", index++,
+                               &language) == B_OK) {
+                       BString languageCode;
+                       language.CopyInto(languageCode, 0, 2);
+                               fPreferredLanguages.Add(languageCode);
+               }
+       }
+
+private:
        BGroupLayout*                   fRatingContainerLayout;
        RatingSummaryView*              fRatingSummaryView;
        BitmapRef                               fThumbsUpIcon;
        BitmapRef                               fThumbsDownIcon;
+       StringList                              fPreferredLanguages;
 };
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev47953 - src/apps/haikudepot/ui - superstippi