add possibility to view eventinfo in recorded movielist (move cursor to
[vuplus_dvbapp] / lib / python / Screens / ChannelSelection.py
index d4a5279..905d455 100644 (file)
@@ -9,9 +9,7 @@ from Components.config import config, configElement, ConfigSubsection, configTex
 from Screens.FixedMenu import FixedMenu
 from Tools.NumericalTextInput import NumericalTextInput
 from Components.NimManager import nimmanager
-from Components.ServiceName import ServiceName
-from Components.Clock import Clock
-from Components.EventInfo import EventInfo
+from Components.Sources.Clock import Clock
 from Components.Input import Input
 from Screens.InputBox import InputBox
 from ServiceReference import ServiceReference
@@ -836,37 +834,82 @@ class ChannelSelectionBase(Screen):
 
 HISTORYSIZE = 20
 
+#config for lastservice
+config.tv = ConfigSubsection()
+config.tv.lastservice = configElement("config.tv.lastservice", configText, "", 0)
+config.tv.lastroot = configElement("config.tv.lastroot", configText, "", 0)
+config.radio = ConfigSubsection()
+config.radio.lastservice = configElement("config.radio.lastservice", configText, "", 0)
+config.radio.lastroot = configElement("config.radio.lastroot", configText, "", 0)
+config.servicelist = ConfigSubsection()
+config.servicelist.lastmode = configElement("config.servicelist.lastmode", configText, "tv", 0)
+
 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
        def __init__(self, session):
                ChannelSelectionBase.__init__(self,session)
                ChannelSelectionEdit.__init__(self)
                ChannelSelectionEPG.__init__(self)
 
-               #config for lastservice
-               config.tv = ConfigSubsection();
-               config.tv.lastservice = configElement("config.tv.lastservice", configText, "", 0);
-               config.tv.lastroot = configElement("config.tv.lastroot", configText, "", 0);
-
-               self["actions"] = ActionMap(["OkCancelActions"],
+               self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
                        {
                                "cancel": self.cancel,
                                "ok": self.channelSelected,
+                               "keyRadio": self.setModeRadio,
+                               "keyTV": self.setModeTv,
                        })
+
                self.onShown.append(self.__onShown)
 
                self.lastChannelRootTimer = eTimer()
                self.lastChannelRootTimer.timeout.get().append(self.__onCreate)
                self.lastChannelRootTimer.start(100,True)
 
-               self.history = [ ]
+               self.history_tv = [ ]
+               self.history_radio = [ ]
+               self.history = self.history_tv
                self.history_pos = 0
 
-       def __onCreate(self):
-               self.setTvMode()
+               self.lastservice = config.tv.lastservice
+               self.lastroot = config.tv.lastroot
+               self.revertMode = None
+
+       def setMode(self):
                self.restoreRoot()
-               lastservice=eServiceReference(config.tv.lastservice.value)
+               lastservice=eServiceReference(self.lastservice.value)
                if lastservice.valid():
                        self.setCurrentSelection(lastservice)
+
+       def setModeTv(self):
+               if self.revertMode is None and config.servicelist.lastmode.value == "radio":
+                       self.revertMode = MODE_RADIO
+               self.history = self.history_tv
+               self.lastservice = config.tv.lastservice
+               self.lastroot = config.tv.lastroot
+               config.servicelist.lastmode.value = "tv"
+               self.setTvMode()
+               self.setMode()
+
+       def setModeRadio(self):
+               if self.revertMode is None and config.servicelist.lastmode.value == "tv":
+                       self.revertMode = MODE_TV
+               if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
+                       self.history = self.history_radio
+                       self.lastservice = config.radio.lastservice
+                       self.lastroot = config.radio.lastroot
+                       config.servicelist.lastmode.value = "radio"
+                       self.setRadioMode()
+                       self.setMode()
+
+       def __onCreate(self):
+               if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
+                       if config.servicelist.lastmode.value == "tv":
+                               self.setModeTv()
+                       else:
+                               self.setModeRadio()
+               else:
+                       self.setModeTv()
+               lastservice=eServiceReference(self.lastservice.value)
+               if lastservice.valid():
                        self.zap()
 
        def __onShown(self):
@@ -891,12 +934,14 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
 
        #called from infoBar and channelSelected
        def zap(self):
+               self.revertMode=None
                ref = self.session.nav.getCurrentlyPlayingServiceReference()
                nref = self.getCurrentSelection()
                if ref is None or ref != nref:
                        self.session.nav.playService(nref)
                        self.saveRoot()
                        self.saveChannel()
+                       config.servicelist.lastmode.save()
                        self.addToHistory(nref)
 
        def addToHistory(self, ref):
@@ -942,34 +987,34 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
 
        def saveRoot(self):
                path = ''
-               for i in self.servicePathTV:
+               for i in self.servicePath:
                        path += i.toString()
                        path += ';'
-               if len(path) and path != config.tv.lastroot.value:
-                       config.tv.lastroot.value = path
-                       config.tv.lastroot.save()
+               if len(path) and path != self.lastroot.value:
+                       self.lastroot.value = path
+                       self.lastroot.save()
 
        def restoreRoot(self):
                self.clearPath()
                re = compile('.+?;')
-               tmp = re.findall(config.tv.lastroot.value)
+               tmp = re.findall(self.lastroot.value)
                cnt = 0
                for i in tmp:
-                       self.servicePathTV.append(eServiceReference(i[:len(i)-1]))
+                       self.servicePath.append(eServiceReference(i[:len(i)-1]))
                        cnt += 1
                if cnt:
-                       path = self.servicePathTV.pop()
+                       path = self.servicePath.pop()
                        self.enterPath(path)
                else:
                        self.showFavourites()
                        self.saveRoot()
 
        def preEnterPath(self, refstr):
-               if len(self.servicePathTV) and self.servicePathTV[0] != eServiceReference(refstr):
-                       pathstr = config.tv.lastroot.value
+               if len(self.servicePath) and self.servicePath[0] != eServiceReference(refstr):
+                       pathstr = self.lastroot.value
                        if pathstr is not None and pathstr.find(refstr) == 0:
                                self.restoreRoot()
-                               lastservice=eServiceReference(config.tv.lastservice.value)
+                               lastservice=eServiceReference(self.lastservice.value)
                                if lastservice.valid():
                                        self.setCurrentSelection(lastservice)
                                return True
@@ -981,9 +1026,23 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        refstr = ref.toString()
                else:
                        refstr = ""
-               if refstr != config.tv.lastservice.value:
-                       config.tv.lastservice.value = refstr
-                       config.tv.lastservice.save()
+               if refstr != self.lastservice.value:
+                       self.lastservice.value = refstr
+                       self.lastservice.save()
+
+       def setCurrentServicePath(self, path):
+               hlen = len(self.history)
+               if hlen > 0:
+                       self.history[self.history_pos] = path
+               else:
+                       self.history.append(path)
+               self.setHistoryPath()
+
+       def getCurrentServicePath(self):
+               hlen = len(self.history)
+               if hlen > 0:
+                       return self.history[self.history_pos]
+               return None
 
        def recallPrevService(self):
                hlen = len(self.history)
@@ -999,11 +1058,17 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        self.setHistoryPath()
 
        def cancel(self):
+               if self.revertMode is None:
+                       self.restoreRoot()
+                       lastservice=eServiceReference(self.lastservice.value)
+                       if lastservice.valid() and self.getCurrentSelection() != lastservice:
+                               self.setCurrentSelection(lastservice)
+               elif self.revertMode == MODE_TV:
+                       self.setModeTv()
+               elif self.revertMode == MODE_RADIO:
+                       self.setModeRadio()
+               self.revertMode = None
                self.close(None)
-               self.restoreRoot()
-               lastservice=eServiceReference(config.tv.lastservice.value)
-               if lastservice.valid() and self.getCurrentSelection() != lastservice:
-                       self.setCurrentSelection(lastservice)
 
 from Screens.InfoBarGenerics import InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord
 
@@ -1013,7 +1078,7 @@ class RadioInfoBar(Screen, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecor
                InfoBarEvent.__init__(self)
                InfoBarServiceName.__init__(self)
                InfoBarInstantRecord.__init__(self)
-               self["Clock"] = Clock()
+               self["CurrentTime"] = Clock()
 
 class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
        def __init__(self, session):