show similar broadcastings deferred in eventview
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 19 Apr 2006 18:37:37 +0000 (18:37 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 19 Apr 2006 18:37:37 +0000 (18:37 +0000)
when similar broascastings are avail now it is possible to open a epglist with all similar broadcastings (via red button)

data/keymap.xml
lib/python/Components/EpgList.py
lib/python/Screens/EpgSelection.py
lib/python/Screens/EventView.py
lib/python/Screens/InfoBarGenerics.py

index cc558b1..b91360f 100644 (file)
                <key id="KEY_DOWN" mapto="pageDown" flags="mr" />
                <key id="KEY_LEFT" mapto="prevEvent" flags="mr" />
                <key id="KEY_RIGHT" mapto="nextEvent" flags="mr" />
                <key id="KEY_DOWN" mapto="pageDown" flags="mr" />
                <key id="KEY_LEFT" mapto="prevEvent" flags="mr" />
                <key id="KEY_RIGHT" mapto="nextEvent" flags="mr" />
+               <key id="KEY_RED" mapto="openSimilarList" flags="m" />
                <key id="KEY_GREEN" mapto="timerAdd" flags="m" />
                <key id="KEY_INFO" mapto="cancel" flags="m" />
        </map>
                <key id="KEY_GREEN" mapto="timerAdd" flags="m" />
                <key id="KEY_INFO" mapto="cancel" flags="m" />
        </map>
index a1030b9..1ea0a1c 100644 (file)
@@ -9,6 +9,7 @@ from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
 
 EPG_TYPE_SINGLE = 0
 EPG_TYPE_MULTI = 1
 
 EPG_TYPE_SINGLE = 0
 EPG_TYPE_MULTI = 1
+EPG_TYPE_SIMILAR = 2
 
 RT_HALIGN_LEFT = 0
 RT_HALIGN_RIGHT = 1
 
 RT_HALIGN_LEFT = 0
 RT_HALIGN_RIGHT = 1
@@ -56,8 +57,11 @@ class EPGList(HTMLComponent, GUIComponent):
                        self.l = eListboxPythonMultiContent()
                        if type == EPG_TYPE_SINGLE:
                                self.l.setBuildFunc(self.buildSingleEntry)
                        self.l = eListboxPythonMultiContent()
                        if type == EPG_TYPE_SINGLE:
                                self.l.setBuildFunc(self.buildSingleEntry)
-                       else:
+                       elif type == EPG_TYPE_MULTI:
                                self.l.setBuildFunc(self.buildMultiEntry)
                                self.l.setBuildFunc(self.buildMultiEntry)
+                       else:
+                               assert(type == EPG_TYPE_SIMILAR)
+                               self.l.setBuildFunc(self.buildSimilarEntry)
                self.epgcache = eEPGCache.getInstance()
 
        def getEventFromId(self, service, eventid):
                self.epgcache = eEPGCache.getInstance()
 
        def getEventFromId(self, service, eventid):
@@ -81,7 +85,7 @@ class EPGList(HTMLComponent, GUIComponent):
                                        return cur
                                else:
                                        evt = self.getEventFromId(self.service, cur[0])
                                        return cur
                                else:
                                        evt = self.getEventFromId(self.service, cur[0])
-               else:
+               elif self.type == EPG_TYPE_MULTI:
                        tmp = self.l.getCurrentSelection()
                        if tmp is None:
                                return ( None, None )
                        tmp = self.l.getCurrentSelection()
                        if tmp is None:
                                return ( None, None )
@@ -89,6 +93,14 @@ class EPGList(HTMLComponent, GUIComponent):
                        service = ServiceReference(tmp[1])
                        event = self.getEventFromId(service, eventid)
                        evt = ( event, service )
                        service = ServiceReference(tmp[1])
                        event = self.getEventFromId(service, eventid)
                        evt = ( event, service )
+               else:
+                       tmp = self.l.getCurrentSelection()
+                       if tmp is None:
+                               return ( None, None )
+                       eventid = tmp[1]
+                       service = ServiceReference(tmp[0])
+                       event = self.getEventFromId(service, eventid)
+                       evt = ( event, service )
                return evt
 
        def moveUp(self):
                return evt
 
        def moveUp(self):
@@ -134,7 +146,7 @@ class EPGList(HTMLComponent, GUIComponent):
                                w = width/20*5
                                self.datetime_rect = Rect(0,0, w, height)
                                self.descr_rect = Rect(w, 0, width/20*15, height)
                                w = width/20*5
                                self.datetime_rect = Rect(0,0, w, height)
                                self.descr_rect = Rect(w, 0, width/20*15, height)
-                       else:
+                       elif self.type == EPG_TYPE_MULTI:
                                xpos = 0;
                                w = width/10*3;
                                self.service_rect = Rect(xpos, 0, w-10, height)
                                xpos = 0;
                                w = width/10*3;
                                self.service_rect = Rect(xpos, 0, w-10, height)
@@ -145,6 +157,13 @@ class EPGList(HTMLComponent, GUIComponent):
                                xpos += w
                                w = width/10*5;
                                self.descr_rect = Rect(xpos, 0, width, height)
                                xpos += w
                                w = width/10*5;
                                self.descr_rect = Rect(xpos, 0, width, height)
+                       else: # EPG_TYPE_SIMILAR
+                               xpos = 0;
+                               w = width/10*3;
+                               self.datetime_rect = Rect(xpos, 0, w-10, height)
+                               xpos += w
+                               w = width/10*7;
+                               self.service_rect = Rect(xpos, 0, w-10, height)
 
        def buildSingleEntry(self, eventId, beginTime, duration, EventName):
                rec=(self.timer.isInTimer(eventId, beginTime, duration, self.service) > ((duration/10)*8)) 
 
        def buildSingleEntry(self, eventId, beginTime, duration, EventName):
                rec=(self.timer.isInTimer(eventId, beginTime, duration, self.service) > ((duration/10)*8)) 
@@ -160,6 +179,15 @@ class EPGList(HTMLComponent, GUIComponent):
                        res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, EventName))
                return res
 
                        res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, EventName))
                return res
 
+       def buildSimilarEntry(self, service, eventId, beginTime, service_name):
+               r1=self.datetime_rect
+               r2=self.service_rect
+               res = [ None ]  # no private data needed
+               t = localtime(beginTime)
+               res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4])))
+               res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, service_name))
+               return res
+
        def buildMultiEntry(self, changecount, service, eventId, begTime, duration, EventName, nowTime, service_name):
                rec=begTime and (self.timer.isInTimer(eventId, begTime, duration, service) > ((duration/10)*8))
                sname = service_name
        def buildMultiEntry(self, changecount, service, eventId, begTime, duration, EventName, nowTime, service_name):
                rec=begTime and (self.timer.isInTimer(eventId, begTime, duration, service) > ((duration/10)*8))
                sname = service_name
@@ -246,3 +274,22 @@ class EPGList(HTMLComponent, GUIComponent):
                        self.l.setList(self.queryEPG(test))
                print time() - t
                self.selectionChanged()
                        self.l.setList(self.queryEPG(test))
                print time() - t
                self.selectionChanged()
+
+       def sort_func(self,x,y):
+               if x[2] < y[2]:
+                       return -1
+               elif x[2] == y[2]:
+                       return 0
+               else:
+                       return 1
+
+       def fillSimilarList(self, refstr, event_id):
+               t = time()
+        # search similar broadcastings
+               if event_id is None:
+                       return
+               l = self.epgcache.search(('RIBN', 1024, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, event_id))
+               l.sort(self.sort_func)
+               self.l.setList(l)
+               self.selectionChanged()
+               print time() - t
index f9516e1..5613c8b 100644 (file)
@@ -18,11 +18,18 @@ from time import localtime
 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):
                Screen.__init__(self, session)
                self["key_red"] = Button("")
                self.closeRecursive = False
                Screen.__init__(self, session)
                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
+               elif isinstance(service, eServiceReference) or isinstance(service, str):
                        self.type = EPG_TYPE_SINGLE
                        self["key_yellow"] = Button()
                        self["key_blue"] = Button()
                        self.type = EPG_TYPE_SINGLE
                        self["key_yellow"] = Button()
                        self["key_blue"] = Button()
@@ -70,7 +77,7 @@ class EPGSelection(Screen):
                self.close(self.closeRecursive)
 
        def infoKeyPressed(self):
                self.close(self.closeRecursive)
 
        def infoKeyPressed(self):
-               if self.type == EPG_TYPE_MULTI:
+               if self.type == EPG_TYPE_MULTI or self.type == EPG_TYPE_SIMILAR:
                        cur = self["list"].getCurrent()
                        event = cur[0]
                        service = cur[1]
                        cur = self["list"].getCurrent()
                        event = cur[0]
                        service = cur[1]
@@ -78,7 +85,13 @@ class EPGSelection(Screen):
                        event = self["list"].getCurrent()
                        service = self.currentService
                if event is not None:
                        event = self["list"].getCurrent()
                        service = self.currentService
                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)
 
        #just used in multipeg
        def onCreate(self):
 
        #just used in multipeg
        def onCreate(self):
@@ -86,10 +99,13 @@ class EPGSelection(Screen):
                if self.type == EPG_TYPE_MULTI:
                        l.recalcEntrySize()
                        l.fillMultiEPG(self.services)
                if self.type == EPG_TYPE_MULTI:
                        l.recalcEntrySize()
                        l.fillMultiEPG(self.services)
-               else:
+               elif self.type == EPG_TYPE_SINGLE:
                        if SINGLE_CPP == 0:
                                l.recalcEntrySize()
                        l.fillSingleEPG(self.currentService)
                        if SINGLE_CPP == 0:
                                l.recalcEntrySize()
                        l.fillSingleEPG(self.currentService)
+               else:
+                       l.recalcEntrySize()
+                       l.fillSimilarList(self.currentService, self.eventid)
 
        def eventViewCallback(self, setEvent, setService, val):
                l = self["list"]
 
        def eventViewCallback(self, setEvent, setService, val):
                l = self["list"]
@@ -115,10 +131,10 @@ class EPGSelection(Screen):
                        self.zapFunc(ref.ref)
 
        def eventSelected(self):
                        self.zapFunc(ref.ref)
 
        def eventSelected(self):
-               if self.type == EPG_TYPE_SINGLE:
-                       self.infoKeyPressed()
-               else: # EPG_TYPE_MULTI
+               if self.type == EPG_TYPE_MULTI:
                        self.zapTo()
                        self.zapTo()
+               else:
+                       self.infoKeyPressed()
 
        def yellowButtonPressed(self):
                if self.type == EPG_TYPE_MULTI:
 
        def yellowButtonPressed(self):
                if self.type == EPG_TYPE_MULTI:
index 8694746..56a9e02 100644 (file)
@@ -3,14 +3,15 @@ from Components.ActionMap import ActionMap
 from Components.Button import Button
 from Components.Label import Label
 from Components.ScrollLabel import ScrollLabel
 from Components.Button import Button
 from Components.Label import Label
 from Components.ScrollLabel import ScrollLabel
-from enigma import eServiceEventPtr, eEPGCachePtr, eEPGCache
+from enigma import eServiceEventPtr, eEPGCachePtr, eEPGCache, eTimer
 from ServiceReference import ServiceReference
 from RecordTimer import RecordTimerEntry, parseEvent
 from TimerEntry import TimerEntry
 from time import localtime, asctime
 
 class EventViewBase:
 from ServiceReference import ServiceReference
 from RecordTimer import RecordTimerEntry, parseEvent
 from TimerEntry import TimerEntry
 from time import localtime, asctime
 
 class EventViewBase:
-       def __init__(self, Event, Ref, callback=None):
+       def __init__(self, Event, Ref, callback=None, similarEPGCB=None):
+               self.similarEPGCB = similarEPGCB
                self.cbFunc = callback
                self.currentService=Ref
                self.isRecording = len(Ref.ref.getPath())
                self.cbFunc = callback
                self.currentService=Ref
                self.isRecording = len(Ref.ref.getPath())
@@ -20,6 +21,11 @@ class EventViewBase:
                self["channel"] = Label()
                self["duration"] = Label()
                self["key_red"] = Button("")
                self["channel"] = Label()
                self["duration"] = Label()
                self["key_red"] = Button("")
+               if similarEPGCB is not None:
+                       self.SimilarBroadcastTimer = eTimer()
+                       self.SimilarBroadcastTimer.timeout.get().append(self.getSimilarEvents)
+               else:
+                       self.SimilarBroadcastTimer = None
                if self.isRecording:
                        self["key_green"] = Button("")
                else:
                if self.isRecording:
                        self["key_green"] = Button("")
                else:
@@ -34,7 +40,8 @@ class EventViewBase:
                                "pageDown": self.pageDown,
                                "prevEvent": self.prevEvent,
                                "nextEvent": self.nextEvent,
                                "pageDown": self.pageDown,
                                "prevEvent": self.prevEvent,
                                "nextEvent": self.nextEvent,
-                               "timerAdd": self.timerAdd
+                               "timerAdd": self.timerAdd,
+                               "openSimilarList": self.openSimilarList
                        })
                self.onShown.append(self.onCreate)
 
                        })
                self.onShown.append(self.onCreate)
 
@@ -62,7 +69,6 @@ class EventViewBase:
                        print "Timeredit aborted"
 
        def setService(self, service):
                        print "Timeredit aborted"
 
        def setService(self, service):
-               
                self.currentService=service
                if self.isRecording:
                        self["channel"].setText(_("Recording"))
                self.currentService=service
                if self.isRecording:
                        self["channel"].setText(_("Recording"))
@@ -83,10 +89,6 @@ class EventViewBase:
 
        def setEvent(self, event):
                self.event = event
 
        def setEvent(self, event):
                self.event = event
-               id = event.getEventId()
-
-               refstr = str(self.currentService)
-               epgcache = eEPGCache.getInstance()
                text = event.getEventName()
                short = event.getShortDescription()
                ext = event.getExtendedDescription()
                text = event.getEventName()
                short = event.getShortDescription()
                ext = event.getExtendedDescription()
@@ -97,19 +99,13 @@ class EventViewBase:
                                text = text + '\n\n'
                        text = text + ext
 
                                text = text + '\n\n'
                        text = text + ext
 
-        # search similar broadcastings
-               ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
-               if ret is not None:
-                       text += '\n\n' + _('Similar broadcasts:')
-                       ret.sort(self.sort_func)
-                       for x in ret:
-                               t = localtime(x[1])
-                               text += '\n%d.%d.%d, %02d:%02d  -  %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
-
                self.setTitle(event.getEventName())
                self["epg_description"].setText(text)
                self["datetime"].setText(event.getBeginTimeString())
                self["duration"].setText(_("%d min")%(event.getDuration()/60))
                self.setTitle(event.getEventName())
                self["epg_description"].setText(text)
                self["datetime"].setText(event.getBeginTimeString())
                self["duration"].setText(_("%d min")%(event.getDuration()/60))
+               self["key_red"].setText("")
+               if self.SimilarBroadcastTimer is not None:
+                       self.SimilarBroadcastTimer.start(400,True)
 
        def pageUp(self):
                self["epg_description"].pageUp()
 
        def pageUp(self):
                self["epg_description"].pageUp()
@@ -117,21 +113,45 @@ class EventViewBase:
        def pageDown(self):
                self["epg_description"].pageDown()
 
        def pageDown(self):
                self["epg_description"].pageDown()
 
+       def getSimilarEvents(self):
+        # search similar broadcastings
+               refstr = str(self.currentService)
+               id = self.event.getEventId()
+               epgcache = eEPGCache.getInstance()
+               ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
+               if ret is not None:
+                       descr = self["epg_description"]
+                       text = descr.getText()
+                       text += '\n\n' + _('Similar broadcasts:')
+                       ret.sort(self.sort_func)
+                       for x in ret:
+                               t = localtime(x[1])
+                               text += '\n%d.%d.%d, %02d:%02d  -  %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
+                       descr.setText(text)
+                       self["key_red"].setText(_("Similar"))
+
+       def openSimilarList(self):
+               if self.similarEPGCB is not None:
+                       id = self.event and self.event.getEventId()
+                       refstr = str(self.currentService)
+                       if id is not None:
+                               self.similarEPGCB(id, refstr)
+
 class EventViewSimple(Screen, EventViewBase):
 class EventViewSimple(Screen, EventViewBase):
-       def __init__(self, session, Event, Ref, callback=None):
+       def __init__(self, session, Event, Ref, callback=None, similarEPGCB=None):
                Screen.__init__(self, session)
                self.skinName = "EventView"
                Screen.__init__(self, session)
                self.skinName = "EventView"
-               EventViewBase.__init__(self, Event, Ref, callback)
+               EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
 
 class EventViewEPGSelect(Screen, EventViewBase):
 
 class EventViewEPGSelect(Screen, EventViewBase):
-       def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
+       def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None, similarEPGCB=None):
                Screen.__init__(self, session)
                self.skinName = "EventView"
                Screen.__init__(self, session)
                self.skinName = "EventView"
-               EventViewBase.__init__(self, Event, Ref, callback)
+               EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
                self["key_yellow"].setText(_("Single EPG"))
                self["key_blue"].setText(_("Multi EPG"))
                self["epgactions"] = ActionMap(["EventViewEPGActions"],
                        {
                                "openSingleServiceEPG": singleEPGCB,
                self["key_yellow"].setText(_("Single EPG"))
                self["key_blue"].setText(_("Multi EPG"))
                self["epgactions"] = ActionMap(["EventViewEPGActions"],
                        {
                                "openSingleServiceEPG": singleEPGCB,
-                               "openMultiServiceEPG": multiEPGCB
+                               "openMultiServiceEPG": multiEPGCB,
                        })
                        })
index aea8131..77fca55 100644 (file)
@@ -396,8 +396,10 @@ class InfoBarEPG:
 
        def openSingleServiceEPG(self):
                ref=self.session.nav.getCurrentlyPlayingServiceReference()
 
        def openSingleServiceEPG(self):
                ref=self.session.nav.getCurrentlyPlayingServiceReference()
-               ptr=eEPGCache.getInstance()
-               self.session.openWithCallback(self.closed, EPGSelection, ref)
+               self.session.open(EPGSelection, ref)
+
+       def openSimilarList(self, eventid, refstr):
+               self.session.open(EPGSelection, refstr, None, eventid)
 
        def openEventView(self):
                self.epglist = [ ]
 
        def openEventView(self):
                self.epglist = [ ]
@@ -419,7 +421,7 @@ class InfoBarEPG:
                                if ptr:
                                        self.epglist.append(ptr)
                if len(self.epglist) > 0:
                                if ptr:
                                        self.epglist.append(ptr)
                if len(self.epglist) > 0:
-                       self.session.open(EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG)
+                       self.session.open(EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
                else:
                        print "no epg for the service avail.. so we show multiepg instead of eventinfo"
                        self.openMultiServiceEPG(False)
                else:
                        print "no epg for the service avail.. so we show multiepg instead of eventinfo"
                        self.openMultiServiceEPG(False)