jumping to an entry beginning with a character nearly works now
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 30 Nov 2005 14:15:56 +0000 (14:15 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 30 Nov 2005 14:15:56 +0000 (14:15 +0000)
lib/gui/elistbox.cpp
lib/gui/elistbox.h
lib/python/Components/ServiceList.py
lib/python/Screens/ChannelSelection.py
lib/service/listboxservice.cpp
lib/service/listboxservice.h

index 28d220a..873cc93 100644 (file)
@@ -121,6 +121,12 @@ void eListbox::moveSelection(int dir)
        }
 }
 
+void eListbox::moveSelectionTo(int index)
+{
+       printf("Moving to listbox-entry with index %d\n", index);
+       // TODO: implement it
+}
+
 int eListbox::event(int event, void *data, void *data2)
 {
        switch (event)
index a7ed637..60429d2 100644 (file)
@@ -63,6 +63,7 @@ public:
        }; */
        
        void moveSelection(int how);
+       void moveSelectionTo(int index);
 
        enum ListboxActions {
                moveUp,
index 89b40ed..e04594e 100644 (file)
@@ -3,6 +3,8 @@ from GUIComponent import *
 
 from enigma import *
 
+from string import upper
+
 class ServiceList(HTMLComponent, GUIComponent):
 
        MODE_NORMAL = 0
@@ -28,6 +30,16 @@ class ServiceList(HTMLComponent, GUIComponent):
 
        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 (index > indexup):
+                       index = indexup
+               self.instance.moveSelectionTo(index)
+               print "Moving to character " + str(char)
 
        def GUIcreate(self, parent):
                self.instance = eListbox(parent)
index 565655f..3cca57f 100644 (file)
@@ -276,9 +276,10 @@ class ChannelSelectionBase(Screen):
                self.setRoot(self.bouquet_root)
 
        def keyNumberGlobal(self, number):
+               char = self.numericalTextInput.getKey(number)
                print "You pressed number " + str(number)
-               print "You would go to character " + str(self.numericalTextInput.getKey(number))
-               # TODO let the servicelist jump to the next entry strating with the chosen character
+               print "You would go to character " + str(char)
+               self.servicelist.moveToChar(char)
 
        def enterBouquet(self, action):
                if action[:7] == "bouquet":
index 9eafc85..e336dc1 100644 (file)
@@ -44,6 +44,23 @@ void eListboxServiceContent::getCurrent(eServiceReference &ref)
                ref = eServiceReference();
 }
 
+int eListboxServiceContent::getNextBeginningWithChar(char c)
+{
+//     printf("Char: %c\n", c);
+       int index=0;
+       for (list::iterator i(m_list.begin()); i != m_list.end(); ++i, ++index)
+       {
+               std::string text;
+               ePtr<iStaticServiceInformation> service_info;
+               m_service_center->info(*i, service_info);
+               service_info->getName(*i, text);
+//             printf("%c\n", text.c_str()[0]);
+               if (text.c_str()[0] == c)
+                       return index;
+       }
+       return 0;
+}
+
 void eListboxServiceContent::initMarked()
 {
        m_marked.clear();
index 1d5dc2a..ae0ec5a 100644 (file)
@@ -15,6 +15,8 @@ public:
        eListboxServiceContent();
        void setRoot(const eServiceReference &ref);
        void getCurrent(eServiceReference &ref);
+       
+       int getNextBeginningWithChar(char c);
 
                /* support for marked services */
        void initMarked();