From 5c1f204a1c4c3ce9cf531b66d384ceb16839d0e4 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 9 Dec 2004 23:38:43 +0000 Subject: [PATCH] * src/FamilyView.py: remove debug statement * src/PeopleModel.py: abandon the attempt to use TreeFilter * src/PeopleView.py: abandon the attempt to use TreeFilter svn: r3792 --- ChangeLog | 5 +++ src/FamilyView.py | 1 - src/PeopleModel.py | 85 +++++++++++++++++++--------------------------- src/PeopleView.py | 50 ++++++++++++--------------- 4 files changed, 61 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98ea9653a..a73e1f25c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-09 Don Allingham + * src/FamilyView.py: remove debug statement + * src/PeopleModel.py: abandon the attempt to use TreeFilter + * src/PeopleView.py: abandon the attempt to use TreeFilter + 2004-12-07 Don Allingham * src/DbPrompter.py: destroy filechooser if open cancelled. * src/Report.py: Use markup in dialog diff --git a/src/FamilyView.py b/src/FamilyView.py index 34757042a..004f1d1e6 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -960,7 +960,6 @@ class FamilyView: flist = {} - print splist for f in splist: fm = self.parent.db.get_family_from_handle(f) if not fm: diff --git a/src/PeopleModel.py b/src/PeopleModel.py index b8a0550eb..fbd09e77e 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -66,40 +66,31 @@ _CHANGE_COL= 21 #------------------------------------------------------------------------- class PeopleModel(gtk.GenericTreeModel): - def __init__(self,db): + def __init__(self,db,data_filter): gtk.GenericTreeModel.__init__(self) self.db = db self.visible = {} self.top_visible = {} - - maps = self.db.get_people_view_maps() - if maps[0] != None and len(maps[0]) != 0: - self.top_path2iter = maps[0] - self.iter2path = maps[1] - self.path2iter = maps[2] - self.sname_sub = maps[3] - else: - self.rebuild_data() - - def rebuild_data(self): - self.top_path2iter = [] - self.iter2path = {} - self.path2iter = {} + self.rebuild_data(data_filter) + + def rebuild_data(self,data_filter): + self.data_filter = data_filter + temp_top_path2iter = [] + temp_iter2path = {} + temp_path2iter = {} self.sname_sub = {} - self.visible = {} - self.top_visible = {} if not self.db.is_open(): return - cursor = self.db.get_person_cursor() - - data = cursor.first() - while data: - person = Person() - person_handle = data[0] - person.unserialize(data[1]) + if data_filter: + keys = self.data_filter.apply(self.db,self.db.get_person_handles(sort_handles=False)) + else: + keys = self.db.get_person_handles(sort_handles=False) + + for person_handle in keys: + person = self.db.get_person_from_handle(person_handle) grp_as = person.get_primary_name().get_group_as() sn = person.get_primary_name().get_surname() if grp_as: @@ -111,21 +102,23 @@ class PeopleModel(gtk.GenericTreeModel): self.sname_sub[surname].append(person_handle) else: self.sname_sub[surname] = [person_handle] - - data = cursor.next() - cursor.close() - self.top_path2iter = self.sname_sub.keys() - self.top_path2iter.sort(locale.strcoll) - for name in self.top_path2iter: + temp_top_path2iter = self.sname_sub.keys() + temp_top_path2iter.sort(locale.strcoll) + for name in temp_top_path2iter: val = 0 entries = self.sname_sub[name] entries.sort(self.byname) for person_handle in entries: tpl = (name,val) - self.iter2path[person_handle] = tpl - self.path2iter[tpl] = person_handle + temp_iter2path[person_handle] = tpl + temp_path2iter[tpl] = person_handle val += 1 + + self.top_path2iter = temp_top_path2iter + self.iter2path = temp_iter2path + self.path2iter = temp_path2iter + self.db.set_people_view_maps(self.get_maps()) def get_maps(self): @@ -188,16 +181,10 @@ class PeopleModel(gtk.GenericTreeModel): return u'error' def reset_visible(self): - self.visible = {} - self.top_visible = {} + pass def set_visible(self,node,val): - try: - col = self.iter2path[node] - self.top_visible[col[0]] = val - self.visible[node] = val - except: - self.visible[node] = val + pass def on_iter_next(self, node): '''returns the next node at this level of the tree''' @@ -234,11 +221,14 @@ class PeopleModel(gtk.GenericTreeModel): return 0 def on_iter_nth_child(self,node,n): - if node == None: - return self.top_path2iter[n] try: - return self.path2iter[(node,n)] - except: + if node == None: + return self.top_path2iter[n] + try: + return self.path2iter[(node,n)] + except: + return None + except IndexError: return None def on_iter_parent(self, node): @@ -315,9 +305,6 @@ class PeopleModel(gtk.GenericTreeModel): def column_bold(self,data,node): return pango.WEIGHT_NORMAL - def column_view(self,data,node): - return self.visible.has_key(node) - def column_header(self,node): return node @@ -325,7 +312,7 @@ class PeopleModel(gtk.GenericTreeModel): return pango.WEIGHT_NORMAL #BOLD def column_header_view(self,node): - return self.top_visible.has_key(node) + return True _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] @@ -346,7 +333,6 @@ COLUMN_DEFS = [ # these columns are hidden, and must always be last in the list (PeopleModel.column_sort_name, None, gobject.TYPE_STRING), - (PeopleModel.column_view, PeopleModel.column_header_view,gobject.TYPE_BOOLEAN), (PeopleModel.column_bold, PeopleModel.column_header_bold,gobject.TYPE_INT), (PeopleModel.column_int_id, None, gobject.TYPE_STRING), ] @@ -354,7 +340,6 @@ COLUMN_DEFS = [ # dynamic calculation of column indices, for use by various Views COLUMN_INT_ID = len(COLUMN_DEFS) - 1 COLUMN_BOLD = COLUMN_INT_ID - 1 -COLUMN_VIEW = COLUMN_BOLD - 1 # indices into main column definition table COLUMN_DEF_LIST = 0 diff --git a/src/PeopleView.py b/src/PeopleView.py index 9763498dc..60a8ce2f8 100644 --- a/src/PeopleView.py +++ b/src/PeopleView.py @@ -115,10 +115,8 @@ class PeopleView: index += 1 def build_tree(self): - self.person_model = PeopleModel.PeopleModel(self.parent.db) - #self.sort_model = self.person_model - self.sort_model = self.person_model.filter_new() - self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) + self.person_model = PeopleModel.PeopleModel(self.parent.db,self.DataFilter) + self.sort_model = self.person_model self.person_tree.set_model(self.sort_model) def blist(self, store, path, node, id_list): @@ -147,10 +145,10 @@ class PeopleView: def change_db(self,db): self.build_columns() - self.person_model = PeopleModel.PeopleModel(db) - #self.sort_model = self.person_model - self.sort_model = self.person_model.filter_new() - self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) + self.person_model = PeopleModel.PeopleModel(db,self.DataFilter) + self.sort_model = self.person_model + #self.sort_model = self.person_model.filter_new() + #self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.apply_filter() self.person_tree.set_model(self.sort_model) @@ -193,32 +191,26 @@ class PeopleView: if not self.parent.active_person: return p = self.parent.active_person - path = self.person_model.on_get_path(p.get_handle()) - group_name = p.get_primary_name().get_group_name() - top_name = self.parent.db.get_name_group_mapping(group_name) - top_path = self.person_model.on_get_path(top_name) - self.person_tree.expand_row(top_path,0) - self.person_selection.select_path(path) - self.person_tree.scroll_to_cell(path,None,1,0.5,0) + try: + path = self.person_model.on_get_path(p.get_handle()) + group_name = p.get_primary_name().get_group_name() + top_name = self.parent.db.get_name_group_mapping(group_name) + top_path = self.person_model.on_get_path(top_name) + self.person_tree.expand_row(top_path,0) + self.person_selection.select_path(path) + self.person_tree.scroll_to_cell(path,None,1,0.5,0) + except KeyError: + self.person_selection.unselect_all() + print "Person not currently available due to filter" + self.parent.active_person = p def alpha_event(self,*obj): self.parent.load_person(self.parent.active_person) def apply_filter(self,current_model=None): - self.person_model.rebuild_data() self.parent.status_text(_('Updating display...')) - keys = self.DataFilter.apply( - self.parent.db, - self.parent.db.get_person_handles(sort_handles=False)) - self.person_model.reset_visible() - for person_handle in keys: - self.person_model.set_visible(person_handle,True) - - print "Applying filter" - self.sort_model.refilter() - print "Done" + self.build_tree() self.parent.modify_statusbar() - print "exit" def on_plist_button_press(self,obj,event): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: @@ -265,7 +257,7 @@ class PeopleView: menu.popup(None,None,None,event.button,event.time) def redisplay_person_list(self,person): - self.person_model.rebuild_data() + self.person_model.rebuild_data(self.DataFilter) self.add_person(person) def add_person(self,person): @@ -294,7 +286,7 @@ class PeopleView: def update_person_list(self,person): self.delete_person(person) - self.person_model.rebuild_data() + self.person_model.rebuild_data(self.DataFilter) self.add_person(person) self.parent.change_active_person(person) self.goto_active_person()