store configmode in advanced sat mode
[enigma2.git] / lib / python / Screens / TimerEntry.py
index a9a79d12dc4bf9dcf580320bc525840a2fdb0ba1..fef525f0be945d10ae692725b824290cf680bd4e 100644 (file)
@@ -2,12 +2,15 @@ from Screen import Screen
 import ChannelSelection
 from ServiceReference import ServiceReference
 from Components.config import *
 import ChannelSelection
 from ServiceReference import ServiceReference
 from Components.config import *
-from Components.ActionMap import NumberActionMap
+from Components.ActionMap import ActionMap, NumberActionMap
 from Components.ConfigList import ConfigList
 from Components.ConfigList import ConfigList
+from Components.MenuList import MenuList
+from Components.Button import Button
 from Components.NimManager import nimmanager
 from Components.Label import Label
 from Components.Pixmap import Pixmap
 from Screens.SubserviceSelection import SubserviceSelection
 from Components.NimManager import nimmanager
 from Components.Label import Label
 from Components.Pixmap import Pixmap
 from Screens.SubserviceSelection import SubserviceSelection
+from Screens.MessageBox import MessageBox
 from enigma import eEPGCache
 import time
 import datetime
 from enigma import eEPGCache
 import time
 import datetime
@@ -15,7 +18,7 @@ import datetime
 class TimerEntry(Screen):
        def __init__(self, session, timer):
                Screen.__init__(self, session)
 class TimerEntry(Screen):
        def __init__(self, session, timer):
                Screen.__init__(self, session)
-               self.timer = timer;
+               self.timer = timer
                
                self["oktext"] = Label(_("OK"))
                self["canceltext"] = Label(_("Cancel"))
                
                self["oktext"] = Label(_("OK"))
                self["canceltext"] = Label(_("Cancel"))
@@ -46,7 +49,7 @@ class TimerEntry(Screen):
 
                self.list = []
                self["config"] = ConfigList(self.list)
 
                self.list = []
                self["config"] = ConfigList(self.list)
-               self.createSetup()
+               self.createSetup("config")
 
        def createConfig(self):
                        config.timerentry = ConfigSubsection()
 
        def createConfig(self):
                        config.timerentry = ConfigSubsection()
@@ -132,7 +135,7 @@ class TimerEntry(Screen):
                                except:
                                        pass
 
                                except:
                                        pass
 
-       def createSetup(self):
+       def createSetup(self, widget):
                self.list = []
                self.list.append(getConfigListEntry(_("Name"), config.timerentry.name))
                self.list.append(getConfigListEntry(_("Description"), config.timerentry.description))
                self.list = []
                self.list.append(getConfigListEntry(_("Name"), config.timerentry.name))
                self.list.append(getConfigListEntry(_("Description"), config.timerentry.description))
@@ -165,27 +168,27 @@ class TimerEntry(Screen):
 
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("Start"), config.timerentry.startdate))
 
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("Start"), config.timerentry.startdate))
-                       self.list.append(getConfigListEntry("", config.timerentry.starttime))
+                       self.list.append(getConfigListEntry(" ", config.timerentry.starttime))
                else:
                        self.list.append(getConfigListEntry(_("StartTime"), config.timerentry.starttime))
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("End"), config.timerentry.enddate))
                else:
                        self.list.append(getConfigListEntry(_("StartTime"), config.timerentry.starttime))
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("End"), config.timerentry.enddate))
-                       self.list.append(getConfigListEntry("", config.timerentry.endtime))
+                       self.list.append(getConfigListEntry(" ", config.timerentry.endtime))
                else:
                        self.list.append(getConfigListEntry(_("EndTime"), config.timerentry.endtime))
 
                self.channelEntry = getConfigListEntry(_("Channel"), config.timerentry.service)
                self.list.append(self.channelEntry)
 
                else:
                        self.list.append(getConfigListEntry(_("EndTime"), config.timerentry.endtime))
 
                self.channelEntry = getConfigListEntry(_("Channel"), config.timerentry.service)
                self.list.append(self.channelEntry)
 
-               self["config"].list = self.list
-               self["config"].l.setList(self.list)
+               self[widget].list = self.list
+               self[widget].l.setList(self.list)
 
        def newConfig(self):
                print self["config"].getCurrent()
                if self["config"].getCurrent() == self.timerTypeEntry:
 
        def newConfig(self):
                print self["config"].getCurrent()
                if self["config"].getCurrent() == self.timerTypeEntry:
-                       self.createSetup()
+                       self.createSetup("config")
                if self["config"].getCurrent() == self.frequencyEntry:
                if self["config"].getCurrent() == self.frequencyEntry:
-                       self.createSetup()
+                       self.createSetup("config")
 
        def keyLeft(self):
                if self["config"].getCurrent() == self.channelEntry:
 
        def keyLeft(self):
                if self["config"].getCurrent() == self.channelEntry:
@@ -279,3 +282,79 @@ class TimerEntry(Screen):
 
        def keyCancel(self):
                self.close((False,))
 
        def keyCancel(self):
                self.close((False,))
+               
+class TimerLog(Screen):
+       def __init__(self, session, timer):
+               Screen.__init__(self, session)
+               self.timer = timer;
+               self.log_entries = self.timer.log_entries[:]
+               
+               self.fillLogList()
+               
+               self["loglist"] = MenuList(self.list)
+               self["logentry"] = Label()
+               
+               self["key_red"] = Button(_("Delete entry"))
+               self["key_green"] = Button()
+               self["key_yellow"] = Button("")
+               self["key_blue"] = Button(_("Clear log"))
+               
+               self.onShown.append(self.updateText)
+
+               self["actions"] = NumberActionMap(["OkCancelActions", "DirectionActions", "ColorActions"],
+               {
+                       "ok": self.keyClose,
+                       "cancel": self.keyClose,
+                       "up": self.up,
+                       "down": self.down,
+                       "left": self.left,
+                       "right": self.right,
+                       "red": self.deleteEntry,
+                       "blue": self.clearLog
+               }, -1)
+
+       def deleteEntry(self):
+               self.log_entries.remove(self["loglist"].getCurrent()[1])
+               self.fillLogList()
+               self["loglist"].l.setList(self.list)
+               self.updateText()
+
+       def fillLogList(self):
+               self.list = [ ]
+               for x in self.log_entries:
+                       self.list.append((str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x))
+       
+       def clearLog(self):             
+               self.log_entries = []
+               self.fillLogList()
+               self["loglist"].l.setList(self.list)
+               self.updateText()
+               
+       def keyClose(self):
+               if self.timer.log_entries != self.log_entries:
+                       self.timer.log_entries = self.log_entries
+                       self.close((True, self.timer))
+               else:
+                       self.close((False,))
+               
+       def up(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.moveUp)
+               self.updateText()
+               
+       def down(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.moveDown)
+               self.updateText()
+
+       def left(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.pageUp)
+               self.updateText()
+               
+       def right(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.pageDown)
+               self.updateText()
+
+       def updateText(self):
+               if len(self.list) > 0:
+                       self["logentry"].setText(str(self["loglist"].getCurrent()[1][2]))
+               else:
+                       self["logentry"].setText("")