From 064ad83c6a5347c9be3fbbc731666a6f8924cc74 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 9 Mar 2006 22:37:19 +0000 Subject: [PATCH] add/delete families better svn: r6124 --- ChangeLog | 7 +++++++ src/DataViews/_FamilyView.py | 29 ++++++++++++++++++++--------- src/DataViews/_PedigreeView.py | 2 +- src/DataViews/_PersonView.py | 31 +++++++++++++++---------------- src/Editors/_EditFamily.py | 19 ++++++++----------- src/PeopleModel.py | 8 ++++---- 6 files changed, 55 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 092d7d084..f5f473190 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-09 Don Allingham + * src/DataViews/_FamilyView.py: avoid reentry + * src/DataViews/_PedigreeView.py: handle PluginUtils + * src/DataViews/_PersonView.py: handle remove person better + * src/Editors/_EditFamily.py: connect children up properly + * src/PeopleModel.py: handle delete properly + 2006-03-09 Alex Roitman * PluginUtils: Add module with Report and Tool utils. diff --git a/src/DataViews/_FamilyView.py b/src/DataViews/_FamilyView.py index e08419319..c139d9061 100644 --- a/src/DataViews/_FamilyView.py +++ b/src/DataViews/_FamilyView.py @@ -28,10 +28,10 @@ import NameDisplay import Utils import DateHandler import ImgManip -import ReportUtils import Config import GrampsWidgets import Errors +from PluginUtils import ReportUtils _GenderCode = { RelLib.Person.MALE : u'\u2642', @@ -105,28 +105,34 @@ class FamilyView(PageView.PersonNavView): def person_update(self,handle_list): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) + while not self.change_person(self.dbstate.active.handle): + pass def person_rebuild(self): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) + while not self.change_person(self.dbstate.active.handle): + pass def family_update(self,handle_list): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) + while not self.change_person(self.dbstate.active.handle): + pass def family_add(self,handle_list): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) + while not self.change_person(self.dbstate.active.handle): + pass def family_delete(self,handle_list): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) + while not self.change_person(self.dbstate.active.handle): + pass def family_rebuild(self): if self.dbstate.active: - self.change_person(self.dbstate.active.handle) - + while not self.change_person(self.dbstate.active.handle): + pass + def get_stock(self): """ Returns the name of the stock icon to use for the display. @@ -231,7 +237,8 @@ class FamilyView(PageView.PersonNavView): def change_person(self,obj): if self.redrawing: - return + return False + print "DRAW" self.redrawing = True old_child = self.child @@ -244,6 +251,7 @@ class FamilyView(PageView.PersonNavView): self.row = 5 family_handle_list = person.get_parent_family_handle_list() + print family_handle_list if family_handle_list: for (family_handle,mrel,frel) in family_handle_list: if family_handle: @@ -301,6 +309,7 @@ class FamilyView(PageView.PersonNavView): self.vbox.pack_start(self.child,False) self.redrawing = False + return True def write_title(self,person): @@ -429,6 +438,8 @@ class FamilyView(PageView.PersonNavView): def write_parents(self,family_handle): family = self.dbstate.db.get_family_from_handle(family_handle) + if not family: + return self.write_label("%s:" % _('Parents'),family,True), self.write_person(_('Father'),family.get_father_handle()) if self.show_details: diff --git a/src/DataViews/_PedigreeView.py b/src/DataViews/_PedigreeView.py index 2ed3270ac..5c46cf8fa 100644 --- a/src/DataViews/_PedigreeView.py +++ b/src/DataViews/_PedigreeView.py @@ -54,7 +54,7 @@ import NameDisplay import Utils import DateHandler import ImgManip -import ReportUtils +from PluginUtils import ReportUtils from Editors import EditPerson #------------------------------------------------------------------------- diff --git a/src/DataViews/_PersonView.py b/src/DataViews/_PersonView.py index bd30f8037..c8649b9af 100644 --- a/src/DataViews/_PersonView.py +++ b/src/DataViews/_PersonView.py @@ -525,22 +525,21 @@ class PersonView(PageView.PersonNavView): def person_removed(self,handle_list): self.model.clear_cache() - self.build_tree() -# for node in handle_list: -# person = self.dbstate.db.get_person_from_handle(node) -# top = person.get_primary_name().get_group_name() -# mylist = self.model.sname_sub.get(top,[]) -# self.model.calculate_data() -# if mylist: -# try: -# path = self.model.on_get_path(node) -# self.model.row_deleted(path) -# if len(mylist) == 1: -# path = self.model.on_get_path(top) -# self.model.row_deleted(path) -# except KeyError: -# pass -# self.model.assign_data() + for node in handle_list: + person = self.dbstate.db.get_person_from_handle(node) + top = person.get_primary_name().get_group_name() + mylist = self.model.sname_sub.get(top,[]) + self.model.calculate_data(skip=set(handle_list)) + if mylist: + try: + path = self.model.on_get_path(node) + self.model.row_deleted(path) + if len(mylist) == 1: + path = self.model.on_get_path(top) + self.model.row_deleted(path) + except KeyError: + pass + self.model.assign_data() def person_updated(self,handle_list): self.model.clear_cache() diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index a6d50103e..9fbeda2dc 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -67,10 +67,10 @@ import NameDisplay import Spell import GrampsDisplay import RelLib -import ReportUtils import AutoComp from _EditPrimary import EditPrimary - +from PluginUtils import ReportUtils + from DdTargets import DdTargets from DisplayTabs import * from GrampsWidgets import * @@ -415,9 +415,8 @@ class EditFamily(EditPrimary): for person_handle in self.obj.get_child_handle_list(): person = self.db.get_person_from_handle(person_handle) event_ref = person.get_birth_ref() - event_handle = event_ref.ref - if event_handle: - event = self.db.get_event_from_handle(event_handle) + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) child_birth_years.append(event.get_date_object().get_year()) if len(child_birth_years) > 0: @@ -463,11 +462,9 @@ class EditFamily(EditPrimary): for person_handle in self.obj.get_child_handle_list(): person = self.db.get_person_from_handle(person_handle) event_ref = person.get_birth_ref() - if event_ref: - event_handle = event_ref.ref - if event_handle: - event = self.db.get_event_from_handle(event_handle) - child_birth_years.append(event.get_date_object().get_year()) + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) + child_birth_years.append(event.get_date_object().get_year()) if len(child_birth_years) > 0: filter_spec.set_birth_year(min(child_birth_years)) @@ -570,7 +567,7 @@ class EditFamily(EditPrimary): for handle in self.obj.get_child_handle_list(): child = self.db.get_person_from_handle(handle) # fix - relationships need to be extracted from the list - child.add_parent_family_handle(handle, + child.add_parent_family_handle(self.obj.handle, (RelLib.Person.CHILD_BIRTH,''), (RelLib.Person.CHILD_BIRTH,''), ) diff --git a/src/PeopleModel.py b/src/PeopleModel.py index b5250d19f..5d69c3435 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -127,11 +127,11 @@ class PeopleModel(gtk.GenericTreeModel): self.prev_data = None self.rebuild_data(data_filter) - def rebuild_data(self,data_filter=None,skip=None): - self.calculate_data(data_filter) + def rebuild_data(self,data_filter=None,skip=[]): + self.calculate_data(data_filter,skip) self.assign_data() - def calculate_data(self,data_filter=None): + def calculate_data(self,data_filter=None,skip=[]): if data_filter: self.data_filter = data_filter self.temp_top_path2iter = [] @@ -159,7 +159,7 @@ class PeopleModel(gtk.GenericTreeModel): ngn = NameDisplay.displayer.name_grouping_name nsn = NameDisplay.displayer.sorted_name - flist = set(keys) + flist = set([key for key in keys if key not in skip]) while node: n,d = node