diff --git a/ChangeLog b/ChangeLog index 22b890d86..4a12222f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ 2004-09-30 Don Allingham + * src/EditPerson.py: enhanced update/delete/add of person view + * src/PeopleModel.py: enhanced update/delete/add of person view + * src/PeopleView.py: enhanced update/delete/add of person view + * src/gramps_main.py: enhanced update/delete/add of person view * src/DisplayModels.py: change 0 to False * src/EditPerson.py: copy current name info to name editor when invoking * src/GrampsBSDDB.py: provide default name to group mapping diff --git a/src/EditPerson.py b/src/EditPerson.py index e212bc440..702989776 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -1620,14 +1620,16 @@ class EditPerson: if not self.person.get_handle(): self.db.add_person(self.person, trans) + call_value = 0 else: if not self.person.get_gramps_id(): self.person.set_gramps_id(self.db.find_next_person_gramps_id()) + call_value = 1 self.db.commit_person(self.person, trans) n = self.person.get_primary_name().get_regular_name() self.db.transaction_commit(trans,_("Edit Person (%s)") % n) if self.callback: - self.callback(self,1) + self.callback(self,call_value) self.close() def get_place(self,field,makenew=0): diff --git a/src/PeopleModel.py b/src/PeopleModel.py index ae5a522d1..ea1ed0c7d 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -72,16 +72,15 @@ class PeopleModel(gtk.GenericTreeModel): self.db = db self.visible = {} self.top_visible = {} - -# maps = self.db.get_people_view_maps() -# print -# 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() + + 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 = [] @@ -179,6 +178,7 @@ class PeopleModel(gtk.GenericTreeModel): try: return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.person_map[str(node)],node) except: + print "except" return u'' def reset_visible(self): diff --git a/src/PeopleView.py b/src/PeopleView.py index 0c2b3b359..687869a1b 100644 --- a/src/PeopleView.py +++ b/src/PeopleView.py @@ -121,7 +121,7 @@ class PeopleView: #self.sort_model = self.person_model.filter_new() self.sort_model = self.person_model self.person_tree.set_model(self.sort_model) - + def blist(self, store, path, iter, id_list): id_list.append(self.sort_model.get_value(iter,PeopleModel.COLUMN_INT_ID)) @@ -202,9 +202,6 @@ class PeopleView: self.parent.load_person(self.parent.active_person) def apply_filter(self,current_model=None): - self.build_tree() - return - self.person_model.rebuild_data() self.parent.status_text(_('Updating display...')) keys = self.DataFilter.apply(self.parent.db, @@ -261,5 +258,33 @@ class PeopleView: menu.popup(None,None,None,event.button,event.time) def redisplay_person_list(self,person): - self.build_tree() + self.person_model.rebuild_data() + self.add_person(person) + + def add_person(self,person): + node = person.get_handle() + top = person.get_primary_name().get_group_name() + if len(self.person_model.sname_sub[top]) == 1: + path = self.person_model.on_get_path(top) + iter = self.person_model.get_iter(path) + self.person_model.row_inserted(path,iter) + path = self.person_model.on_get_path(node) + iter = self.person_model.get_iter(path) + self.person_model.row_inserted(path,iter) + + def delete_person(self,person): + node = person.get_handle() + top = person.get_primary_name().get_group_name() + if len(self.person_model.sname_sub[top]) == 1: + path = self.person_model.on_get_path(top) + self.person_model.row_deleted(path) + path = self.person_model.on_get_path(node) + self.person_model.row_deleted(path) + + def update_person_list(self,person): + self.delete_person(person) + self.person_model.rebuild_data() + self.add_person(person) + self.parent.change_active_person(person) + self.goto_active_person() diff --git a/src/gramps_main.py b/src/gramps_main.py index 5e35c5173..688b7ed57 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -176,7 +176,6 @@ class Gramps: TipOfDay.TipOfDay() self.db.set_researcher(GrampsCfg.get_researcher()) - #self.update_display(0) def date_format_key_update(self,client,cnxn_id,entry,data): GrampsCfg.set_calendar_date_format() @@ -1212,6 +1211,9 @@ class Gramps: else: mlist = [ self.active_person.get_handle() ] + if len(mlist) == 0: + return + for sel in mlist: p = self.db.get_person_from_handle(sel) self.active_person = p @@ -1226,8 +1228,6 @@ class Gramps: _('_Delete Person'), self.delete_person_response) - self.update_display(0) - def delete_person_response(self): trans = self.db.transaction_begin() @@ -1267,9 +1267,13 @@ class Gramps: self.db.commit_family(family,trans) id = self.active_person.get_handle() - self.people_view.remove_from_person_list(self.active_person) + + person = self.active_person + self.people_view.remove_from_person_list(person) self.people_view.remove_from_history(id) self.db.remove_person(id, trans) + self.people_view.delete_person(person) + self.people_view.person_model.rebuild_data() if self.hindex >= 0: self.active_person = self.db.get_person_from_handle(self.history[self.hindex]) @@ -1457,9 +1461,11 @@ class Gramps: self.place_view.new_place_after_edit(p) def update_after_edit(self,epo,change=1): - if epo: + if change: + self.people_view.update_person_list(epo.person) + else: self.people_view.redisplay_person_list(epo.person) - self.family_view.load_family() + self.family_view.load_family() self.update_display(0) self.goto_active_person()