From e90e15c4af73fa56ad94fb63caa16ad6446263a7 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Mon, 31 Dec 2007 22:22:12 +0000 Subject: [PATCH] Modifications so that GenericFilters can be applied to a PeopleModel. svn: r9665 --- ChangeLog | 6 ++++++ src/DisplayModels/_PeopleModel.py | 2 +- src/Editors/_EditFamily.py | 4 ++-- src/Filters/_GenericFilter.py | 9 +++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71db875ea..6f3fe72d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-31 Brian Matherly + * src/Editors/EditFamily.py: + * src/DisplayModels/_PeopleModel.py: + * src/Filters/_GenericFilter.py: + Modifications so that GenericFilters can be applied to a PeopleModel. + 2007-12-31 Gary Burton * src/gen/db/base.py: added missing key for reference_key in mapbase and _SIGBASE. Was preventing deleted notes being undone. Bug #1507. diff --git a/src/DisplayModels/_PeopleModel.py b/src/DisplayModels/_PeopleModel.py index 1dcdf83f4..27ba9fb4b 100644 --- a/src/DisplayModels/_PeopleModel.py +++ b/src/DisplayModels/_PeopleModel.py @@ -334,7 +334,7 @@ class PeopleModel(gtk.GenericTreeModel): while node: self.total += 1 handle, d = node - if not (handle in skip or (dfilter and not dfilter.match(handle))): + if not (handle in skip or (dfilter and not dfilter.match(handle,self.db))): name_data = d[PeopleModel._NAME_COL] group_name = ngn(self.db, name_data) diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index d9d3ff05f..f890ffd15 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -364,7 +364,7 @@ class FastMaleFilter: def __init__(self,db): self.db = db - def match(self, handle): + def match(self, handle,db): value = self.db.get_raw_person_data(handle) return value[2] == gen.lib.Person.MALE @@ -373,7 +373,7 @@ class FastFemaleFilter: def __init__(self,db): self.db = db - def match(self, handle): + def match(self, handle,db): value = self.db.get_raw_person_data(handle) return value[2] == gen.lib.Person.FEMALE diff --git a/src/Filters/_GenericFilter.py b/src/Filters/_GenericFilter.py index 59ba11884..628ec32de 100644 --- a/src/Filters/_GenericFilter.py +++ b/src/Filters/_GenericFilter.py @@ -51,8 +51,13 @@ class GenericFilter: self.logical_op = 'and' self.invert = False - def match(self,handle): - return True + def match(self,handle,db): + """Return True or False depending on whether the handle matches the + filter """ + if self.apply(db,[handle]): + return True + else: + return False def is_empty(self): return len(self.flist) == 0 or (len(self.flist) == 1 and self.flist[0].is_empty())