Collection filtering

I moved filtering from the Library lens to the collection base class
This commit is contained in:
Bryan Schumaker 2010-10-20 20:21:11 -04:00
parent 8f370aa3bd
commit 48d0af571c
2 changed files with 15 additions and 15 deletions

View File

@ -30,6 +30,8 @@ class Collection:
def __init__(self, file):
self.file = file
self.load()
self.filtered = False
self.visible = None
def save(self):
libsaria.data.save(
@ -62,6 +64,19 @@ class Collection:
#print
#self.tag_tree.disp()
def filter(self, text):
if len(text) > 0:
self.visible = self.index.filter(text)
self.filtered = True
else:
self.visible = None
self.filtered = False
def is_visible(self, id):
if self.filtered == False:
return True
return id in self.visible
def walk_tags(self):
for tag in self.tag_tree.walk_forwards():
rec = self.records[tag[3]]

View File

@ -24,8 +24,6 @@ def set_badfiles():
class Library(collection.Collection):
def __init__(self):
collection.Collection.__init__(self, "DLTree_test")
self.filtered = False
self.visible = None
def scan(self, path):
print "Library scanning %s" % path
@ -36,19 +34,6 @@ class Library(collection.Collection):
save(badfiles, "badfiles", "")
self.disp()
def filter(self, text):
if len(text) > 0:
self.visible = self.index.filter(text)
self.filtered = True
else:
self.visible = None
self.filtered = False
def is_visible(self, id):
if self.filtered == False:
return True
return id in self.visible
def update(self, path):
global badfiles
FileRef = libsaria.collection.FileRef