def _buildOptionEntryServicePicon(self, service): if service.flags & eServiceReference.mustDescent: alist = ServiceReference(service).list() first_in_alternative = alist and alist.getNext() if first_in_alternative: service_str = first_in_alternative.toString() else: service_str = service.toString() else: service_str = service.toString() return self.piconLoader.getPicon(service_str)
def _checkHasRecording(self, service, isPlayable): if not config.usage.configselection_showrecordings.value: return False if self.recordingList.has_key(service.toString()): return True if isPlayable and len(self.recordingList) and service.flags & eServiceReference.mustDescent: alist = ServiceReference(service).list() while True: aservice = alist.getNext() if not aservice.valid(): break if self.recordingList.has_key(aservice.toString()): return True return False
def _checkHasRecording(self, service, isPlayable): if not config.usage.configselection_showrecordings.value: return False if self.recordingList.has_key(service.toString()): return True if isPlayable and len( self.recordingList ) and service.flags & eServiceReference.mustDescent: alist = ServiceReference(service).list() while True: aservice = alist.getNext() if not aservice.valid(): break if self.recordingList.has_key(aservice.toString()): return True return False
def buildOptionEntry(self, service, **args): width = self.l.getItemSize().width() height = self.l.getItemSize().height() selected = args["selected"] res = [ None ] showListNumbers = config.usage.configselection_showlistnumbers.value showPicons = self.mode == self.MODE_FAVOURITES and config.usage.configselection_showpicons.value showServiceName = self.mode == self.MODE_NORMAL or (self.mode == self.MODE_FAVOURITES and config.usage.configselection_showservicename.value) showProgressbar = config.usage.show_event_progress_in_servicelist.value progressbarPosition = config.usage.configselection_progressbarposition.value servicenameWidth = config.usage.configselection_servicenamecolwidth.value columnStyle = config.usage.configselection_columnstyle.value additionalposition = config.usage.configselection_additionaltimedisplayposition.value bigPicons = self.mode == self.MODE_FAVOURITES and config.usage.configselection_bigpicons.value secondlineinfo = config.usage.configselection_secondlineinfo.value # get service information service_info = self.service_center.info(service) isMarker = service.flags & eServiceReference.isMarker isPlayable = not(service.flags & eServiceReference.isDirectory or isMarker) recording = False if config.usage.configselection_showrecordings.value: if self.recordingList.has_key(service.toString()): recording = True else: if isPlayable and len(self.recordingList) and service.flags & eServiceReference.mustDescent: alist = ServiceReference(service).list() while True: aservice = alist.getNext() if not aservice.valid(): break if self.recordingList.has_key(aservice.toString()): recording = True break marked = 0 if self.l.isCurrentMarked() and selected: marked = 2 elif self.l.isMarked(service): if selected: marked = 2 else: marked = 1 if marked == 1: # marked additionalInfoColor = serviceDescriptionColor = forgroundColor = self.markedForeground backgroundColor = self.markedBackground forgroundColorSel = backgroundColorSel = additionalInfoColorSelected = serviceDescriptionColorSelected = None elif marked == 2: # marked and selected additionalInfoColorSelected = serviceDescriptionColorSelected = forgroundColorSel = self.markedForegroundSelected backgroundColorSel = self.markedBackgroundSelected forgroundColor = additionalInfoColor = serviceDescriptionColor = backgroundColor = None else: if recording: forgroundColor = additionalInfoColor = serviceDescriptionColor = self.recordingColor forgroundColorSel = additionalInfoColorSelected = serviceDescriptionColorSelected = self.recordingColorSelected backgroundColor = backgroundColorSel = None else: forgroundColor = forgroundColorSel = backgroundColor = backgroundColorSel = None serviceDescriptionColor = self.serviceDescriptionColor serviceDescriptionColorSelected = self.serviceDescriptionColorSelected additionalInfoColor = self.additionalInfoColor additionalInfoColorSelected = self.additionalInfoColorSelected if (marked == 0 and isPlayable and service_info and self.is_playable_ignore.valid() and not service_info.isPlayable(service, self.is_playable_ignore)): forgroundColor = forgroundColorSel = additionalInfoColor = additionalInfoColorSelected = serviceDescriptionColor = serviceDescriptionColorSelected = self.serviceNotAvail # set windowstyle if marked > 0: res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, width , height, 1, RT_HALIGN_RIGHT, "", forgroundColor, forgroundColorSel, backgroundColor, backgroundColorSel)) info = self.service_center.info(service) serviceName = info.getName(service) or "<n/a>" event = info.getEvent(service) index = self.getCurrentIndex() xoffset = 2 pixmap = None drawProgressbar = isPlayable and showProgressbar if service.flags & eServiceReference.isMarker: pixmap = self.picMarker elif service.flags & eServiceReference.isGroup: pixmap = self.picServiceGroup elif service.flags & eServiceReference.isDirectory: pixmap = self.picFolder else: orbpos = service.getUnsignedData(4) >> 16; if orbpos == 0xFFFF: pixmap = self.picDVB_C elif orbpos == 0xEEEE: pixmap = self.picDVB_T else: pixmap = self.picDVB_S if pixmap is not None: pixmap_size = self.picMarker.size() ypos = (height - pixmap_size.height()) / 2 pix_width = pixmap_size.width() res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, xoffset, ypos, pix_width, height, pixmap)) xoffset += pix_width + 8 if self.mode != self.MODE_NORMAL: # servicenumber if not (service.flags & eServiceReference.isMarker) and showListNumbers: markers_before = self.l.getNumMarkersBeforeCurrent() text = "%d" % (self.numberoffset + index + 1 - markers_before) res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, 50 , height, 1, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, text, forgroundColor, forgroundColorSel, backgroundColor, backgroundColorSel)) xoffset += 60 # picons if isPlayable and showPicons: if service.flags & eServiceReference.mustDescent: alist = ServiceReference(service).list() first_in_alternative = alist and alist.getNext() if first_in_alternative: service_str = first_in_alternative.toString() else: service_str = service.toString() else: service_str = service.toString() picon = self.piconLoader.getPicon(service_str) if picon: pixmap_size = picon.size() ypos = (height - pixmap_size.height()) / 2 pix_width = pixmap_size.width() res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, xoffset, ypos, pix_width, height, picon)) if bigPicons: xoffset += 108 else: xoffset += 58 # progressbar between servicenumber and servicename if drawProgressbar and progressbarPosition == "0": res.append(self.paintProgressBar(event, xoffset, width, height)) xoffset += 60 addtimedisplay = "" addtimedisplayWidth = 0 if config.usage.configselection_showadditionaltimedisplay.value != "0" and event and isPlayable: if columnStyle: self.textRenderer.setFont(self.additionalInfoFont) if config.usage.configselection_showadditionaltimedisplay.value == "1": # percent now = int(time()) percent = 100 * (now - event.getBeginTime()) / event.getDuration() addtimedisplay = "%d%%" % percent if columnStyle: self.textRenderer.setText("100%") elif config.usage.configselection_showadditionaltimedisplay.value == "2": # remain now = int(time()) remain = int((event.getBeginTime() + event.getDuration() - now) / 60) addtimedisplay = "+%d min" % remain if columnStyle: self.textRenderer.setText("+%d min" % 9999) elif config.usage.configselection_showadditionaltimedisplay.value == "3": # Remain / duration now = int(time()) remain = int((event.getBeginTime() + event.getDuration() - now) / 60) duration = int(event.getDuration() / 60) addtimedisplay = "+%d/%d min" % (remain, duration) if columnStyle: self.textRenderer.setText("+%d/%d min" % (9999, 9999)) elif config.usage.configselection_showadditionaltimedisplay.value == "4": # elapsed now = int(time()) elapsed = int((now - event.getBeginTime()) / 60) addtimedisplay = "%d min" % elapsed if columnStyle: self.textRenderer.setText("%d min" % 9999) elif config.usage.configselection_showadditionaltimedisplay.value == "5": # elapsed / duration now = int(time()) elapsed = int((now - event.getBeginTime()) / 60) duration = int(event.getDuration() / 60) addtimedisplay = "%d/%d min" % (elapsed, duration) if columnStyle: self.textRenderer.setText("%d/%d min" % (9999, 9999)) elif config.usage.configselection_showadditionaltimedisplay.value == "6": # elapsed / remain / duration now = int(time()) elapsed = int((now - event.getBeginTime()) / 60) remain = int((event.getBeginTime() + event.getDuration() - now) / 60) duration = int(event.getDuration() / 60) addtimedisplay = "%d/+%d/%d min" % (elapsed, remain, duration) if columnStyle: self.textRenderer.setText("%d/+%d/%d min" % (9999, 9999, 9999)) elif config.usage.configselection_showadditionaltimedisplay.value == "7": # begin - end time beginTime = localtime(event.getBeginTime()) endTime = localtime(event.getBeginTime()+event.getDuration()) addtimedisplay = "%02d:%02d - %02d:%02d" % (beginTime[3],beginTime[4],endTime[3],endTime[4]) if columnStyle: self.textRenderer.setText("00:00 - 00:000") if columnStyle: addtimedisplayWidth = self.textRenderer.calculateSize().width() if columnStyle: rwidth = 0 # servicename if (isPlayable and showServiceName) or not isPlayable: if isPlayable: rwidth = servicenameWidth # space for servicename else: rwidth = width - xoffset # space for servicename res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, rwidth , height, 2, RT_HALIGN_LEFT|RT_VALIGN_CENTER, serviceName, forgroundColor, forgroundColorSel, backgroundColor, backgroundColorSel)) xoffset = xoffset + rwidth + 10 # progressbar between servicename and service description if drawProgressbar and progressbarPosition == "1": res.append(self.paintProgressBar(event, xoffset, width, height)) xoffset += 60 if event and isPlayable: if addtimedisplay != "" and additionalposition == "1": if drawProgressbar and progressbarPosition == "2": rwidth = width - xoffset - addtimedisplayWidth rwidth -= 60 else: rwidth = width - xoffset - addtimedisplayWidth else: rwidth = width-xoffset if drawProgressbar and progressbarPosition == "2": rwidth -= 60 if addtimedisplay != "" and additionalposition == "0": # add time text before service description res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, addtimedisplayWidth, height, 0, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, addtimedisplay, additionalInfoColor, additionalInfoColorSelected, backgroundColor, backgroundColorSel)) addoffset = addtimedisplayWidth + 10 xoffset += addoffset rwidth -= addoffset # service description if secondlineinfo != "0" and self.mode == self.MODE_FAVOURITES: res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, rwidth, self.serviceInfoFontHeight+6, 3, RT_HALIGN_LEFT|RT_VALIGN_CENTER, event.getEventName(), serviceDescriptionColor, serviceDescriptionColorSelected, backgroundColor, backgroundColorSel)) if secondlineinfo == "1": # shortdescription text = event.getShortDescription() else: event_next = eEPGCache.getInstance().lookupEventTime(service, -1, 1) if event_next: beginTime = localtime(event_next.getBeginTime()) endTime = localtime(event_next.getBeginTime()+event_next.getDuration()) text = "%02d:%02d - %02d:%02d %s" % (beginTime[3],beginTime[4],endTime[3],endTime[4], event_next.getEventName()) else: text = "%s: n/a" % _("upcoming event") res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, self.serviceInfoFontHeight+6, rwidth, height - (self.serviceInfoFontHeight+6), 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, text, additionalInfoColor, additionalInfoColorSelected, backgroundColor, backgroundColorSel)) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, rwidth, height, 3, RT_HALIGN_LEFT|RT_VALIGN_CENTER, event.getEventName(), serviceDescriptionColor, serviceDescriptionColorSelected, backgroundColor, backgroundColorSel)) # progressbar after service description if drawProgressbar and progressbarPosition == "2": xoffset = xoffset + rwidth + 5 res.append(self.paintProgressBar(event, xoffset, width, height)) xoffset += 60 elif addtimedisplay != "": xoffset = xoffset + rwidth # add time text at last position if addtimedisplay != "" and additionalposition == "1": res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, width-xoffset , height, 0, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, addtimedisplay, additionalInfoColor, additionalInfoColorSelected, backgroundColor, backgroundColorSel)) else: if event and isPlayable: self.textRenderer.setFont(self.serviceNameFont) self.textRenderer.setText(serviceName) length = self.textRenderer.calculateSize().width() + 10 res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, length , height, 2, RT_HALIGN_LEFT|RT_VALIGN_CENTER, serviceName, forgroundColor, forgroundColorSel, backgroundColor, backgroundColorSel)) xoffset += length if addtimedisplay != "": if additionalposition == "1": # add time text after service description text = "(%s %s)" % (event.getEventName(), addtimedisplay) else: # add time text before service description text = "(%s %s)" % (addtimedisplay, event.getEventName()) else: text = "(%s)" % (event.getEventName()) if drawProgressbar and progressbarPosition == "2": # progressbar after service description length = width-xoffset - 60 else: length = width-xoffset # service description res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, length , height, 3, RT_HALIGN_LEFT|RT_VALIGN_CENTER, text, serviceDescriptionColor, serviceDescriptionColorSelected, backgroundColor, backgroundColorSel)) if drawProgressbar and progressbarPosition == "2": xoffset += length + 5 res.append(self.paintProgressBar(event, xoffset, width, height)) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, xoffset, 0, width - xoffset , height, 2, RT_HALIGN_LEFT|RT_VALIGN_CENTER, serviceName, forgroundColor, forgroundColorSel, backgroundColor, backgroundColorSel)) return res