EPG event: add check timer sanity conflict when edit timer
authorDima73 <Dima-73@inbox.lv>
Fri, 13 Nov 2015 21:05:31 +0000 (23:05 +0200)
committerErik Slagter <erik@openpli.org>
Sat, 14 Nov 2015 17:07:53 +0000 (18:07 +0100)
(cherry picked from commit 0d386ddcbb5d31f9214f474a39b8a7976fe96ca4)
Signed-off-by: Erik Slagter <erik@openpli.org>

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

index 4e27663..e392a49 100644 (file)
@@ -1244,7 +1244,7 @@ class GraphMultiEPG(Screen, HelpableScreen):
                                        if choice[1] == "delete":
                                                self.removeTimer(timer)
                                        elif choice[1] == "edit":
-                                               self.session.open(TimerEntry, timer)
+                                               self.session.openWithCallback(self.finishedEdit, TimerEntry, timer)
                                        elif choice[1] == "disable":
                                                self.disableTimer(timer, prev_state)
                                        elif choice[1] == "timereditlist":
@@ -1258,6 +1258,22 @@ class GraphMultiEPG(Screen, HelpableScreen):
                        newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
                        self.session.openWithCallback(self.finishedTimerAdd, TimerEntry, newEntry)
 
+       def finishedEdit(self, answer=None):
+               if answer[0]:
+                       entry = answer[1]
+                       simulTimerList = self.session.nav.RecordTimer.record(entry)
+                       if simulTimerList is not None:
+                               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.finishedEdit, TimerSanityConflict, simulTimerList)
+                                       return
+                               else:
+                                       self.session.nav.RecordTimer.timeChanged(entry)
+               self.onSelectionChanged()
+
        def finishedTimerAdd(self, answer):
                print "finished add"
                if answer[0]:
index d6a3e4d..427972f 100644 (file)
@@ -369,7 +369,7 @@ class EPGSelection(Screen):
                                        if choice[1] == "delete":
                                                self.removeTimer(timer)
                                        elif choice[1] == "edit":
-                                               self.session.open(TimerEntry, timer)
+                                               self.session.openWithCallback(self.finishedEdit, TimerEntry, timer)
                                        elif choice[1] == "disable":
                                                self.disableTimer(timer, prev_state)
                                        elif choice[1] == "timereditlist":
@@ -383,6 +383,22 @@ class EPGSelection(Screen):
                        newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(event))
                        self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
 
+       def finishedEdit(self, answer=None):
+               if answer[0]:
+                       entry = answer[1]
+                       simulTimerList = self.session.nav.RecordTimer.record(entry)
+                       if simulTimerList is not None:
+                               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.finishedEdit, TimerSanityConflict, simulTimerList)
+                                       return
+                               else:
+                                       self.session.nav.RecordTimer.timeChanged(entry)
+               self.onSelectionChanged()
+
        def finishedAdd(self, answer):
                print "finished add"
                if answer[0]:
index 5f87552..2497e32 100644 (file)
@@ -111,12 +111,35 @@ class EventViewBase:
                                        if choice[1] == "delete":
                                                self.removeTimer(timer)
                                        elif choice[1] == "edit":
-                                               self.session.open(TimerEntry, timer)
+                                               self.session.openWithCallback(self.finishedEdit, 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)
 
+       def finishedEdit(self, answer=None):
+               if answer[0]:
+                       entry = answer[1]
+                       simulTimerList = self.session.nav.RecordTimer.record(entry)
+                       if simulTimerList is not None:
+                               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.finishedEdit, TimerSanityConflict, simulTimerList)
+                                       return
+                               else:
+                                       self.session.nav.RecordTimer.timeChanged(entry)
+               if answer is not None:
+                       entry = answer[1]
+                       if not entry.disabled:
+                               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
+
        def finishedAdd(self, answer):
                print "finished add"
                if answer[0]: