X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/1213cbcff4f8b31aa77825325f102a134d246e0a..dfbd5853de864053e8ac10d1269e8137f3cb5a34:/lib/python/Components/EpgList.py diff --git a/lib/python/Components/EpgList.py b/lib/python/Components/EpgList.py index b7288792..7e5dca10 100644 --- a/lib/python/Components/EpgList.py +++ b/lib/python/Components/EpgList.py @@ -5,6 +5,7 @@ from enigma import * from re import * from time import localtime, time from ServiceReference import ServiceReference +from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE EPG_TYPE_SINGLE = 0 EPG_TYPE_MULTI = 1 @@ -42,7 +43,11 @@ class Rect: return self.__width class EPGList(HTMLComponent, GUIComponent): - def __init__(self, type=EPG_TYPE_SINGLE): + def __init__(self, type=EPG_TYPE_SINGLE, selChangedCB=None, timer = None): + self.timer = timer + self.onSelChanged = [ ] + if selChangedCB is not None: + self.onSelChanged.append(selChangedCB) GUIComponent.__init__(self) self.type=type if type == EPG_TYPE_SINGLE and SINGLE_CPP > 0: @@ -57,6 +62,11 @@ class EPGList(HTMLComponent, GUIComponent): event = self.epgcache.lookupEventId(service.ref, eventid) return event + def getCurrentChangeCount(self): + if self.type == EPG_TYPE_SINGLE: + return 0 + return self.l.getCurrentSelection()[0][0] + def getCurrent(self): if self.type == EPG_TYPE_SINGLE: if SINGLE_CPP > 0: @@ -66,8 +76,8 @@ class EPGList(HTMLComponent, GUIComponent): evt = self.getEventFromId(self.service, eventid) else: tmp = self.l.getCurrentSelection()[0] - eventid = tmp[0] - service = ServiceReference(tmp[1]) + eventid = tmp[1] + service = ServiceReference(tmp[2]) event = self.getEventFromId(service, eventid) evt = ( event, service ) return evt @@ -78,8 +88,25 @@ class EPGList(HTMLComponent, GUIComponent): def moveDown(self): self.instance.moveSelection(self.instance.moveDown) + def connectSelectionChanged(func): + if not self.onSelChanged.count(func): + self.onSelChanged.append(func) + + def disconnectSelectionChanged(func): + self.onSelChanged.remove(func) + + def selectionChanged(self): + for x in self.onSelChanged: + if x is not None: + try: + x() + except: + pass + def GUIcreate(self, parent): self.instance = eListbox(parent) + self.instance.setWrapAround(True) + self.instance.selectionChanged.get().append(self.selectionChanged) self.instance.setContent(self.l) if SINGLE_CPP > 0: self.instance.setItemHeight(25) @@ -88,45 +115,48 @@ class EPGList(HTMLComponent, GUIComponent): self.instance = None def recalcEntrySize(self): - t = time() - esize = self.l.getItemSize() - self.l.setFont(0, gFont("Regular", 22)) - self.l.setFont(1, gFont("Regular", 16)) - width = esize.width() - height = esize.height() - if self.type == EPG_TYPE_SINGLE: - w = width/20*5 - self.datetime_rect = Rect(0,0, w, height) - self.descr_rect = Rect(w, 0, width/20*15, height) - else: - xpos = 0; - w = width/10*3; - self.service_rect = Rect(xpos, 0, w-10, height) - xpos += w; - w = width/10*2; - self.start_end_rect = Rect(xpos, 0, w-10, height) - self.progress_rect = Rect(xpos, 4, w-10, height-8) - xpos += w - w = width/10*5; - self.descr_rect = Rect(xpos, 0, width, height) - print "recalcEntrySize", time() - t - - def buildSingleEntry(self, eventId, beginTime, duration, EventName): + if SINGLE_CPP == 0: + esize = self.l.getItemSize() + self.l.setFont(0, gFont("Regular", 22)) + self.l.setFont(1, gFont("Regular", 16)) + width = esize.width() + height = esize.height() + if self.type == EPG_TYPE_SINGLE: + w = width/20*5 + self.datetime_rect = Rect(0,0, w, height) + self.descr_rect = Rect(w, 0, width/20*15, height) + else: + xpos = 0; + w = width/10*3; + self.service_rect = Rect(xpos, 0, w-10, height) + xpos += w; + w = width/10*2; + self.start_end_rect = Rect(xpos, 0, w-10, height) + self.progress_rect = Rect(xpos, 4, w-10, height-8) + xpos += w + w = width/10*5; + self.descr_rect = Rect(xpos, 0, width, height) + + def buildSingleEntry(self, eventId, beginTime, duration, EventName, rec=False): r1=self.datetime_rect r2=self.descr_rect res = [ eventId ] 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, EventName)) + if rec: + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r2.left(), r2.top(), 21, 21, loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, 'epgclock-fs8.png')))) + res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left() + 25, r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, EventName)) + else: + res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r2.height(), 0, RT_HALIGN_LEFT, EventName)) return res - def buildMultiEntry(self, service, eventId, begTime, duration, EventName, nowTime, service_name): + def buildMultiEntry(self, changecount, service, eventId, begTime, duration, EventName, nowTime, service_name): sname = service_name r1=self.service_rect r2=self.progress_rect r3=self.descr_rect r4=self.start_end_rect - res = [ (eventId, service, begTime, duration) ] + res = [ (changecount, eventId, service, begTime, duration) ] re = compile('\xc2\x86.*?\xc2\x87') list = re.findall(sname) if len(list): @@ -168,32 +198,34 @@ class EPGList(HTMLComponent, GUIComponent): tmp = self.queryEPG(test) self.list = [ ] for x in tmp: - self.list.append(self.buildMultiEntry(x[0], x[1], x[2], x[3], x[4], x[5], x[6])) + self.list.append(self.buildMultiEntry(0, x[0], x[1], x[2], x[3], x[4], x[5], x[6])) self.l.setList(self.list) print time() - t + self.selectionChanged() def updateMultiEPG(self, direction): t = time() test = [ 'RIBDTCN' ] for x in self.list: data = x[0] - service = data[1] - begTime = data[2] - duration = data[3] - new_stime = 0 - if begTime is not None: - if direction > 0: - new_stime = begTime+duration+120 - else: - new_stime = begTime-120 - test.append((service, 0, new_stime)) - self.list = self.queryEPG(test, self.buildMultiEntry) -# tmp = self.queryEPG(test) -# self.list = [ ] -# for x in tmp: -# self.list.append(self.buildMultiEntry(x[0], x[1], x[2], x[3], x[4], x[5], x[6])) + service = data[2] + begTime = data[3] + duration = data[4] + if begTime is None: + begTime = 0 + test.append((service, direction, begTime)) +# self.list = self.queryEPG(test, self.buildMultiEntry) + tmp = self.queryEPG(test) + cnt=0 + for x in tmp: + changecount = self.list[cnt][0][0] + direction + if changecount >= 0: + if x[2] is not None: + self.list[cnt]=self.buildMultiEntry(changecount, x[0], x[1], x[2], x[3], x[4], x[5], x[6]) + cnt+=1 self.l.setList(self.list) print time() - t + self.selectionChanged() def fillSingleEPG(self, service): t = time() @@ -206,7 +238,8 @@ class EPGList(HTMLComponent, GUIComponent): tmp = self.queryEPG(test) self.list = [ ] for x in tmp: - self.list.append(self.buildSingleEntry(x[0], x[1], x[2], x[3])) + self.list.append(self.buildSingleEntry(x[0], x[1], x[2], x[3], (self.timer.isInTimer(eventid=x[0], begin=x[1], duration=x[2], service=service) > 0))) # self.list.append(self.buildSingleEntry(refstr, x[0], x[1], x[2], x[3])) self.l.setList(self.list) print time() - t + self.selectionChanged()