From 542927d48a5d97a984802fde3e505dc1b9260606 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 15 May 2006 18:49:35 +0000 Subject: [PATCH] 2006-05-15 Don Allingham * 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 --- ChangeLog | 6 ++++++ src/DataViews/_PersonView.py | 9 ++++----- src/PeopleModel.py | 34 ++++++++++++++++++++++++---------- src/Selectors/_SelectPerson.py | 2 +- src/plugins/RelCalc.py | 2 +- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d77c66e9..c35061930 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-15 Don Allingham + * 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 * src/DataViews/_SourceView.py (edit,on_double_click): Catch exception. * configure.in: Generate new Makefile. diff --git a/src/DataViews/_PersonView.py b/src/DataViews/_PersonView.py index e5483a19b..7602adcac 100644 --- a/src/DataViews/_PersonView.py +++ b/src/DataViews/_PersonView.py @@ -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() diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 2a04fd50b..9558dc29f 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -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) diff --git a/src/Selectors/_SelectPerson.py b/src/Selectors/_SelectPerson.py index ea1a1682f..a3e24efcc 100644 --- a/src/Selectors/_SelectPerson.py +++ b/src/Selectors/_SelectPerson.py @@ -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) diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 0ae53271f..62e44e8b3 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -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)