diff --git a/ChangeLog b/ChangeLog index 267832309..83f0e34e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-06-02 Don Allingham + * src/DisplayModels.py: Handle EventRefs properly + * src/FamilyView.py: handle relationship types + * src/ReadXML.py: start of upgrade process + * src/RelLib.py: ROLE_PRIMARY -> PRIMARY + 2005-06-02 Alex Roitman * src/ListModel.py: Check for the list to be long enough. * src/gramps.glade: Replace ComboBox with ComboBoxEntry; remove diff --git a/src/DisplayModels.py b/src/DisplayModels.py index 9696909f8..15558cae8 100644 --- a/src/DisplayModels.py +++ b/src/DisplayModels.py @@ -216,37 +216,40 @@ class ChildModel(gtk.ListStore): index += 1 def column_birth_day(self,data): - event_handle = data.get_birth_handle() - if event_handle: - return self.db.get_event_from_handle(event_handle).get_date() + event_ref = data.get_birth_ref() + if event_ref and event_ref.ref: + print event_ref.ref + return self.db.get_event_from_handle(event_ref.ref).get_date() else: return u"" def column_birth_sort(self,data): - event_handle = data.get_birth_handle() - if event_handle: - return self.db.get_event_from_handle(event_handle).get_date_object().get_sort_value() + event_ref = data.get_birth_ref() + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) + return event.get_date_object().get_sort_value() else: return 0 def column_death_day(self,data): - event_handle = data.get_death_handle() - if event_handle: - return self.db.get_event_from_handle(event_handle).get_date() + event_ref = data.get_death_ref() + if event_ref and event_ref.ref: + return self.db.get_event_from_handle(event_ref.ref).get_date() else: return u"" def column_death_sort(self,data): - event_handle = data.get_death_handle() - if event_handle: - return self.db.get_event_from_handle(event_handle).get_date_object().get_sort_value() + event_ref = data.get_death_ref() + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) + return event.get_date_object().get_sort_value() else: return 0 def column_birth_place(self,data): - event_handle = data.get_birth_handle() - if event_handle: - event = self.db.get_event_from_handle(event_handle) + event_ref = data.get_birth_ref() + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) if event: place_handle = event.get_place_handle() if place_handle: @@ -254,9 +257,9 @@ class ChildModel(gtk.ListStore): return u"" def column_death_place(self,data): - event_handle = data.get_death_handle() - if event_handle: - event = self.db.get_event_from_handle(event_handle) + event_ref = data.get_death_ref() + if event_ref and event_ref.ref: + event = self.db.get_event_from_handle(event_ref.ref) if event: place_handle = event.get_place_handle() if place_handle: @@ -591,7 +594,7 @@ class RepositoryModel(BaseModel): def column_search_url(self,data): return unicode(data[6]) - + def column_home_url(self,data): return unicode(data[7]) diff --git a/src/FamilyView.py b/src/FamilyView.py index 1eb2827bd..ce62145e6 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -1044,12 +1044,12 @@ class FamilyView: mdate = " - %s" % DateHandler.displayer.display(dobj) else: mdate = "" + i,s = fm.get_relationship() - if Utils.family_relations.has_key(i) \ - and i != RelLib.Family.CUSTOM: - disp_rel = Utils.family_relations[i] - else: + if i == RelLib.Family.CUSTOM: disp_rel = s + else: + disp_rel = Utils.family_relations[i] v = "%s [%s]\n\t%s%s" % ( NameDisplay.displayer.display(sp), sp.get_gramps_id(), disp_rel, mdate) @@ -1106,9 +1106,9 @@ class FamilyView: m = self.parent.db.get_person_from_handle(mother_handle) father = self.nameof(_("Father"),f, - const.child_rel_list[frel]) + Utils.child_relations[frel]) mother = self.nameof(_("Mother"),m, - const.child_rel_list[mrel]) + Utils.child_relations[mrel]) node = model.append() if not sel: diff --git a/src/ReadXML.py b/src/ReadXML.py index 5091a2ff5..44ea6645f 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -56,8 +56,12 @@ except: gzip_ok = 0 _FAMILY_TRANS = { - 'Married' : 0, 'Unmarried' : 1, 'Partners' : 1, - 'Civil Union' : 2, 'Unknown' : 3, 'Other' : 4 + 'Married' : RelLib.Family.MARRIED, + 'Unmarried' : RelLib.Family.UNMARRIED, + 'Partners' : RelLib.Family.UNMARRIED, + 'Civil Union' : RelLib.Family.CIVIL_UNION, + 'Unknown' : RelLib.Family.UNKNOWN, + 'Other' : RelLib.Family.CUSTOM, } #------------------------------------------------------------------------- @@ -352,7 +356,6 @@ class GrampsParser: "attr_type" : (None,self.stop_attr_type), "attr_value" : (None,self.stop_attr_value), "bookmark" : (self.start_bmark, None), - "witness" : (self.start_witness,self.stop_witness), "bookmarks" : (None, None), "child" : (self.start_child,None), "childof" : (self.start_childof,None), @@ -426,6 +429,56 @@ class GrampsParser: "url" : (self.start_url, None) } + self.save_event = { + "Unknown" : RelLib.Event.UNKNOWN, + "Custom" : RelLib.Event.CUSTOM, + "Marriage" : RelLib.Event.MARRIAGE, + "Marriage Settlement" : RelLib.Event.MARR_SETTL, + "Marriage License" : RelLib.Event.MARR_LIC, + "Marriage Contract" : RelLib.Event.MARR_CONTR, + "Marriage Banns" : RelLib.Event.MARR_BANNS, + "Engagement" : RelLib.Event.ENGAGEMENT, + "Divorce" : RelLib.Event.DIVORCE, + "Divorce Filing" : RelLib.Event.DIV_FILING, + "Annulment" : RelLib.Event.ANNULMENT, + "Alternate Marriage" : RelLib.Event.MARR_ALT, + "Adopted" : RelLib.Event.ADOPT, + "Birth" : RelLib.Event.BIRTH, + "Death" : RelLib.Event.DEATH, + "Adult Christening" : RelLib.Event.ADULT_CHRISTEN, + "Baptism" : RelLib.Event.BAPTISM, + "Bar Mitzvah" : RelLib.Event.BAR_MITZVAH, + "Bas Mitzvah" : RelLib.Event.BAS_MITZVAH, + "Blessing" : RelLib.Event.BLESS, + "Burial" : RelLib.Event.BURIAL, + "Cause Of Death" : RelLib.Event.CAUSE_DEATH, + "Census" : RelLib.Event.CENSUS, + "Christening" : RelLib.Event.CHRISTEN, + "Confirmation" : RelLib.Event.CONFIRMATION, + "Cremation" : RelLib.Event.CREMATION, + "Degree" : RelLib.Event.DEGREE, + "Divorce Filing" : RelLib.Event.DIV_FILING, + "Education" : RelLib.Event.EDUCATION, + "Elected" : RelLib.Event.ELECTED, + "Emigration" : RelLib.Event.EMIGRATION, + "First Communion" : RelLib.Event.FIRST_COMMUN, + "Immigration" : RelLib.Event.IMMIGRATION, + "Graduation" : RelLib.Event.GRADUATION, + "Medical Information" : RelLib.Event.MED_INFO, + "Military Service" : RelLib.Event.MILITARY_SERV, + "Naturalization" : RelLib.Event.NATURALIZATION, + "Nobility Title" : RelLib.Event.NOB_TITLE, + "Number of Marriages" : RelLib.Event.NUM_MARRIAGES, + "Occupation" : RelLib.Event.OCCUPATION, + "Ordination" : RelLib.Event.ORDINATION, + "Probate" : RelLib.Event.PROBATE, + "Property" : RelLib.Event.PROPERTY, + "Religion" : RelLib.Event.RELIGION, + "Residence" : RelLib.Event.RESIDENCE, + "Retirement" : RelLib.Event.RETIREMENT, + "Will" : RelLib.Event.WILL, + } + def find_person_by_gramps_id(self,gramps_id): intid = self.gid2id.get(gramps_id) if intid: @@ -646,6 +699,7 @@ class GrampsParser: self.locations = self.locations + 1 def start_witness(self,attrs): + return self.in_witness = 1 self.witness_comment = "" if attrs.has_key('hlink'): @@ -664,8 +718,13 @@ class GrampsParser: def start_event(self,attrs): self.event = RelLib.Event() + self.event.set_handle(Utils.create_id()) self.db.add_event(self.event,self.trans) - self.event_type = const.save_event(attrs["type"]) + etype = self.save_event.get(attrs["type"],RelLib.Event.CUSTOM) + if etype == RelLib.Event.CUSTOM: + self.event.set_type((etype,attrs["type"])) + else: + self.event.set_type((etype,u"")) if attrs.has_key("conf"): self.event.conf = int(attrs["conf"]) else: @@ -682,7 +741,7 @@ class GrampsParser: if attrs.has_key("priv"): self.attribute.private = int(attrs["priv"]) if attrs.has_key('type'): - self.attribute.set_type(const.save_attr(attrs["type"])) + self.attribute.set_type(attrs["type"]) if attrs.has_key('value'): self.attribute.set_value(attrs["value"]) if self.photo: @@ -790,9 +849,12 @@ class GrampsParser: self.family = self.find_family_by_gramps_id(handle) if attrs.has_key("type"): - self.family.set_relationship( - _FAMILY_TRANS.get(attrs["type"], - RelLib.Family.UNKNOWN)) + ftype = _FAMILY_TRANS.get(attrs["type"],RelLib.Family.UNKNOWN) + if ftype == RelLib.Family.UNKNOWN: + self.family.set_relationship((ftype,attrs['type'])) + else: + self.family.set_relationship((ftype,"")) + if attrs.has_key("complete"): self.family.set_complete_flag(int(attrs['complete'])) else: @@ -1169,31 +1231,33 @@ class GrampsParser: gtk.main_iteration() def stop_event(self,*tag): - self.event.name = self.event_type - if self.family: self.family.add_event_handle(self.event.get_handle()) else: - if self.event_type == "Birth": - self.person.set_birth_handle(self.event.get_handle()) - elif self.event_type == "Death": - self.person.set_death_handle(self.event.get_handle()) + ref = RelLib.EventRef() + ref.ref = self.event.get_handle() + if self.event.get_type()[0] == RelLib.Event.BIRTH: + self.person.set_birth_ref(ref) + elif self.event.get_type()[0] == RelLib.Event.DEATH: + self.person.set_death_ref(ref) else: - self.person.add_event_handle(self.event.get_handle()) + self.person.add_event_ref(ref) + print self.event.get_date() self.db.commit_event(self.event,self.trans,self.change) self.event = None def stop_name(self,tag): - if self.in_witness: - self.witness = RelLib.Witness(RelLib.Event.NAME,tag) - else: - if self.name.get_type() == "": - self.name.set_type("Birth Name") - self.person.set_primary_name (self.name) - self.person.get_primary_name().build_sort_name() - self.name = None + #if self.in_witness: + # self.witness = RelLib.Witness(RelLib.Event.NAME,tag) + #else: + if self.name.get_type() == "": + self.name.set_type("Birth Name") + self.person.set_primary_name (self.name) + self.person.get_primary_name().build_sort_name() + self.name = None def stop_ref(self,tag): + return self.witness = RelLib.Witness(RelLib.Event.ID,tag) def stop_place(self,tag): diff --git a/src/RelLib.py b/src/RelLib.py index 5af70f442..9b8ca2c79 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -1253,7 +1253,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( EventRef.ROLE_PRIMARY) + event_ref.set_role( EventRef.PRIMARY) self.set_birth_ref( event_ref) def set_birth_ref(self,event_ref): @@ -1276,7 +1276,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( EventRef.ROLE_PRIMARY) + event_ref.set_role( EventRef.PRIMARY) self.set_death_ref( event_ref) def set_death_ref(self,event_ref): @@ -1339,7 +1339,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( EventRef.ROLE_PRIMARY) + event_ref.set_role( EventRef.PRIMARY) self.add_event_ref( event_ref) def add_event_ref(self,event_ref): @@ -1384,7 +1384,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): for event_handle in event_list: event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role( EventRef.ROLE_PRIMARY) + event_ref.set_role( EventRef.PRIMARY) event_ref_list.append( event_ref) self.set_event_ref_list(event_ref_list) @@ -2081,7 +2081,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): # remove when transitition done. event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role(EventRef.ROLE_PRIMARY) + event_ref.set_role(EventRef.PRIMARY) self.add_event_ref(event_ref) def add_event_ref(self,event_ref): @@ -2126,7 +2126,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): for event_handle in event_list: event_ref = EventRef() event_ref.set_reference_handle(event_handle) - event_ref.set_role(EventRef.ROLE_PRIMARY) + event_ref.set_role(EventRef.PRIMARY) event_ref_list.append( event_ref) self.set_event_ref_list(event_ref_list)