show used dvb system in tuner info dialog (dvb-s / dvb-s2)
[enigma2.git] / lib / python / Screens / EpgSelection.py
index 7f1b204cca435bd02d6f79526a21a38a961830a7..ba49f3147ba5eecae70949485bdc9e661c45b0bc 100644 (file)
@@ -6,6 +6,7 @@ from Components.EpgList import *
 from Components.ActionMap import ActionMap
 from Components.ScrollLabel import ScrollLabel
 from Screens.EventView import EventViewSimple
 from Components.ActionMap import ActionMap
 from Components.ScrollLabel import ScrollLabel
 from Screens.EventView import EventViewSimple
+from TimeDateInput import TimeDateInput
 from enigma import eServiceReference, eServiceEventPtr
 from Screens.FixedMenu import FixedMenu
 from RecordTimer import RecordTimerEntry, parseEvent
 from enigma import eServiceReference, eServiceEventPtr
 from Screens.FixedMenu import FixedMenu
 from RecordTimer import RecordTimerEntry, parseEvent
@@ -13,20 +14,31 @@ from TimerEdit import TimerEditList
 from TimerEntry import TimerEntry
 from ServiceReference import ServiceReference
 from Components.config import config, currentConfigSelectionElement
 from TimerEntry import TimerEntry
 from ServiceReference import ServiceReference
 from Components.config import config, currentConfigSelectionElement
-from time import localtime
+from time import localtime, time
 
 import xml.dom.minidom
 
 class EPGSelection(Screen):
 
 import xml.dom.minidom
 
 class EPGSelection(Screen):
-       def __init__(self, session, service, zapFunc=None):
+       def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None):
                Screen.__init__(self, session)
                Screen.__init__(self, session)
+               self.bouquetChangeCB = bouquetChangeCB
+               self.ask_time = -1 #now
                self["key_red"] = Button("")
                self.closeRecursive = False
                self["key_red"] = Button("")
                self.closeRecursive = False
-               if isinstance(service, eServiceReference):
+               if isinstance(service, str) and eventid != None:
+                       self.type = EPG_TYPE_SIMILAR
+                       self["key_yellow"] = Button()
+                       self["key_blue"] = Button()
+                       self["key_red"] = Button()
+                       self.currentService=service
+                       self.eventid = eventid
+                       self.zapFunc = None
+               elif isinstance(service, eServiceReference) or isinstance(service, str):
                        self.type = EPG_TYPE_SINGLE
                        self["key_yellow"] = Button()
                        self["key_blue"] = Button()
                        self.currentService=ServiceReference(service)
                        self.type = EPG_TYPE_SINGLE
                        self["key_yellow"] = Button()
                        self["key_blue"] = Button()
                        self.currentService=ServiceReference(service)
+                       self.zapFunc = None
                else:
                        self.skinName = "EPGSelectionMulti"
                        self.type = EPG_TYPE_MULTI
                else:
                        self.skinName = "EPGSelectionMulti"
                        self.type = EPG_TYPE_MULTI
@@ -60,36 +72,63 @@ class EPGSelection(Screen):
                                "yellow": self.yellowButtonPressed,
                                "blue": self.blueButtonPressed,
                                "info": self.infoKeyPressed,
                                "yellow": self.yellowButtonPressed,
                                "blue": self.blueButtonPressed,
                                "info": self.infoKeyPressed,
-                               "zapTo": self.zapTo
+                               "red": self.zapTo,
+                               "input_date_time": self.enterDateTime,
+                               "nextBouquet": self.nextBouquet,
+                               "prevBouquet": self.prevBouquet
                        })
                self["actions"].csel = self
 
                self.onLayoutFinish.append(self.onCreate)
 
                        })
                self["actions"].csel = self
 
                self.onLayoutFinish.append(self.onCreate)
 
+       def nextBouquet(self):
+               if self.bouquetChangeCB:
+                       self.bouquetChangeCB(1, self)
+
+       def prevBouquet(self):
+               if self.bouquetChangeCB:
+                       self.bouquetChangeCB(-1, self)
+
+       def enterDateTime(self):
+               if self.type == EPG_TYPE_MULTI:
+                       self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput)
+
+       def onDateTimeInputClosed(self, ret):
+               if len(ret) > 1:
+                       if ret[0]:
+                               self.ask_time=ret[1]
+                               self["list"].fillMultiEPG(self.services, ret[1])
+
        def closeScreen(self):
        def closeScreen(self):
-               self.close(self.closeRecursive or self.type == EPG_TYPE_SINGLE)
+               self.close(self.closeRecursive)
 
        def infoKeyPressed(self):
 
        def infoKeyPressed(self):
-               if self.type == EPG_TYPE_MULTI:
-                       cur = self["list"].getCurrent()
-                       event = cur[0]
-                       service = cur[1]
-               else:
-                       event = self["list"].getCurrent()
-                       service = self.currentService
+               cur = self["list"].getCurrent()
+               event = cur[0]
+               service = cur[1]
                if event is not None:
                if event is not None:
-                       self.session.open(EventViewSimple, event, service, self.eventViewCallback)
+                       if self.type != EPG_TYPE_SIMILAR:
+                               self.session.open(EventViewSimple, event, service, self.eventViewCallback, self.openSimilarList)
+                       else:
+                               self.session.open(EventViewSimple, event, service, self.eventViewCallback)
+
+       def openSimilarList(self, eventid, refstr):
+               self.session.open(EPGSelection, refstr, None, eventid)
+
+       def setServices(self, services):
+               self.services = services
+               self.onCreate()
 
        #just used in multipeg
        def onCreate(self):
                l = self["list"]
 
        #just used in multipeg
        def onCreate(self):
                l = self["list"]
+               l.recalcEntrySize()
                if self.type == EPG_TYPE_MULTI:
                if self.type == EPG_TYPE_MULTI:
-                       l.recalcEntrySize()
-                       l.fillMultiEPG(self.services)
-               else:
-                       if SINGLE_CPP == 0:
-                               l.recalcEntrySize()
+                       l.fillMultiEPG(self.services, self.ask_time)
+               elif self.type == EPG_TYPE_SINGLE:
                        l.fillSingleEPG(self.currentService)
                        l.fillSingleEPG(self.currentService)
+               else:
+                       l.fillSimilarList(self.currentService, self.eventid)
 
        def eventViewCallback(self, setEvent, setService, val):
                l = self["list"]
 
        def eventViewCallback(self, setEvent, setService, val):
                l = self["list"]
@@ -99,26 +138,23 @@ class EPGSelection(Screen):
                elif val == +1:
                        self.moveDown()
                cur = l.getCurrent()
                elif val == +1:
                        self.moveDown()
                cur = l.getCurrent()
-               if self.type == EPG_TYPE_SINGLE:
-                       setEvent(cur)
+               if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref:
+                       self.eventViewCallback(setEvent, setService, val)
                else:
                else:
-                       if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref:
-                               self.eventViewCallback(setEvent, setService, val)
-                       else:
-                               setEvent(cur[0])
-                               setService(cur[1])
+                       setService(cur[1])
+                       setEvent(cur[0])
 
        def zapTo(self): # just used in multiepg
 
        def zapTo(self): # just used in multiepg
-               if self.zapFunc != None:
-                       self.closeRecursive = True
-                       ref = self["list"].getCurrent()[1]
-                       self.zapFunc(ref.ref)
+               if self.zapFunc and self["key_red"].getText() == "Zap":
+                       lst = self["list"]
+                       count = lst.getCurrentChangeCount()
+                       if count == 0:
+                               self.closeRecursive = True
+                               ref = lst.getCurrent()[1]
+                               self.zapFunc(ref.ref)
 
        def eventSelected(self):
 
        def eventSelected(self):
-               if self.type == EPG_TYPE_SINGLE:
-                       self.infoKeyPressed()
-               else: # EPG_TYPE_MULTI
-                       self.zapTo()
+               self.infoKeyPressed()
 
        def yellowButtonPressed(self):
                if self.type == EPG_TYPE_MULTI:
 
        def yellowButtonPressed(self):
                if self.type == EPG_TYPE_MULTI:
@@ -129,16 +165,12 @@ class EPGSelection(Screen):
                        self["list"].updateMultiEPG(1)
 
        def timerAdd(self):
                        self["list"].updateMultiEPG(1)
 
        def timerAdd(self):
-               if self.type == EPG_TYPE_SINGLE:
-                       event = self["list"].getCurrent()
-                       serviceref = self.currentService
-               else:
-                       cur = self["list"].getCurrent()
-                       event = cur[0]
-                       serviceref = cur[1]
+               cur = self["list"].getCurrent()
+               event = cur[0]
+               serviceref = cur[1]
                if event is None:
                        return
                if event is None:
                        return
-               newEntry = RecordTimerEntry(serviceref, *parseEvent(event))
+               newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
                self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
 
        def timerEditFinished(self, answer):
                self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
 
        def timerEditFinished(self, answer):
@@ -154,31 +186,47 @@ class EPGSelection(Screen):
                self["list"].moveDown()
 
        def applyButtonState(self, state):
                self["list"].moveDown()
 
        def applyButtonState(self, state):
-               if state == 1:
-                       self["now_button_sel"].show()
+               if state == 0:
                        self["now_button"].hide()
                        self["now_button"].hide()
-               else:
-                       self["now_button"].show()
                        self["now_button_sel"].hide()
                        self["now_button_sel"].hide()
-
-               if state == 2:
-                       self["next_button_sel"].show()
                        self["next_button"].hide()
                        self["next_button"].hide()
-               else:
-                       self["next_button"].show()
                        self["next_button_sel"].hide()
                        self["next_button_sel"].hide()
-
-               if state == 3:
-                       self["more_button_sel"].show()
                        self["more_button"].hide()
                        self["more_button"].hide()
-               else:
-                       self["more_button"].show()
                        self["more_button_sel"].hide()
                        self["more_button_sel"].hide()
+                       self["now_text"].hide()
+                       self["next_text"].hide()
+                       self["more_text"].hide()
+                       self["key_red"].setText("")
+               else:
+                       if state == 1:
+                               self["key_red"].setText("Zap")
+                               self["now_button_sel"].show()
+                               self["now_button"].hide()
+                       else:
+                               self["now_button"].show()
+                               self["now_button_sel"].hide()
+                               self["key_red"].setText("")
+
+                       if state == 2:
+                               self["next_button_sel"].show()
+                               self["next_button"].hide()
+                       else:
+                               self["next_button"].show()
+                               self["next_button_sel"].hide()
+
+                       if state == 3:
+                               self["more_button_sel"].show()
+                               self["more_button"].hide()
+                       else:
+                               self["more_button"].show()
+                               self["more_button_sel"].hide()
 
        def onSelectionChanged(self):
                if self.type == EPG_TYPE_MULTI:
                        count = self["list"].getCurrentChangeCount()
 
        def onSelectionChanged(self):
                if self.type == EPG_TYPE_MULTI:
                        count = self["list"].getCurrentChangeCount()
-                       if count > 1:
+                       if self.ask_time != -1:
+                               self.applyButtonState(0)
+                       elif count > 1:
                                self.applyButtonState(3)
                        elif count > 0:
                                self.applyButtonState(2)
                                self.applyButtonState(3)
                        elif count > 0:
                                self.applyButtonState(2)