+
+ def getMutableList(self, root=eServiceReference()):
+ if not self.mutableList is None:
+ return self.mutableList
+ serviceHandler = eServiceCenter.getInstance()
+ if not root.valid():
+ root=self.servicelist.getRoot()
+ list = serviceHandler.list(root)
+ if list is not None:
+ return list.startEdit()
+ return None
+
+# multiple marked entry stuff ( edit mode, later multiepg selection )
+ def startMarkedEdit(self):
+ self.mutableList = self.getMutableList()
+ # add all services from the current list to internal marked set in listboxservicecontent
+ self.bouquetRoot = self.servicelist.getRoot()
+ self.clearMarks() # this clears the internal marked set in the listboxservicecontent
+ self.bouquet_mark_edit = True
+ self.__marked = self.servicelist.getRootServices()
+ for x in self.__marked:
+ self.servicelist.addMarked(eServiceReference(x))
+
+ def endMarkedEdit(self, abort):
+ if not abort and self.mutableList is not None:
+ new_marked = set(self.servicelist.getMarked())
+ old_marked = set(self.__marked)
+ removed = old_marked - new_marked
+ added = new_marked - old_marked
+ changed = False
+ for x in removed:
+ changed = True
+ self.mutableList.removeService(eServiceReference(x))
+ for x in added:
+ changed = True
+ self.mutableList.addService(eServiceReference(x))
+ if changed:
+ self.mutableList.flushChanges()
+ self.setRoot(self.bouquetRoot)
+ #self.showFavourites()
+ self.__marked = []
+ self.clearMarks()
+ self.bouquet_mark_edit = False
+ self.bouquetRoot = None
+ self.mutableList = None
+
+ def clearMarks(self):
+ self.servicelist.clearMarks()
+
+ def doMark(self):
+ ref = self.servicelist.getCurrent()
+ if self.servicelist.isMarked(ref):
+ self.servicelist.removeMarked(ref)
+ else:
+ self.servicelist.addMarked(ref)
+
+ def removeCurrentService(self):
+ ref = self.servicelist.getCurrent()
+ mutableList = self.getMutableList()
+ if ref.valid() and mutableList is not None:
+ if not mutableList.removeService(ref):
+ mutableList.flushChanges() #FIXME dont flush on each single removed service
+ self.setRoot(self.servicelist.getRoot())
+
+ def addCurrentServiceToBouquet(self, dest):
+ mutableList = self.getMutableList(dest)
+ if not mutableList is None:
+ if not mutableList.addService(self.servicelist.getCurrent()):
+ mutableList.flushChanges()
+ self.close()
+
+ def toggleMoveMode(self):
+ if self.movemode:
+ if self.entry_marked:
+ self.toggleMoveMarked() # unmark current entry
+ self.movemode = False
+ self.mutableList.flushChanges() # FIXME add check if changes was made
+ self.mutableList = None
+ else:
+ self.mutableList = self.getMutableList()
+ self.movemode = True
+
+ def handleEditCancel(self):
+ if self.movemode: #movemode active?
+ self.channelSelected() # unmark
+ self.toggleMoveMode() # disable move mode
+ elif self.bouquet_mark_edit:
+ self.endMarkedEdit(True) # abort edit mode
+
+ def toggleMoveMarked(self):
+ if self.entry_marked:
+ self.servicelist.setCurrentMarked(False)
+ self.entry_marked = False
+ else:
+ self.servicelist.setCurrentMarked(True)
+ self.entry_marked = True
+
+ def doContext(self):
+ self.session.open(ChannelContextMenu, self)
+
+class ChannelSelectionBase(Screen):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+ # this makes it much simple to implement a selectable radio or tv mode :)
+ self.service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17)'
+ self.service_types_radio = '1:7:1:0:0:0:0:0:0:0:(type == 2)'
+
+ self.service_types = self.service_types_tv
+
+ self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
+ #self.bouquet_root = eServiceReference('%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types))
+