From 94b27d450c0e6221b414dd36ac66fe03f76584f3 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 2 Apr 2005 21:14:53 +0000 Subject: [PATCH] * src/ReadGedcom.py: emit proper signals to notify of a database rebuild, handle parent/child relationships better - eliminate string types * src/ReadXML.py: emit proper signals to notify of a database rebuild * src/Sources.py: select just added handle after an addition svn: r4286 --- gramps2/ChangeLog | 5 +++++ gramps2/src/ReadGedcom.py | 30 +++++++++++++++++++----------- gramps2/src/ReadXML.py | 6 ++++-- gramps2/src/Sources.py | 14 ++++++++------ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d82029726..7e3768181 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,9 @@ 2005-04-02 Don Allingham + * src/ReadGedcom.py: emit proper signals to notify of a database + rebuild, handle parent/child relationships better - eliminate + string types + * src/ReadXML.py: emit proper signals to notify of a database rebuild + * src/Sources.py: select just added handle after an addition * src/SourceView.py: fix multiple selection problem. 2005-04-02 Martin Hawlisch diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index f31fd94df..6fbbcdcb0 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -87,6 +87,12 @@ rel_types = (RelLib.Person.CHILD_REL_BIRTH, RelLib.Person.CHILD_REL_UNKWN, RelLib.Person.CHILD_REL_NONE) +pedi_type = { + 'birth' : RelLib.Person.CHILD_REL_BIRTH, + 'adopted': RelLib.Person.CHILD_REL_ADOPT, + 'foster' : RelLib.Person.CHILD_REL_FOST, + } + #------------------------------------------------------------------------- # # GEDCOM events to GRAMPS events conversion @@ -492,8 +498,10 @@ class GedcomParser: if use_trans: self.db.transaction_commit(self.trans,_("GEDCOM import")) else: - self.db.run_person_rebuild_callbacks() - self.db.run_family_rebuild_callbacks() + self.db.emit('person-rebuild') + self.db.emit('family-rebuild') + self.db.emit('place-rebuild') + self.db.emit('source-rebuild') if self.window: self.infomsg("\n%s" % msg) @@ -819,6 +827,8 @@ class GedcomParser: for f in child.get_parent_family_handle_list(): if f[0] == self.family.get_handle(): + child.change_parent_family_handle(self.family.get_handle(), + mrel, frel) break else: if mrel in rel_types and frel in reltypes: @@ -826,8 +836,7 @@ class GedcomParser: else: if child.get_main_parents_family_handle() == self.family: child.set_main_parent_family_handle(None) - child.add_parent_family_handle(self.family.get_handle(),mrel,frel) - self.db.commit_person(child, self.trans) + self.db.commit_person(child, self.trans) elif matches[1] == "NCHI": a = RelLib.Attribute() a.set_type("Number of Children") @@ -974,10 +983,9 @@ class GedcomParser: break else: if ftype in rel_types: - if self.person.get_main_parents_family_handle() == None: - self.person.set_main_parent_family_handle(handle) - else: - self.person.add_parent_family_handle(handle,RelLib.Person.CHILD_REL_UNKWN,RelLib.Person.CHILD_REL_UNKWN) + self.person.add_parent_family_handle(handle, + RelLib.Person.CHILD_REL_BIRTH, + RelLib.Person.CHILD_REL_BIRTH) else: if self.person.get_main_parents_family_handle() == handle: self.person.set_main_parent_family_handle(None) @@ -1098,16 +1106,16 @@ class GedcomParser: return None def parse_famc_type(self,level): - ftype = "" + ftype = RelLib.Person.CHILD_REL_BIRTH note = "" while 1: matches = self.get_next() if int(matches[0]) < level: self.backup() - return (ftype.capitalize(),note) + return (ftype,note) elif matches[1] == "PEDI": - ftype = matches[2] + ftype = pedi_type.get(matches[2],RelLib.Person.UNKNOWN) elif matches[1] == "SOUR": source_ref = self.handle_source(matches,level+1) self.person.get_primary_name().add_source_reference(source_ref) diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index 256eec3cd..08203d77f 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -562,8 +562,10 @@ class GrampsParser: if use_trans: self.db.transaction_commit(self.trans,_("GRAMPS XML import")) else: - self.db.run_person_rebuild_callbacks() - self.db.run_family_rebuild_callbacks() + self.db.emit('person-rebuild') + self.db.emit('family-rebuild') + self.db.emit('place-rebuild') + self.db.emit('source-rebuild') def start_lds_ord(self,attrs): atype = attrs['type'] diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py index d90623923..0c9fd068b 100644 --- a/gramps2/src/Sources.py +++ b/gramps2/src/Sources.py @@ -432,7 +432,7 @@ class SourceEditor: self.sourceDisplay.show() def rebuild_menu(self,handle_list): - self.build_source_menu() + self.build_source_menu(handle_list[0]) def on_delete_event(self,obj,b): self.close_child_windows() @@ -510,9 +510,12 @@ class SourceEditor: self.author_field.set_text("") self.pub_field.set_text("") self.active_source = sel - self.build_source_menu() + if sel: + self.build_source_menu(sel.get_handle()) + else: + self.build_source_menu(None) - def build_source_menu(self): + def build_source_menu(self,selected_handle): keys = self.db.get_source_handles() keys.sort(self.db._sortbysource) @@ -526,10 +529,9 @@ class SourceEditor: src = self.db.get_source_from_handle(src_id) title = src.get_title() gid = src.get_gramps_id() - handle = src.get_handle() store.append(row=["%s [%s]" % (title,gid)]) - self.handle_list.append(handle) - if self.active_source and self.active_source.get_handle() == src_id: + self.handle_list.append(src_id) + if selected_handle == src_id: sel_index = index index += 1 self.title_menu.set_model(store)