X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/44c32e4101acdeb6df3833f35e9c0719e993a2a5..cdb8a973f09efb2d42875d7854edba9a411719ff:/lib/python/Screens/EventView.py diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py index 5d50d9bc..cced3ceb 100644 --- a/lib/python/Screens/EventView.py +++ b/lib/python/Screens/EventView.py @@ -1,22 +1,27 @@ from Screen import Screen from Screens.TimerEdit import TimerSanityConflict +from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap from Components.Button import Button from Components.Label import Label from Components.ScrollLabel import ScrollLabel from Components.TimerList import TimerList +from Components.UsageConfig import preferredTimerPath from enigma import eEPGCache, eTimer, eServiceReference -from RecordTimer import RecordTimerEntry, parseEvent +from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT from TimerEntry import TimerEntry from time import localtime from Components.config import config class EventViewBase: + ADD_TIMER = 0 + REMOVE_TIMER = 1 + def __init__(self, Event, Ref, callback=None, similarEPGCB=None): self.similarEPGCB = similarEPGCB self.cbFunc = callback self.currentService=Ref - self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and len(Ref.ref.getPath()) + self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and Ref.ref.getPath() self.event = Event self["epg_description"] = ScrollLabel() self["datetime"] = Label() @@ -28,6 +33,7 @@ class EventViewBase: self.SimilarBroadcastTimer.callback.append(self.getSimilarEvents) else: self.SimilarBroadcastTimer = None + self.key_green_choice = self.ADD_TIMER if self.isRecording: self["key_green"] = Button("") else: @@ -59,9 +65,28 @@ class EventViewBase: if self.cbFunc is not None: self.cbFunc(self.setEvent, self.setService, +1) + def removeTimer(self, timer): + timer.afterEvent = AFTEREVENT.NONE + self.session.nav.RecordTimer.removeEntry(timer) + self["key_green"].setText(_("Add timer")) + self.key_green_choice = self.ADD_TIMER + def timerAdd(self): - if not self.isRecording: - newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, *parseEvent(self.event)) + if self.isRecording: + return + event = self.event + serviceref = self.currentService + if event is None: + return + eventid = event.getEventId() + refstr = serviceref.ref.toString() + for timer in self.session.nav.RecordTimer.timer_list: + if timer.eit == eventid and timer.service_ref.ref.toString() == refstr: + cb_func = lambda ret : not ret or self.removeTimer(timer) + self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName()) + break + else: + newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event)) self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry) def finishedAdd(self, answer): @@ -70,13 +95,17 @@ class EventViewBase: entry = answer[1] simulTimerList = self.session.nav.RecordTimer.record(entry) if simulTimerList is not None: - if (len(simulTimerList) == 2) and (simulTimerList[1].dontSave) and (simulTimerList[1].autoincrease): - simulTimerList[1].end = entry.begin - 30 - self.session.nav.RecordTimer.timeChanged(simulTimerList[1]) - self.session.nav.RecordTimer.record(entry) - else: + for x in simulTimerList: + if x.setAutoincreaseEnd(entry): + self.session.nav.RecordTimer.timeChanged(x) + simulTimerList = self.session.nav.RecordTimer.record(entry) + if simulTimerList is not None: self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList) + self["key_green"].setText(_("Remove timer")) + self.key_green_choice = self.REMOVE_TIMER else: + self["key_green"].setText(_("Add timer")) + self.key_green_choice = self.ADD_TIMER print "Timeredit aborted" def finishSanityCorrection(self, answer): @@ -108,12 +137,12 @@ class EventViewBase: text = event.getEventName() short = event.getShortDescription() ext = event.getExtendedDescription() - if len(short) > 0 and short != text: - text = text + '\n\n' + short - if len(ext) > 0: - if len(text) > 0: - text = text + '\n\n' - text = text + ext + if short and short != text: + text += '\n\n' + short + if ext: + if text: + text += '\n\n' + text += ext self.setTitle(event.getEventName()) self["epg_description"].setText(text) @@ -123,6 +152,22 @@ class EventViewBase: if self.SimilarBroadcastTimer is not None: self.SimilarBroadcastTimer.start(400,True) + serviceref = self.currentService + eventid = self.event.getEventId() + refstr = serviceref.ref.toString() + isRecordEvent = False + for timer in self.session.nav.RecordTimer.timer_list: + if timer.eit == eventid and timer.service_ref.ref.toString() == refstr: + isRecordEvent = True + break + if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER: + self["key_green"].setText(_("Remove timer")) + self.key_green_choice = self.REMOVE_TIMER + elif not isRecordEvent and self.key_green_choice != self.ADD_TIMER: + self["key_green"].setText(_("Add timer")) + self.key_green_choice = self.ADD_TIMER + + def pageUp(self): self["epg_description"].pageUp() @@ -147,7 +192,7 @@ class EventViewBase: self["key_red"].setText(_("Similar")) def openSimilarList(self): - if self.similarEPGCB is not None and len(self["key_red"].getText()): + if self.similarEPGCB is not None and self["key_red"].getText(): id = self.event and self.event.getEventId() refstr = str(self.currentService) if id is not None: