Commits

Aren Olson committed fc1c678

moving to storing ratings in a float from 0-100. Will break existing ratings,
though until they are reset the old values will remain in the db.

Comments (0)

Files changed (4)

 import os, time
 from copy import deepcopy
 from urlparse import urlparse
-from xl import common
+from xl import common, settings
 import xl.metadata as metadata
 from xl.common import lstrip_special
 import logging, traceback
 logger = logging.getLogger(__name__)
 
+settings = settings.SettingsManager.settings
 
 def is_valid_track(loc):
     """
             Returns the current track rating.  Default is 2
         """
         try:
-            rating = int(self['rating'])
+            rating = float(self['rating'])
         except TypeError:
             return 0
         except KeyError:
         except ValueError:
             return 0
 
-        if rating > 5: return 5
+        steps = settings.get_option("miscellaneous/rating_steps", 5)
+        rating = int(rating*steps/100.0)
+
+        if rating > steps: return int(steps)
         elif rating < 0: return 0
 
         return rating
             return
 
         rating = int(self.rating_combo.get_active())
-        track['rating'] = rating
+        steps = self.settings.get_option("miscellaneous/rating_steps", 5)
 
-        self.update_rating_combo()
+        track['rating'] = float((100.0*rating)/steps)
+
+        self.update_rating_combo(rating)
 
     def update_rating_combo(self, rating=None):
         """
 
 import gtk
 from xlgui import guiutil, commondialogs
-from xl import playlist, xdg
+from xl import playlist, xdg, settings
 from xl.nls import gettext as _
 
+settings = settings.SettingsManager.settings
+
 class GenericTrackMenu(guiutil.Menu):
     """
         A menu that can be subclassed to use on any widget that displays
         if not selected:
             selected = self.widget.get_selected_tracks()
 
+        steps = settings.get_option("miscellaneous/rating_steps", 5)
+
         for track in selected:
-            track['rating'] = i
+            track['rating'] = float((100.0*i)/steps)
 
         if hasattr(self.widget, 'queue_draw'):
             self.widget.queue_draw()

xlgui/plcolumns.py

             cell.set_property('pixbuf', 
                 self.playlist.rating_images[idx])
         except IndexError:
+            print "idx_error"
             if idx > 5: idx = 5
             elif idx < 0: idx = 0
             cell.set_property('pixbuf',