working on move, edit mode and add remove service to context menu
[enigma2.git] / lib / python / Screens / TimerEdit.py
index 86bd4e0..4f5039e 100644 (file)
@@ -16,12 +16,9 @@ class TimerEditList(Screen):
                Screen.__init__(self, session)
                
                list = [ ]
                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")
                self["timerlist"] = TimerList(list)
                
                self["key_red"] = Button("Delete")
@@ -37,6 +34,15 @@ class TimerEditList(Screen):
                                "green": self.addCurrentTimer
                        })
 
                                "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])
        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])
        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()
        
        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())
                
                # 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"
                
        def finishedEdit(self, answer):
                if (answer[0]):
                        print "Edited timer"
+                       self.fillTimerList()
                else:
                        print "Timeredit aborted"
                else:
                        print "Timeredit aborted"
-
+                       
        def finishedAdd(self, answer):
                if (answer[0]):
                        self.session.nav.RecordTimer.record(answer[1])
        def finishedAdd(self, answer):
                if (answer[0]):
                        self.session.nav.RecordTimer.record(answer[1])
+                       self.fillTimerList()
                else:
                else:
-                       print "Timeredit aborted"               
\ No newline at end of file
+                       print "Timeredit aborted"