refs bug #429
[enigma2.git] / lib / python / Components / MovieList.py
index 6a2640982d12900315673236134378f92dbf9999..5c98e4be5d6d344b951a21b95da646e5538607f3 100644 (file)
@@ -2,6 +2,7 @@ from GUIComponent import GUIComponent
 from Tools.FuzzyDate import FuzzyTime
 from ServiceReference import ServiceReference
 from Components.MultiContent import MultiContentEntryText
+from Components.config import config
 
 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation, \
        RT_HALIGN_LEFT, RT_HALIGN_RIGHT, eServiceReference, eServiceCenter
@@ -83,20 +84,24 @@ class MovieList(GUIComponent):
                if len <= 0: #recalc len when not already done
                        cur_idx = self.l.getCurrentSelectionIndex()
                        x = self.list[cur_idx]
-                       len = x[1].getLength(x[0]) #recalc the movie length...
+                       if config.usage.load_length_of_movies_in_moviellist.value:
+                               len = x[1].getLength(x[0]) #recalc the movie length...
+                       else:
+                               len = 0 #dont recalc movielist to speedup loading the list
                        self.list[cur_idx] = (x[0], x[1], x[2], len) #update entry in list... so next time we don't need to recalc
                
                if len > 0:
                        len = "%d:%02d" % (len / 60, len % 60)
                else:
-                       len = "?:??"
+                       len = ""
                
                res = [ None ]
                
                txt = info.getName(serviceref)
                service = ServiceReference(info.getInfoString(serviceref, iServiceInformation.sServiceref))
                description = info.getInfoString(serviceref, iServiceInformation.sDescription)
-               
+               tags = info.getInfoString(serviceref, iServiceInformation.sTags)
+
                begin_string = ""
                if begin > 0:
                        t = FuzzyTime(begin)
@@ -104,23 +109,33 @@ class MovieList(GUIComponent):
                
                if self.list_type == MovieList.LISTTYPE_ORIGINAL:
                        res.append(MultiContentEntryText(pos=(0, 0), size=(width-182, 30), font = 0, flags = RT_HALIGN_LEFT, text=txt))
-                       if service is not None:
-                               res.append(MultiContentEntryText(pos=(width-180, 0), size=(180, 30), font = 2, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
+                       if self.tags:
+                               res.append(MultiContentEntryText(pos=(width-180, 0), size=(180, 30), font = 2, flags = RT_HALIGN_RIGHT, text = tags))
+                               if service is not None:
+                                       res.append(MultiContentEntryText(pos=(200, 50), size=(200, 20), font = 1, flags = RT_HALIGN_LEFT, text = service.getServiceName()))
+                       else:
+                               if service is not None:
+                                       res.append(MultiContentEntryText(pos=(width-180, 0), size=(180, 30), font = 2, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
                        res.append(MultiContentEntryText(pos=(0, 30), size=(width, 20), font=1, flags=RT_HALIGN_LEFT, text=description))
-                       res.append(MultiContentEntryText(pos=(0, 50), size=(width-270, 20), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
-                       res.append(MultiContentEntryText(pos=(width-200, 50), size=(200, 20), font=1, flags=RT_HALIGN_RIGHT, text=len))
+                       res.append(MultiContentEntryText(pos=(0, 50), size=(200, 20), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
+                       res.append(MultiContentEntryText(pos=(width-200, 50), size=(198, 20), font=1, flags=RT_HALIGN_RIGHT, text=len))
                elif self.list_type == MovieList.LISTTYPE_COMPACT_DESCRIPTION:
                        res.append(MultiContentEntryText(pos=(0, 0), size=(width-120, 20), font = 0, flags = RT_HALIGN_LEFT, text = txt))
-                       if service is not None:
-                               res.append(MultiContentEntryText(pos=(width-212, 20), size=(154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
                        res.append(MultiContentEntryText(pos=(0, 20), size=(width-212, 17), font=1, flags=RT_HALIGN_LEFT, text=description))
                        res.append(MultiContentEntryText(pos=(width-120, 6), size=(120, 20), font=1, flags=RT_HALIGN_RIGHT, text=begin_string))
+                       if service is not None:
+                               res.append(MultiContentEntryText(pos=(width-212, 20), size=(154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
                        res.append(MultiContentEntryText(pos=(width-58, 20), size=(58, 20), font=1, flags=RT_HALIGN_RIGHT, text=len))
                elif self.list_type == MovieList.LISTTYPE_COMPACT:
                        res.append(MultiContentEntryText(pos=(0, 0), size=(width-77, 20), font = 0, flags = RT_HALIGN_LEFT, text = txt))
-                       if service is not None:
-                               res.append(MultiContentEntryText(pos=(width-200, 20), size=(200, 17), font = 1, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
-                       res.append(MultiContentEntryText(pos=(0, 20), size=(width-200, 17), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
+                       if self.tags:
+                               res.append(MultiContentEntryText(pos=(width-200, 20), size=(200, 17), font = 1, flags = RT_HALIGN_RIGHT, text = tags))
+                               if service is not None:
+                                       res.append(MultiContentEntryText(pos=(200, 20), size=(200, 17), font = 1, flags = RT_HALIGN_LEFT, text = service.getServiceName()))
+                       else:
+                               if service is not None:
+                                       res.append(MultiContentEntryText(pos=(width-200, 20), size=(200, 17), font = 1, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
+                       res.append(MultiContentEntryText(pos=(0, 20), size=(200, 17), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
                        res.append(MultiContentEntryText(pos=(width-75, 0), size=(75, 20), font=0, flags=RT_HALIGN_RIGHT, text=len))
                else:
                        assert(self.list_type == MovieList.LISTTYPE_MINIMAL)
@@ -153,6 +168,10 @@ class MovieList(GUIComponent):
                instance.setContent(self.l)
                instance.selectionChanged.get().append(self.selectionChanged)
 
+       def preWidgetRemove(self, instance):
+               instance.setContent(None)
+               instance.selectionChanged.get().remove(self.selectionChanged)
+
        def reload(self, root = None, filter_tags = None):
                if root is not None:
                        self.load(root, filter_tags)
@@ -201,6 +220,7 @@ class MovieList(GUIComponent):
                        if this_tags == ['']:
                                this_tags = []
                        this_tags = set(this_tags)
+                       tags |= this_tags
                
                        # filter_tags is either None (which means no filter at all), or 
                        # a set. In this case, all elements of filter_tags must be present,
@@ -208,7 +228,6 @@ class MovieList(GUIComponent):
                        if filter_tags is not None and not this_tags.issuperset(filter_tags):
                                continue
                
-                       tags |= this_tags
                        self.list.append((serviceref, info, begin, -1))
                
                if self.sort_type == MovieList.SORT_ALPHANUMERIC:
@@ -225,15 +244,16 @@ class MovieList(GUIComponent):
                ref = x[0]
                info = self.serviceHandler.info(ref)
                name = info and info.getName(ref)
-               return name and name.lower() or ""
+               return (name and name.lower() or "", -x[2])
 
        def moveTo(self, serviceref):
                count = 0
                for x in self.list:
                        if x[0] == serviceref:
                                self.instance.moveSelectionTo(count)
-                               break
+                               return True
                        count += 1
-
+               return False
+       
        def moveDown(self):
                self.instance.moveSelection(self.instance.moveDown)