ocarina/trunk/src/queue.py

60 lines
1.6 KiB
Python

from list import List
class Queue(List):
def __init__(self,data,nextFunc,labelFunc,plause):
List.__init__(self,data,"Queue",nextFunc,labelFunc,plause)
self.data = data
self.populated = False
self.count = len(self.data.curQ)
self.makeLabel()
# Returns true if we had a song to load, false otherwise
def getNext(self):
# Populate the queue
if self.populated == False:
self.visible("show")
# No songs in queue, return false
if len(self.list) == 0:
return False
# Queue ignores random settings and filtering, just takes next song
self.data.curSong = self.list[0][0]
# Remove file from queue and tree
for i in range(len(self.data.curQ)):
if self.data.curQ[i].id == self.data.curSong:
self.data.curQ.pop(i)
break
self.remove(self.list.get_iter_root())
# Removed 7/30/2009 (Do I really need to do this?)
#self.filterRows(self.string)
self.loadSong(self.data.library.files[self.data.curSong])
return True
# Inselt a song into the queue
# Updates the visible treeview and the self.data.curQ array
def insert(self,file):
if self.populated == False:
self.visible("show")
List.insert(self,file)
self.data.curQ += [file]
# Shows and hides the treeview, populates if empty
def visible(self,func):
List.visible(self,func)
if (func == "show") and (self.populated == False):
for file in self.data.curQ:
List.insert(self,file)
self.populated = True
self.makeLabel()
self.timeText()
# Filters things quicker because it does not have to show/hide rows
# This is only called for offscreen tabs
def filterQuick(self,string):
List.filterQuick(self,self.data.curQ,string)