2006-05-15 Don Allingham <don@gramps-project.org>

* src/DataViews/_PersonView.py: cleaner interface to filters
	* src/plugins/RelCalc.py: cleaner interface to filters
	* src/PeopleModel.py: cleaner interface to filters
	* src/Selectors/_SelectPerson.py: cleaner interface to filters



svn: r6671
This commit is contained in:
Don Allingham 2006-05-15 18:49:35 +00:00
parent ce0983129c
commit bfef16e318
5 changed files with 36 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2006-05-15 Don Allingham <don@gramps-project.org>
* src/DataViews/_PersonView.py: cleaner interface to filters
* src/plugins/RelCalc.py: cleaner interface to filters
* src/PeopleModel.py: cleaner interface to filters
* src/Selectors/_SelectPerson.py: cleaner interface to filters
2006-05-15 Alex Roitman <shura@gramps-project.org> 2006-05-15 Alex Roitman <shura@gramps-project.org>
* src/DataViews/_SourceView.py (edit,on_double_click): Catch exception. * src/DataViews/_SourceView.py (edit,on_double_click): Catch exception.
* configure.in: Generate new Makefile. * configure.in: Generate new Makefile.

View File

@ -532,13 +532,11 @@ class PersonView(PageView.PersonNavView):
if self.active: if self.active:
if Config.get(Config.FILTER): if Config.get(Config.FILTER):
search = (0, '', False) filter_info = (PeopleModel.GENERIC, self.generic_filter)
else: else:
search = self.search_bar.get_value() filter_info = (PeopleModel.SEARCH, self.search_bar.get_value())
self.generic_filter = None
self.model = PeopleModel.PeopleModel( self.model = PeopleModel.PeopleModel(self.dbstate.db, filter_info)
self.dbstate.db, self.generic_filter, search)
self.tree.set_model(self.model) self.tree.set_model(self.model)
@ -570,6 +568,7 @@ class PersonView(PageView.PersonNavView):
self.filter_pane.hide() self.filter_pane.hide()
active = False active = False
Config.set(Config.FILTER, active) Config.set(Config.FILTER, active)
self.build_tree()
def add(self,obj): def add(self,obj):
person = RelLib.Person() person = RelLib.Person()

View File

@ -120,6 +120,9 @@ else:
mylist.sort(locale.strcoll) mylist.sort(locale.strcoll)
return mylist return mylist
GENERIC = 0
SEARCH = 1
FAST = 2
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -132,7 +135,7 @@ class PeopleModel(gtk.GenericTreeModel):
the PersonView the PersonView
""" """
def __init__(self, db, data_filter=None, search=None, skip=[]): def __init__(self, db, filter_info=None, skip=[]):
""" """
Initialize the model building the initial data Initialize the model building the initial data
""" """
@ -160,15 +163,23 @@ class PeopleModel(gtk.GenericTreeModel):
self.iter2path = {} self.iter2path = {}
self.path2iter = {} self.path2iter = {}
self.sname_sub = {} self.sname_sub = {}
if not data_filter: if filter_info:
col = search[0] if filter_info[0] == GENERIC:
text = search[1] data_filter = filter_info[1]
inv = search[2] self._build_data = self._build_filter_sub
elif filter_info[0] == SEARCH:
col = filter_info[1][0]
text = filter_info[1][1]
inv = filter_info[1][2]
func = lambda x: self.on_get_value(x, col) or u"" func = lambda x: self.on_get_value(x, col) or u""
data_filter = SearchFilter(func, text, inv) data_filter = SearchFilter(func, text, inv)
self._build_data = self._build_search_sub self._build_data = self._build_search_sub
else: else:
self._build_data = self._build_filter_sub data_filter = filter_info[1]
self._build_data = self._build_search_sub
else:
self._build_data = self._build_search_sub
data_filter = None
self.rebuild_data(data_filter, skip) self.rebuild_data(data_filter, skip)
def update_todo(self,client,cnxn_id,entry,data): def update_todo(self,client,cnxn_id,entry,data):
@ -214,7 +225,10 @@ class PeopleModel(gtk.GenericTreeModel):
ngn = NameDisplay.displayer.name_grouping_name ngn = NameDisplay.displayer.name_grouping_name
nsn = NameDisplay.displayer.raw_sorted_name nsn = NameDisplay.displayer.raw_sorted_name
if dfilter:
handle_list = dfilter.apply(self.db, self.db.get_person_handles()) handle_list = dfilter.apply(self.db, self.db.get_person_handles())
else:
handle_list = self.db.get_person_handles()
for handle in handle_list: for handle in handle_list:
d = self.db.get_raw_person_data(handle) d = self.db.get_raw_person_data(handle)

View File

@ -69,7 +69,7 @@ class SelectPerson(ManagedWindow.ManagedWindow):
title) title)
self.model = PeopleModel.PeopleModel(self.db, self.model = PeopleModel.PeopleModel(self.db,
data_filter=filter, (PeopleModel.FAST, filter),
skip=skip) skip=skip)
self.add_columns(self.plist) self.add_columns(self.plist)

View File

@ -104,7 +104,7 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
self.tree = self.glade.get_widget("peopleList") self.tree = self.glade.get_widget("peopleList")
self.model = PeopleModel.PeopleModel(self.db,search=(0,'',False)) self.model = PeopleModel.PeopleModel(self.db,None)
self.tree.set_model(self.model) self.tree.set_model(self.model)
column = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(),text=0) column = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(),text=0)