From 494169d25068e3d3dd2dcc8b37b42d32df6935e7 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Wed, 30 Nov 2005 14:15:56 +0000 Subject: [PATCH] jumping to an entry beginning with a character nearly works now --- lib/gui/elistbox.cpp | 6 ++++++ lib/gui/elistbox.h | 1 + lib/python/Components/ServiceList.py | 12 ++++++++++++ lib/python/Screens/ChannelSelection.py | 5 +++-- lib/service/listboxservice.cpp | 17 +++++++++++++++++ lib/service/listboxservice.h | 2 ++ 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index 28d220a2..873cc937 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -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) diff --git a/lib/gui/elistbox.h b/lib/gui/elistbox.h index a7ed637d..60429d2e 100644 --- a/lib/gui/elistbox.h +++ b/lib/gui/elistbox.h @@ -63,6 +63,7 @@ public: }; */ void moveSelection(int how); + void moveSelectionTo(int index); enum ListboxActions { moveUp, diff --git a/lib/python/Components/ServiceList.py b/lib/python/Components/ServiceList.py index 89b40ed2..e04594ee 100644 --- a/lib/python/Components/ServiceList.py +++ b/lib/python/Components/ServiceList.py @@ -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) diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 565655f9..3cca57fa 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -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": diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp index 9eafc853..e336dc17 100644 --- a/lib/service/listboxservice.cpp +++ b/lib/service/listboxservice.cpp @@ -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 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(); diff --git a/lib/service/listboxservice.h b/lib/service/listboxservice.h index 1d5dc2a2..ae0ec5a6 100644 --- a/lib/service/listboxservice.h +++ b/lib/service/listboxservice.h @@ -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(); -- 2.30.2