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 fc36af2974
commit 542927d48a
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>
* src/DataViews/_SourceView.py (edit,on_double_click): Catch exception.
* configure.in: Generate new Makefile.

View File

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

View File

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

View File

@ -69,7 +69,7 @@ class SelectPerson(ManagedWindow.ManagedWindow):
title)
self.model = PeopleModel.PeopleModel(self.db,
data_filter=filter,
(PeopleModel.FAST, filter),
skip=skip)
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.model = PeopleModel.PeopleModel(self.db,search=(0,'',False))
self.model = PeopleModel.PeopleModel(self.db,None)
self.tree.set_model(self.model)
column = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(),text=0)