aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-10-29 22:34:37 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-10-29 22:34:37 +0000
commit80058dea34aae48ed729986a65112f0096f5b2d5 (patch)
tree48b2ca8b1fd44b3d5591347153554cb6a6cdd68d /lib
parent7f38db72b754a1a5205f2e904aaacf5822793198 (diff)
downloadenigma2-80058dea34aae48ed729986a65112f0096f5b2d5.tar.gz
enigma2-80058dea34aae48ed729986a65112f0096f5b2d5.zip
add ability to filter by tag. they must be created by hand right now.
Diffstat (limited to 'lib')
-rw-r--r--lib/python/Components/MovieList.py30
-rw-r--r--lib/python/Screens/MovieSelection.py89
2 files changed, 106 insertions, 13 deletions
diff --git a/lib/python/Components/MovieList.py b/lib/python/Components/MovieList.py
index 1a61d20f..fca96e24 100644
--- a/lib/python/Components/MovieList.py
+++ b/lib/python/Components/MovieList.py
@@ -14,6 +14,7 @@ class MovieList(HTMLComponent, GUIComponent):
def __init__(self, root):
GUIComponent.__init__(self)
self.l = eListboxPythonMultiContent()
+ self.tags = set()
if root is not None:
self.reload(root)
self.l.setFont(0, gFont("Regular", 22))
@@ -73,11 +74,11 @@ class MovieList(HTMLComponent, GUIComponent):
instance.setContent(self.l)
instance.setItemHeight(75)
- def reload(self, root = None):
+ def reload(self, root = None, filter_tags = None):
if root is not None:
- self.load(root)
+ self.load(root, filter_tags)
else:
- self.load(self.root)
+ self.load(self.root, filter_tags)
self.l.setList(self.list)
def removeService(self, service):
@@ -95,7 +96,7 @@ class MovieList(HTMLComponent, GUIComponent):
self.list[index] = (x[0], x[1], x[2], x[1].getLength(x[0]))
self.l.invalidateEntry(index)
- def load(self, root):
+ def load(self, root, filter_tags):
# this lists our root service, then building a
# nice list
@@ -105,6 +106,8 @@ class MovieList(HTMLComponent, GUIComponent):
self.serviceHandler = eServiceCenter.getInstance()
list = self.serviceHandler.list(root)
+ tags = set()
+
if list is None:
raise "listing of movies failed"
@@ -118,9 +121,28 @@ class MovieList(HTMLComponent, GUIComponent):
if info is None:
continue
begin = info.getInfo(serviceref, iServiceInformation.sTimeCreate)
+
+ # convert space-seperated list of tags into a set
+ this_tags = info.getInfoString(serviceref, iServiceInformation.sTags).split(' ')
+ if this_tags == ['']:
+ this_tags = []
+ this_tags = set(this_tags)
+
+ # filter_tags is either None (which means no filter at all), or
+ # a set. In this case, all elements of filter_tags must be present,
+ # otherwise the entry will be dropped.
+ if filter_tags is not None and not this_tags.issuperset(filter_tags):
+ continue
+
+ tags |= this_tags
self.list.append((serviceref, info, begin, -1))
+ # sort: key is 'begin'
self.list.sort(key=lambda x: -x[2])
+
+ # finally, store a list of all tags which were found. these can be presented
+ # to the user to filter the list
+ self.tags = tags
def moveTo(self, serviceref):
found = 0
diff --git a/lib/python/Screens/MovieSelection.py b/lib/python/Screens/MovieSelection.py
index add42abf..a2763c3a 100644
--- a/lib/python/Screens/MovieSelection.py
+++ b/lib/python/Screens/MovieSelection.py
@@ -70,6 +70,11 @@ class MovieSelection(Screen):
def __init__(self, session, selectedmovie = None):
Screen.__init__(self, session)
+ self.tags = [ ]
+ self.selected_tags = None
+
+ self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD))
+
self.movemode = False
self.bouquet_mark_edit = False
@@ -82,15 +87,25 @@ class MovieSelection(Screen):
self.list = self["list"]
self.selectedmovie = selectedmovie
+ self["key_red"] = Button(_("All..."))
+ self["key_green"] = Button("")
+ self["key_yellow"] = Button("")
+ self["key_blue"] = Button("")
+
#self["okbutton"] = Button("ok", [self.channelSelected])
self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
- self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions"],
+ self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions", "ColorActions"],
{
"cancel": self.abort,
"ok": self.movieSelected,
"showEventInfo": self.showEventInformation,
"contextMenu": self.doContext,
+
+ "red": self.showAll,
+ "yellow": self.showTagsFirst,
+ "green": self.showTagsSecond,
+ "blue": self.showTagsMenu,
})
self["actions"].csel = self
self.onShown.append(self.go)
@@ -114,17 +129,15 @@ class MovieSelection(Screen):
self.inited=True
def updateHDDData(self):
- self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
- if (self.selectedmovie is not None):
+ self.reloadList()
+ if self.selectedmovie is not None:
self.moveTo()
self["waitingtext"].instance.hide()
-
+
self["freeDiskSpace"].update()
-
- self.lengthTimer.start(10, 1)
- self.lengthPosition = 0
- self.lengthLength = len(self["list"])
-
+
+ self.updateTags()
+
def updateLengthData(self):
self.list.updateLengthOfIndex(self.lengthPosition)
self.lengthPosition += 1
@@ -150,3 +163,61 @@ class MovieSelection(Screen):
def abort(self):
self.close(None)
+
+ def updateTags(self):
+ # get a list of tags available in this list
+ self.tags = list(self["list"].tags)
+
+ # by default, we do not display any filtering options
+ self.tag_first = ""
+ self.tag_second = ""
+
+ # when tags are present, however, the first two are
+ # directly mapped to the second, third ("green", "yellow") buttons
+ if len(self.tags) > 0:
+ self.tag_first = self.tags[0]
+
+ if len(self.tags) > 1:
+ self.tag_second = self.tags[1]
+
+ self["key_green"].text = self.tag_first
+ self["key_yellow"].text = self.tag_second
+
+ # the rest is presented in a list, available on the
+ # fourth ("blue") button
+ if len(self.tags) > 2:
+ self["key_blue"].text = _("Other...")
+ else:
+ self["key_blue"].text = ""
+
+ def reloadList(self):
+ self["list"].reload(self.current_ref, self.selected_tags)
+ self.lengthTimer.start(10, 1)
+ self.lengthPosition = 0
+ self.lengthLength = len(self["list"])
+
+ def showAll(self):
+ self.selected_tags = None
+ self.reloadList()
+
+ def showTagsN(self, n):
+ if len(self.tags) < n:
+ self.showTagWarning()
+ else:
+ self.selected_tags = set([self.tags[n - 1]])
+ self.reloadList()
+
+ def showTagsFirst(self):
+ self.showTagsN(1)
+
+ def showTagsSecond(self):
+ self.showTagsN(2)
+
+ def showTagsMenu(self):
+ if len(self.tags) < 3:
+ self.showTagWarning()
+ else:
+ pass
+
+ def showTagWarning(self):
+ print "select some tags first!"