fix newline
[enigma2.git] / lib / python / Components / ServiceList.py
index b1bd217069f6c131a26736876104177248267269..d008c475682ea29a51f79a69c72113b75374d4ee 100644 (file)
@@ -3,42 +3,126 @@ from GUIComponent import *
 
 from enigma import *
 
 
 from enigma import *
 
+from string import upper
+
 class ServiceList(HTMLComponent, GUIComponent):
 class ServiceList(HTMLComponent, GUIComponent):
+
+       MODE_NORMAL = 0
+       MODE_FAVOURITES = 1
+
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
+               self.root = None
                
                
+               self.mode = self.MODE_NORMAL
+
+       def setCurrent(self, ref):
+               self.l.setCurrent(ref)
+
        def getCurrent(self):
                r = eServiceReference()
                self.l.getCurrent(r)
                return r
        def getCurrent(self):
                r = eServiceReference()
                self.l.getCurrent(r)
                return r
-               
+
        def moveUp(self):
                self.instance.moveSelection(self.instance.moveUp)
 
        def moveDown(self):
                self.instance.moveSelection(self.instance.moveDown)
        def moveUp(self):
                self.instance.moveSelection(self.instance.moveUp)
 
        def moveDown(self):
                self.instance.moveSelection(self.instance.moveDown)
+               
+       def moveToChar(self, char):
+               # TODO fill with life
+               print "Next char: "
+               index = self.l.getNextBeginningWithChar(char)
+               indexup = self.l.getNextBeginningWithChar(upper(char))
+               if indexup != 0:
+                       if (index > indexup or index == 0):
+                               index = indexup
+
+               self.instance.moveSelectionTo(index)
+               print "Moving to character " + str(char)
 
 
-       def GUIcreate(self, parent, skindata):
+       def GUIcreate(self, parent):
                self.instance = eListbox(parent)
                self.instance.setContent(self.l)
                self.instance = eListbox(parent)
                self.instance.setContent(self.l)
+               self.setMode(self.mode)
        
        def GUIdelete(self):
                self.instance = None
 
        
        def GUIdelete(self):
                self.instance = None
 
+       def getRoot(self):
+               return self.root
+
+       def getRootServices(self):
+               serviceHandler = eServiceCenter.getInstance()
+               list = serviceHandler.list(self.root)
+               dest = [ ]
+               if list is not None:
+                       while 1:
+                               s = list.getNext()
+                               if s.valid():
+                                       dest.append(s.toString())
+                               else:
+                                       break
+               return dest
+
+       def setNumberOffset(self, offset):
+               self.l.setNumberOffset(offset)
+
+       def setPlayableIgnoreService(self, ref):
+               self.l.setIgnoreService(ref)
+
        def setRoot(self, root):
        def setRoot(self, root):
+               self.root = root
                self.l.setRoot(root)
                self.l.setRoot(root)
-               
-               # mark stuff
-       def clearMarked(self):
-               self.l.clearMarked()
-       
+               self.l.sort()
+
+# stuff for multiple marks (edit mode / later multiepg)
+       def clearMarks(self):
+               self.l.initMarked()
+
        def isMarked(self, ref):
                return self.l.isMarked(ref)
 
        def addMarked(self, ref):
                self.l.addMarked(ref)
        def isMarked(self, ref):
                return self.l.isMarked(ref)
 
        def addMarked(self, ref):
                self.l.addMarked(ref)
-       
+
        def removeMarked(self, ref):
                self.l.removeMarked(ref)
 
        def removeMarked(self, ref):
                self.l.removeMarked(ref)
 
+       def getMarked(self):
+               i = self.l
+               i.markedQueryStart()
+               ref = eServiceReference()
+               marked = [ ]
+               while i.markedQueryNext(ref) == 0:
+                       marked.append(ref.toString())
+                       ref = eServiceReference()
+               return marked
+
+#just for movemode.. only one marked entry..
+       def setCurrentMarked(self, state):
+               self.l.setCurrentMarked(state)
+
+       def setMode(self, mode):
+               self.mode = mode
+
+               try:
+                       self.instance
+               except:
+                       return
+               
+               if mode == self.MODE_NORMAL:
+                       self.instance.setItemHeight(28)
+                       self.l.setVisualMode(eListboxServiceContent.visModeSimple)
+                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
+                       self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
+               else:
+                       self.instance.setItemHeight(28)
+                       self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
+                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 40, 28))
+                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
+                       self.l.setElementPosition(self.l.celServiceName, eRect(50, 0, self.instance.size().width()-50, 28))
+                       self.l.setElementFont(self.l.celServiceInfo, gFont("Arial", 18))
+                       self.l.setVisualMode(eListboxServiceContent.visModeComplex)