add missing import
[enigma2.git] / lib / python / Screens / TimerEdit.py
index 86bd4e031b2706c2740d6d039d844ff6909dc0fe..4f5039ec9bacaa74d3a8cf82017739ed6f81a208 100644 (file)
@@ -16,12 +16,9 @@ class TimerEditList(Screen):
                Screen.__init__(self, session)
                
                list = [ ]
-               for timer in session.nav.RecordTimer.timer_list:
-                       list.append(TimerEntryComponent(timer, 0))
-               
-               for timer in session.nav.RecordTimer.processed_timers:
-                       list.append(TimerEntryComponent(timer, 1))
-               
+               self.list = list
+               self.fillTimerList()
+
                self["timerlist"] = TimerList(list)
                
                self["key_red"] = Button("Delete")
@@ -37,6 +34,15 @@ class TimerEditList(Screen):
                                "green": self.addCurrentTimer
                        })
 
+       def fillTimerList(self):
+               del self.list[:]
+               
+               for timer in self.session.nav.RecordTimer.timer_list:
+                       self.list.append(TimerEntryComponent(timer, 0))
+               
+               for timer in self.session.nav.RecordTimer.processed_timers:
+                       self.list.append(TimerEntryComponent(timer, 1))
+
        def openEdit(self):
                self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timerlist"].getCurrent()[0])
                #self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])
@@ -44,6 +50,8 @@ class TimerEditList(Screen):
        def removeTimer(self):
                # FIXME doesn't work...
                self.session.nav.RecordTimer.removeEntry(self["timerlist"].getCurrent()[0])
+               self.fillTimerList()
+               self["timerlist"].invalidate()
        
        def addCurrentTimer(self):
                begin = time()
@@ -73,20 +81,21 @@ class TimerEditList(Screen):
                # FIXME only works if already playing a service
                serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
                
-               self.addTimer(begin, end, serviceref, epg, description)
+               self.addTimer(RecordTimerEntry(begin, end, serviceref, epg, description))
                
-       def addTimer(self, begin, end, serviceref, epg, description):
-               newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
-               self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
+       def addTimer(self, timer):
+               self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
                
        def finishedEdit(self, answer):
                if (answer[0]):
                        print "Edited timer"
+                       self.fillTimerList()
                else:
                        print "Timeredit aborted"
-
+                       
        def finishedAdd(self, answer):
                if (answer[0]):
                        self.session.nav.RecordTimer.record(answer[1])
+                       self.fillTimerList()
                else:
-                       print "Timeredit aborted"               
\ No newline at end of file
+                       print "Timeredit aborted"