Recommit Advanced functions(edit/delete/disable) with side effects fixed
authordima73 <dima73@dev.null>
Thu, 20 Nov 2014 20:04:40 +0000 (21:04 +0100)
committerlittlesat <littlesat99@yahoo.com>
Thu, 20 Nov 2014 20:04:40 +0000 (21:04 +0100)
Now the response on the overlap of repeated timers is solved

Signed-off-by: littlesat <littlesat99@yahoo.com>

RecordTimer.py
lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py
lib/python/Screens/EpgSelection.py
lib/python/Screens/EventView.py
timer.py

index 850807e..5a9632f 100644 (file)
@@ -821,6 +821,105 @@ class RecordTimer(timer.Timer):
                        self.saveTimer()
                return None
 
+       def isInRepeatTimer(self, timer, event):
+               time_match = 0
+               is_editable = False
+               begin = event.getBeginTime()
+               duration = event.getDuration()
+               end = begin + duration
+               timer_end = timer.end
+               if timer.disabled and timer.isRunning():
+                       if begin < timer.begin <= end or timer.begin <= begin <= timer_end:
+                               return True
+                       else:
+                               return False
+               if timer.justplay and (timer_end - timer.begin) <= 1:
+                       timer_end += 60
+               bt = localtime(begin)
+               bday = bt.tm_wday
+               begin2 = 1440 + bt.tm_hour * 60 + bt.tm_min
+               end2 = begin2 + duration / 60
+               xbt = localtime(timer.begin)
+               xet = localtime(timer_end)
+               offset_day = False
+               checking_time = timer.begin < begin or begin <= timer.begin <= end
+               if xbt.tm_yday != xet.tm_yday:
+                       oday = bday - 1
+                       if oday == -1: oday = 6
+                       offset_day = timer.repeated & (1 << oday)
+               xbegin = 1440 + xbt.tm_hour * 60 + xbt.tm_min
+               xend = xbegin + ((timer_end - timer.begin) / 60)
+               if xend < xbegin:
+                       xend += 1440
+               if timer.repeated & (1 << bday) and checking_time:
+                       if begin2 < xbegin <= end2:
+                               if xend < end2:
+                                       # recording within event
+                                       time_match = (xend - xbegin) * 60
+                                       is_editable = True
+                               else:
+                                       # recording last part of event
+                                       time_match = (end2 - xbegin) * 60
+                                       summary_end = (xend - end2) * 60
+                                       is_editable = not summary_end and True or time_match >= summary_end
+                       elif xbegin <= begin2 <= xend:
+                               if xend < end2:
+                                       # recording first part of event
+                                       time_match = (xend - begin2) * 60
+                                       summary_end = (begin2 - xbegin) * 60
+                                       is_editable = not summary_end and True or time_match >= summary_end
+                               else:
+                                       # recording whole event
+                                       time_match = (end2 - begin2) * 60
+                                       is_editable = True
+                       elif offset_day:
+                               xbegin -= 1440
+                               xend -= 1440
+                               if begin2 < xbegin <= end2:
+                                       if xend < end2:
+                                               # recording within event
+                                               time_match = (xend - xbegin) * 60
+                                               is_editable = True
+                                       else:
+                                               # recording last part of event
+                                               time_match = (end2 - xbegin) * 60
+                                               summary_end = (xend - end2) * 60
+                                               is_editable = not summary_end and True or time_match >= summary_end
+                               elif xbegin <= begin2 <= xend:
+                                       if xend < end2:
+                                               # recording first part of event
+                                               time_match = (xend - begin2) * 60
+                                               summary_end = (begin2 - xbegin) * 60
+                                               is_editable = not summary_end and True or time_match >= summary_end
+                                       else:
+                                               # recording whole event
+                                               time_match = (end2 - begin2) * 60
+                                               is_editable = True
+               elif offset_day and checking_time:
+                       xbegin -= 1440
+                       xend -= 1440
+                       if begin2 < xbegin <= end2:
+                               if xend < end2:
+                                       # recording within event
+                                       time_match = (xend - xbegin) * 60
+                                       is_editable = True
+                               else:
+                                       # recording last part of event
+                                       time_match = (end2 - xbegin) * 60
+                                       summary_end = (xend - end2) * 60
+                                       is_editable = not summary_end and True or time_match >= summary_end
+                       elif xbegin <= begin2 <= xend:
+                               if xend < end2:
+                                       # recording first part of event
+                                       time_match = (xend - begin2) * 60
+                                       summary_end = (begin2 - xbegin) * 60
+                                       is_editable = not summary_end and True or time_match >= summary_end
+                               else:
+                                       # recording whole event
+                                       time_match = (end2 - begin2) * 60
+                                       is_editable = True
+               return time_match and is_editable
+
        def isInTimer(self, eventid, begin, duration, service):
                returnValue = None
                type = 0
@@ -874,7 +973,14 @@ class RecordTimer(timer.Timer):
                                if x.always_zap:
                                        type_offset = 10
 
-                               if x.repeated != 0:
+                               timer_repeat = x.repeated
+                               # if set 'don't stop current event but disable coming events' for repeat timer
+                               running_only_curevent = x.disabled and x.isRunning() and timer_repeat
+                               if running_only_curevent:
+                                       timer_repeat = 0
+                                       type_offset += 15
+
+                               if timer_repeat != 0:
                                        type_offset += 15
                                        if bt is None:
                                                bt = localtime(begin)
index b954c35..580f4ba 100644 (file)
@@ -1076,40 +1076,98 @@ class GraphMultiEPG(Screen, HelpableScreen):
                self["key_green"].setText(_("Add timer"))
                self.key_green_choice = self.ADD_TIMER
 
-       def disableTimer(self, timer):
-               timer.disable()
-               self.session.nav.RecordTimer.timeChanged(timer)
-               self["key_green"].setText(_("Add timer"))
-               self.key_green_choice = self.ADD_TIMER
+       def disableTimer(self, timer, repeat=False, record=False):
+               if repeat:
+                       if record:
+                               title_text = _("Repeating event currently recording.\nWhat do you want to do?")
+                               menu = [(_("Stop current event but not coming events"), "stoponlycurrent"),(_("Stop current event and disable coming events"), "stopall")]
+                               if not timer.disabled:
+                                       menu.append((_("Don't stop current event but disable coming events"), "stoponlycoming"))
+                       else:
+                               title_text = _("Attention, this is repeated timer!\nWhat do you want to do?")
+                               menu = [(_("Disable current event but not coming events"), "nextonlystop"),(_("Disable timer"), "simplestop")]
+                       self.session.openWithCallback(boundFunction(self.runningEventCallback, timer), ChoiceBox, title=title_text, list=menu)
+               else:
+                       timer.disable()
+                       self.session.nav.RecordTimer.timeChanged(timer)
+                       self["key_green"].setText(_("Add timer"))
+                       self.key_green_choice = self.ADD_TIMER
+
+       def runningEventCallback(self, t, result):
+               if result is not None:
+                       findNextRunningEvent = True
+                       findEventNext = False
+                       if result[1] == "nextonlystop":
+                               findEventNext = True
+                               t.disable()
+                               self.session.nav.RecordTimer.timeChanged(t)
+                               t.processRepeated(findNextEvent=True)
+                               t.enable()
+                       if result[1] in ("stoponlycurrent", "stopall"):
+                               findNextRunningEvent = False
+                               t.enable()
+                               t.processRepeated(findRunningEvent=False)
+                               self.session.nav.RecordTimer.doActivate(t)
+                       if result[1] in ("stoponlycoming", "stopall", "simplestop"):
+                               findNextRunningEvent = True
+                               t.disable()
+                       self.session.nav.RecordTimer.timeChanged(t)
+                       t.findRunningEvent = findNextRunningEvent
+                       t.findNextEvent = findEventNext
+                       if result[1] in ("stoponlycurrent", "stopall", "simplestop", "nextonlystop"):
+                               self["key_green"].setText(_("Add timer"))
+                               self.key_green_choice = self.ADD_TIMER
 
        def timerAdd(self):
                cur = self["list"].getCurrent()
                event = cur[0]
+               serviceref = cur[1]
                if event is None:
                        return
+               isRecordEvent = isRepeat = firstNextRepeatEvent = False
                eventid = event.getEventId()
-               serviceref = cur[1]
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
-                               menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
-                               buttons = ["red", "green"]
-                               if not timer.isRunning():
-                                       menu.append((_("Disable timer"), "disable"))
-                                       buttons.append("yellow")
-                               menu.append((_("Timer Overview"), "timereditlist"))
-                               def timerAction(choice):
-                                       if choice is not None:
-                                               if choice[1] == "delete":
-                                                       self.removeTimer(timer)
-                                               elif choice[1] == "edit":
-                                                       self.session.open(TimerEntry, timer)
-                                               elif choice[1] == "disable":
-                                                       self.disableTimer(timer)
-                                               elif choice[1] == "timereditlist":
-                                                       self.session.open(TimerEditList)
-                               self.session.openWithCallback(timerAction, ChoiceBox, title=_("Select action for timer %s:") % event.getEventName(), list=menu, keys=buttons)
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end):
+                               isRecordEvent = True
+                               break
+                       elif needed_ref and timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event):
+                               isRecordEvent = True
                                break
+               if isRecordEvent:
+                       isRepeat = timer.repeated
+                       title_text = isRepeat and _("Attention, this is repeated timer!\n") or ""
+                       firstNextRepeatEvent = isRepeat and (begin < timer.begin <= end or timer.begin <= begin <= timer.end) and not timer.justplay 
+                       menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
+                       buttons = ["red", "green"]
+                       if not timer.isRunning():
+                               if firstNextRepeatEvent and timer.isFindRunningEvent() and not timer.isFindNextEvent():
+                                       menu.append((_("Options disable timer"), "disablerepeat"))
+                               else:
+                                       menu.append((_("Disable timer"), "disable"))
+                               buttons.append("yellow")
+                       elif firstNextRepeatEvent:
+                               menu.append((_("Options disable timer"), "disablerepeatrunning"))
+                               buttons.append("yellow")
+                       menu.append((_("Timer Overview"), "timereditlist"))
+                       def timerAction(choice):
+                               if choice is not None:
+                                       if choice[1] == "delete":
+                                               self.removeTimer(timer)
+                                       elif choice[1] == "edit":
+                                               self.session.open(TimerEntry, timer)
+                                       elif choice[1] == "disable":
+                                               self.disableTimer(timer)
+                                       elif choice[1] == "timereditlist":
+                                               self.session.open(TimerEditList)
+                                       elif choice[1] == "disablerepeatrunning":
+                                               self.disableTimer(timer, repeat=True, record=True)
+                                       elif choice[1] == "disablerepeat":
+                                               self.disableTimer(timer, repeat=True)
+                       self.session.openWithCallback(timerAction, ChoiceBox, title=title_text + _("Select action for timer '%s'.") % timer.name, list=menu, keys=buttons)
                else:
                        newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
                        self.session.openWithCallback(self.finishedTimerAdd, TimerEntry, newEntry)
@@ -1139,8 +1197,15 @@ class GraphMultiEPG(Screen, HelpableScreen):
                                                        simulTimerList = self.session.nav.RecordTimer.record(entry)
                                        if simulTimerList is not None:
                                                self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList)
-                       self["key_green"].setText(_("Change timer"))
-                       self.key_green_choice = self.REMOVE_TIMER
+                                               return
+                       cur = self["list"].getCurrent()
+                       event = cur and cur[0]
+                       if event:
+                               begin = event.getBeginTime()
+                               end = begin + event.getDuration()
+                               if begin < entry.begin <= end or entry.begin <= begin <= entry.end:
+                                       self["key_green"].setText(_("Change timer"))
+                                       self.key_green_choice = self.REMOVE_TIMER
                else:
                        self["key_green"].setText(_("Add timer"))
                        self.key_green_choice = self.ADD_TIMER
@@ -1177,10 +1242,13 @@ class GraphMultiEPG(Screen, HelpableScreen):
                        return
 
                eventid = event.getEventId()
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(servicerefref.toString().split(':')[:11])
                isRecordEvent = False
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and (timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end) or timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event)):
                                isRecordEvent = True
                                break
                if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
index eb22fa3..60541fd 100644 (file)
@@ -284,40 +284,98 @@ class EPGSelection(Screen):
                self["key_green"].setText(_("Add timer"))
                self.key_green_choice = self.ADD_TIMER
 
-       def disableTimer(self, timer):
-               timer.disable()
-               self.session.nav.RecordTimer.timeChanged(timer)
-               self["key_green"].setText(_("Add timer"))
-               self.key_green_choice = self.ADD_TIMER
+       def disableTimer(self, timer, repeat=False, record=False):
+               if repeat:
+                       if record:
+                               title_text = _("Repeating event currently recording.\nWhat do you want to do?")
+                               menu = [(_("Stop current event but not coming events"), "stoponlycurrent"),(_("Stop current event and disable coming events"), "stopall")]
+                               if not timer.disabled:
+                                       menu.append((_("Don't stop current event but disable coming events"), "stoponlycoming"))
+                       else:
+                               title_text = _("Attention, this is repeated timer!\nWhat do you want to do?")
+                               menu = [(_("Disable current event but not coming events"), "nextonlystop"),(_("Disable timer"), "simplestop")]
+                       self.session.openWithCallback(boundFunction(self.runningEventCallback, timer), ChoiceBox, title=title_text, list=menu)
+               else:
+                       timer.disable()
+                       self.session.nav.RecordTimer.timeChanged(timer)
+                       self["key_green"].setText(_("Add timer"))
+                       self.key_green_choice = self.ADD_TIMER
+
+       def runningEventCallback(self, t, result):
+               if result is not None:
+                       findNextRunningEvent = True
+                       findEventNext = False 
+                       if result[1] == "nextonlystop":
+                               findEventNext = True
+                               t.disable()
+                               self.session.nav.RecordTimer.timeChanged(t)
+                               t.processRepeated(findNextEvent=True)
+                               t.enable()
+                       if result[1] in ("stoponlycurrent", "stopall"):
+                               findNextRunningEvent = False
+                               t.enable()
+                               t.processRepeated(findRunningEvent=False)
+                               self.session.nav.RecordTimer.doActivate(t)
+                       if result[1] in ("stoponlycoming", "stopall", "simplestop"):
+                               findNextRunningEvent = True
+                               t.disable()
+                       self.session.nav.RecordTimer.timeChanged(t)
+                       t.findRunningEvent = findNextRunningEvent
+                       t.findNextEvent = findEventNext
+                       if result[1] in ("stoponlycurrent", "stopall", "simplestop", "nextonlystop"):
+                               self["key_green"].setText(_("Add timer"))
+                               self.key_green_choice = self.ADD_TIMER
 
        def timerAdd(self):
                cur = self["list"].getCurrent()
                event = cur[0]
-               serviceref = cur[1]
                if event is None:
                        return
+               serviceref = cur[1]
+               isRecordEvent = isRepeat = firstNextRepeatEvent = False
                eventid = event.getEventId()
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
-                               menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
-                               buttons = ["red", "green"]
-                               if not timer.isRunning():
-                                       menu.append((_("Disable timer"), "disable"))
-                                       buttons.append("yellow")
-                               menu.append((_("Timer Overview"), "timereditlist"))
-                               def timerAction(choice):
-                                       if choice is not None:
-                                               if choice[1] == "delete":
-                                                       self.removeTimer(timer)
-                                               elif choice[1] == "edit":
-                                                       self.session.open(TimerEntry, timer)
-                                               elif choice[1] == "disable":
-                                                       self.disableTimer(timer)
-                                               elif choice[1] == "timereditlist":
-                                                       self.session.open(TimerEditList)
-                               self.session.openWithCallback(timerAction, ChoiceBox, title=_("Select action for timer %s:") % event.getEventName(), list=menu, keys=buttons)
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end):
+                               isRecordEvent = True
                                break
+                       elif needed_ref and timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event):
+                               isRecordEvent = True
+                               break
+               if isRecordEvent:
+                       isRepeat = timer.repeated
+                       title_text = isRepeat and _("Attention, this is repeated timer!\n") or ""
+                       firstNextRepeatEvent = isRepeat and (begin < timer.begin <= end or timer.begin <= begin <= timer.end) and not timer.justplay 
+                       menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
+                       buttons = ["red", "green"]
+                       if not timer.isRunning():
+                               if firstNextRepeatEvent and timer.isFindRunningEvent() and not timer.isFindNextEvent():
+                                       menu.append((_("Options disable timer"), "disablerepeat"))
+                               else:
+                                       menu.append((_("Disable timer"), "disable"))
+                               buttons.append("yellow")
+                       elif firstNextRepeatEvent:
+                               menu.append((_("Options disable timer"), "disablerepeatrunning"))
+                               buttons.append("yellow")
+                       menu.append((_("Timer Overview"), "timereditlist"))
+                       def timerAction(choice):
+                               if choice is not None:
+                                       if choice[1] == "delete":
+                                               self.removeTimer(timer)
+                                       elif choice[1] == "edit":
+                                               self.session.open(TimerEntry, timer)
+                                       elif choice[1] == "disable":
+                                               self.disableTimer(timer)
+                                       elif choice[1] == "timereditlist":
+                                               self.session.open(TimerEditList)
+                                       elif choice[1] == "disablerepeatrunning":
+                                               self.disableTimer(timer, repeat=True, record=True)
+                                       elif choice[1] == "disablerepeat":
+                                               self.disableTimer(timer, repeat=True)
+                       self.session.openWithCallback(timerAction, ChoiceBox, title=title_text + _("Select action for timer '%s'.") % timer.name, list=menu, keys=buttons)
                else:
                        newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(event))
                        self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
@@ -347,8 +405,15 @@ class EPGSelection(Screen):
                                                        simulTimerList = self.session.nav.RecordTimer.record(entry)
                                        if simulTimerList is not None:
                                                self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList)
-                       self["key_green"].setText(_("Change timer"))
-                       self.key_green_choice = self.REMOVE_TIMER
+                                               return
+                       cur = self["list"].getCurrent()
+                       event = cur and cur[0]
+                       if event:
+                               begin = event.getBeginTime()
+                               end = begin + event.getDuration()
+                               if begin < entry.begin <= end or entry.begin <= begin <= entry.end:
+                                       self["key_green"].setText(_("Change timer"))
+                                       self.key_green_choice = self.REMOVE_TIMER
                else:
                        self["key_green"].setText(_("Add timer"))
                        self.key_green_choice = self.ADD_TIMER
@@ -456,10 +521,13 @@ class EPGSelection(Screen):
 
                serviceref = cur[1]
                eventid = event.getEventId()
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
                isRecordEvent = False
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and (timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end) or timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event)):
                                isRecordEvent = True
                                break
                if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
index e092e5d..5f87552 100644 (file)
@@ -90,19 +90,29 @@ class EventViewBase:
                if event is None:
                        return
                eventid = event.getEventId()
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
+               isRecordEvent = False
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
-                               menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
-                               buttons = ["red", "green"]
-                               def timerAction(choice):
-                                       if choice is not None:
-                                               if choice[1] == "delete":
-                                                       self.removeTimer(timer)
-                                               elif choice[1] == "edit":
-                                                       self.session.open(TimerEntry, timer)
-                               self.session.openWithCallback(timerAction, ChoiceBox, title=_("Select action for timer %s:") % event.getEventName(), list=menu, keys=buttons)
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end):
+                               isRecordEvent = True
+                               break
+                       elif needed_ref and timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event):
+                               isRecordEvent = True
                                break
+               if isRecordEvent:
+                       title_text = timer.repeated and _("Attention, this is repeated timer!\n") or ""
+                       menu = [(_("Delete timer"), "delete"),(_("Edit timer"), "edit")]
+                       buttons = ["red", "green"]
+                       def timerAction(choice):
+                               if choice is not None:
+                                       if choice[1] == "delete":
+                                               self.removeTimer(timer)
+                                       elif choice[1] == "edit":
+                                               self.session.open(TimerEntry, timer)
+                       self.session.openWithCallback(timerAction, ChoiceBox, title=title_text + _("Select action for timer '%s'.") % timer.name, list=menu, keys=buttons)
                else:
                        newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event))
                        self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
@@ -192,10 +202,13 @@ class EventViewBase:
 
                serviceref = self.currentService
                eventid = self.event.getEventId()
+               begin = event.getBeginTime()
+               end = begin + event.getDuration()
                refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
                isRecordEvent = False
                for timer in self.session.nav.RecordTimer.timer_list:
-                       if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
+                       needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr
+                       if needed_ref and (timer.eit == eventid and (begin < timer.begin <= end or timer.begin <= begin <= timer.end) or timer.repeated and self.session.nav.RecordTimer.isInRepeatTimer(timer, event)):
                                isRecordEvent = True
                                break
                if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
index 9727abf..e7fdbfa 100644 (file)
--- a/timer.py
+++ b/timer.py
@@ -14,6 +14,8 @@ class TimerEntry:
                self.prepare_time = 20
                self.end = end
                self.state = 0
+               self.findRunningEvent = True
+               self.findNextEvent = False
                self.resetRepeated()
                #begindate = localtime(self.begin)
                #newdate = datetime.datetime(begindate.tm_year, begindate.tm_mon, begindate.tm_mday 0, 0, 0);
@@ -26,6 +28,8 @@ class TimerEntry:
                self.state = self.StateWaiting
                self.cancelled = False
                self.first_try_prepare = True
+               self.findRunningEvent = True
+               self.findNextEvent = False
                self.timeChanged()
 
        def resetRepeated(self):
@@ -44,11 +48,20 @@ class TimerEntry:
                        return (datetime.datetime(timedatestruct.tm_year, timedatestruct.tm_mon, timedatestruct.tm_mday, timedatestruct.tm_hour, timedatestruct.tm_min, timedatestruct.tm_sec) + datetime.timedelta(days=2)).timetuple()
                return newdate
 
+       def isFindRunningEvent(self):
+               return self.findRunningEvent
+
+       def isFindNextEvent(self):
+               return self.findNextEvent
+
        # update self.begin and self.end according to the self.repeated-flags
-       def processRepeated(self, findRunningEvent = True):
+       def processRepeated(self, findRunningEvent=True, findNextEvent=False):
                if (self.repeated != 0):
                        now = int(time()) + 1
-
+                       if findNextEvent:
+                               now = self.end + 120
+                       self.findRunningEvent = findRunningEvent
+                       self.findNextEvent = findNextEvent
                        #to avoid problems with daylight saving, we need to calculate with localtime, in struct_time representation
                        localrepeatedbegindate = localtime(self.repeatedbegindate)
                        localbegin = localtime(self.begin)