Beginnings of filtering

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@42 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-07-02 17:13:40 +00:00
parent 22c61164c1
commit 1c1c99ed81
3 changed files with 73 additions and 12 deletions

View File

@ -15,6 +15,7 @@ class LibView(gtk.VBox):
self.data = data
self.treeview = None
self.col = None
self.plist = None
self.pbar = gtk.ProgressBar()
self.pack_start(self.win)
self.pack_start(self.pbar,False,False,0)
@ -41,6 +42,7 @@ class LibView(gtk.VBox):
tree.append(aliter,[self.data.library.files[track].title,self.data.library.files[track].id])
tree.set_sort_column_id(0,gtk.SORT_ASCENDING)
self.treeview = gtk.TreeView(tree)
self.treeview.set_hover_expand(True)
self.treeview.set_enable_search(True)
self.treeview.connect("button_release_event",self.clicked)
self.col = gtk.TreeViewColumn('Library ('+str(self.data.library.count)+')')
@ -91,19 +93,23 @@ class LibView(gtk.VBox):
def populatePlaylist(self,widgit,func,data):
(model,pathlist) = self.selection.get_selected_rows()
self.data.curList = []
list = []
#self.data.curList = []
for path in pathlist:
iter = model.get_iter(path)
self.popHelper(model,iter,model.iter_n_children(iter))
self.data.updateList = True
self.popHelper(model,iter,model.iter_n_children(iter),list)
#self.data.updateList = True
self.plist.addToList(list,self.plist.plist)
def popHelper(self,model,iter,count):
def popHelper(self,model,iter,count,list):
if count == 0:
self.data.curList+=[model[iter][1]]
row = model[iter][1]
self.data.curList+=[row]
list += [row]
return
child = model.iter_children(iter)
for i in range(count):
self.popHelper(model,child,model.iter_n_children(child))
self.popHelper(model,child,model.iter_n_children(child),list)
child = model.iter_next(child)

View File

@ -23,6 +23,7 @@ class PlistView(gtk.Notebook):
self.ptime = 0
self.qtime = 0
self.search = ""
self.label = gtk.Label("")
self.label.show()
@ -35,9 +36,10 @@ class PlistView(gtk.Notebook):
self.qtree = None
self.makePList()
self.makeQList()
self.makeSearch()
self.qwin.show()
self.loadSong(True)
gobject.timeout_add(1000,self.checkUpdate)
#gobject.timeout_add(1000,self.checkUpdate)
self.append_page(self.pwin,gtk.Label(""))
self.append_page(self.qwin,gtk.Label(""))
self.setTabText("plist")
@ -79,6 +81,9 @@ class PlistView(gtk.Notebook):
self.plist.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING)
self.ptree.connect("button_release_event",self.clicked)
self.ptime = self.popList(self.data.curList,self.plist)
self.pfilter = self.plist.filter_new()
self.pfilter.set_visible_func(self.hideRows)
self.ptree.set_model(self.pfilter)
# Populate a list
@ -107,6 +112,13 @@ class PlistView(gtk.Notebook):
return time
# Called by libview to add rows to list
def addToList(self,src,dest):
self.ptime+=self.generateList(src,dest)
self.updatePTime()
self.setTabText("plist")
# Make the playlist and show it
def list2Tree(self,list):
tree = gtk.TreeView(list)
@ -149,7 +161,7 @@ class PlistView(gtk.Notebook):
# Erase the entire list
def clearList(self,list):
def clearList(self,list,time):
max = len(list)
if max == 0:
return
@ -157,6 +169,16 @@ class PlistView(gtk.Notebook):
iter = list.get_iter(0)
for i in range(0,max):
list.remove(iter)
self.ptime = 0
self.setTabText("plist")
self.updatePTime()
# Update the playlist time label
def updatePTime(self):
page = self.get_current_page()
if page==0:
self.label.set_text(self.makeTimeLabel(self.ptime))
# Shows total running time of the playlist
@ -215,7 +237,7 @@ class PlistView(gtk.Notebook):
self.data.playingQ = True
self.setTabText("queue")
elif self.data.random == True:
self.data.curSong = random.randint(0,len(self.data.curList))
self.data.curSong = self.data.curList[random.randint(0,len(self.data.curList))]
else:
next = self.plist[0][0]
for i in range(len(self.plist)-1):
@ -282,3 +304,29 @@ class PlistView(gtk.Notebook):
self.label.set_text(self.makeTimeLabel(self.ptime))
else:
self.label.set_text(self.makeTimeLabel(self.qtime))
def makeSearch(self):
self.searchBar = gtk.Entry()
self.searchBar.connect("changed",self.textTyped)
self.searchBar.show()
def textTyped(self,entry):
self.search = entry.get_text().lower()
self.pfilter.refilter()
def hideRows(self,list,iter):
if self.search != "":
title = list[iter][1].lower()
if title.find(self.search) > -1:
return True
artist = list[iter][3].lower()
if artist.find(self.search) > -1:
return True
album = list[iter][4].lower()
if album.find(self.search) > -1:
return True
return False
return True

View File

@ -67,7 +67,8 @@ class Window(gtk.Window):
def clearPlist(self,widgit,data,other=None):
self.data.curList = []
self.data.updateList = True
#self.data.updateList = True
self.plistview.clearList(self.plistview.plist,self.plistview.ptime)
def setPlayStatus(self,widgit,status,other):
@ -113,16 +114,22 @@ class Window(gtk.Window):
leftPane.append_page(scrobbler,scrobLabel)
self.divider.add1(leftPane)
rightPane=gtk.VBox(False,0)
topRight = gtk.HBox(False,0)
topRight.show()
infoview = InfoView(self.data)
rightPane.pack_start(infoview,False,False,0)
topRight.pack_start(infoview,False,False,0)
rightPane.pack_start(topRight,False,False,0)
self.plistview = PlistView(self.data)
topRight.pack_end(self.plistview.searchBar,False,False,0)
rightPane.add(self.plistview)
self.makeBottomRow(rightPane)
rightPane.show()
self.libview.plist = self.plistview
self.divider.add2(rightPane)
self.contentPane.show()