cleanup
[vuplus_dvbapp-plugin] / autotimer / src / AutoTimerPreview.py
index 14358f2..cbbc6a8 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: UTF-8 -*-
 # for localized messages
 from . import _
 
@@ -7,13 +8,28 @@ from Screens.Screen import Screen
 # GUI (Components)
 from Components.ActionMap import ActionMap
 from Components.Button import Button
-from AutoTimerList import AutoTimerPreviewList
+from Components.Sources.List import List
+
+from ServiceReference import ServiceReference
+from Tools.FuzzyDate import FuzzyTime
 
 class AutoTimerPreview(Screen):
        """Preview Timers which would be set"""
 
        skin = """<screen name="AutoTimerPreview" title="Preview AutoTimer" position="75,155" size="565,265">
-               <widget name="timerlist" position="5,5" size="555,210" scrollbarMode="showOnDemand" />
+               <widget source="timerlist" render="Listbox" position="5,5" size="555,210" scrollbarMode="showAlways">
+                       <convert type="TemplatedMultiContent">
+                               {"template": [
+                                               MultiContentEntryText(pos=(2,2), size=(550,24), text = 3, font = 0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER),
+                                               MultiContentEntryText(pos=(2,26), size=(555,30), text = 0, font = 1, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER),
+                                               MultiContentEntryText(pos=(2,50), size=(400,20), text = 4, font = 1, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER),
+                                               MultiContentEntryText(pos=(290,50), size=(233,20), text = 2, font = 1, flags = RT_HALIGN_RIGHT|RT_VALIGN_CENTER),
+                                       ],
+                                "fonts": [gFont("Regular", 20),gFont("Regular", 18)],
+                                "itemHeight": 72
+                               }
+                       </convert>
+               </widget>
                <ePixmap position="0,220" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
                <ePixmap position="280,220" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
                <widget name="key_red" position="0,220" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
@@ -27,9 +43,15 @@ class AutoTimerPreview(Screen):
                timers.sort(key = lambda x: x[1])
                self.sort_type = 0
 
-               self.timers = timers
+               # name, begin, end, serviceref, timername -> name, begin, timername, sname, timestr
+               self.timers = [
+                       (x[0], x[1], x[4],
+                       ServiceReference(x[3]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '').encode('utf-8', 'ignore'),
+                       (("%s, %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(x[1]) + FuzzyTime(x[2])[1:] + ((x[2] - x[1]) / 60,))))
+                       for x in timers
+               ]
 
-               self["timerlist"] = AutoTimerPreviewList(timers)
+               self["timerlist"] = List(self.timers)
 
                # Initialize Buttons
                self["key_red"] = Button(_("Cancel"))
@@ -59,16 +81,21 @@ class AutoTimerPreview(Screen):
 
        def sort(self):
                timers = self.timers
-               if len(timers):
-                       timer = self["timerlist"].getCurrent()
+               if timers:
+                       current = self["timerlist"].current
+                       idx = 0
+                       for timer in timers:
+                               if timer == current:
+                                       break
+                               idx += 1
                        if self.sort_type == 1:
                                timers.sort(key=lambda x: x[1])
                                self.sort_type = 0
                        else:
                                timers.sort(key = lambda x: x[4].lower())
                                self.sort_type = 1
-                       self["timerlist"].setList(timers)
-                       self["timerlist"].moveToEntry(timer)
+                       self["timerlist"].updateList(timers)
+                       self["timerlist"].index = idx
                        self.setSortDescription()
 
        def cancel(self):