* 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 svn: r4765
This commit is contained in:
parent
d1aa27e3eb
commit
aa942771ea
@ -1,3 +1,9 @@
|
|||||||
|
2005-06-02 Don Allingham <don@gramps-project.org>
|
||||||
|
* 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 <shura@gramps-project.org>
|
2005-06-02 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/ListModel.py: Check for the list to be long enough.
|
* src/ListModel.py: Check for the list to be long enough.
|
||||||
* src/gramps.glade: Replace ComboBox with ComboBoxEntry; remove
|
* src/gramps.glade: Replace ComboBox with ComboBoxEntry; remove
|
||||||
|
@ -216,37 +216,40 @@ class ChildModel(gtk.ListStore):
|
|||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
def column_birth_day(self,data):
|
def column_birth_day(self,data):
|
||||||
event_handle = data.get_birth_handle()
|
event_ref = data.get_birth_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
return self.db.get_event_from_handle(event_handle).get_date()
|
print event_ref.ref
|
||||||
|
return self.db.get_event_from_handle(event_ref.ref).get_date()
|
||||||
else:
|
else:
|
||||||
return u""
|
return u""
|
||||||
|
|
||||||
def column_birth_sort(self,data):
|
def column_birth_sort(self,data):
|
||||||
event_handle = data.get_birth_handle()
|
event_ref = data.get_birth_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
return self.db.get_event_from_handle(event_handle).get_date_object().get_sort_value()
|
event = self.db.get_event_from_handle(event_ref.ref)
|
||||||
|
return event.get_date_object().get_sort_value()
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def column_death_day(self,data):
|
def column_death_day(self,data):
|
||||||
event_handle = data.get_death_handle()
|
event_ref = data.get_death_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
return self.db.get_event_from_handle(event_handle).get_date()
|
return self.db.get_event_from_handle(event_ref.ref).get_date()
|
||||||
else:
|
else:
|
||||||
return u""
|
return u""
|
||||||
|
|
||||||
def column_death_sort(self,data):
|
def column_death_sort(self,data):
|
||||||
event_handle = data.get_death_handle()
|
event_ref = data.get_death_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
return self.db.get_event_from_handle(event_handle).get_date_object().get_sort_value()
|
event = self.db.get_event_from_handle(event_ref.ref)
|
||||||
|
return event.get_date_object().get_sort_value()
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def column_birth_place(self,data):
|
def column_birth_place(self,data):
|
||||||
event_handle = data.get_birth_handle()
|
event_ref = data.get_birth_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
event = self.db.get_event_from_handle(event_handle)
|
event = self.db.get_event_from_handle(event_ref.ref)
|
||||||
if event:
|
if event:
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
@ -254,9 +257,9 @@ class ChildModel(gtk.ListStore):
|
|||||||
return u""
|
return u""
|
||||||
|
|
||||||
def column_death_place(self,data):
|
def column_death_place(self,data):
|
||||||
event_handle = data.get_death_handle()
|
event_ref = data.get_death_ref()
|
||||||
if event_handle:
|
if event_ref and event_ref.ref:
|
||||||
event = self.db.get_event_from_handle(event_handle)
|
event = self.db.get_event_from_handle(event_ref.ref)
|
||||||
if event:
|
if event:
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
|
@ -1044,12 +1044,12 @@ class FamilyView:
|
|||||||
mdate = " - %s" % DateHandler.displayer.display(dobj)
|
mdate = " - %s" % DateHandler.displayer.display(dobj)
|
||||||
else:
|
else:
|
||||||
mdate = ""
|
mdate = ""
|
||||||
|
|
||||||
i,s = fm.get_relationship()
|
i,s = fm.get_relationship()
|
||||||
if Utils.family_relations.has_key(i) \
|
if i == RelLib.Family.CUSTOM:
|
||||||
and i != RelLib.Family.CUSTOM:
|
|
||||||
disp_rel = Utils.family_relations[i]
|
|
||||||
else:
|
|
||||||
disp_rel = s
|
disp_rel = s
|
||||||
|
else:
|
||||||
|
disp_rel = Utils.family_relations[i]
|
||||||
v = "%s [%s]\n\t%s%s" % (
|
v = "%s [%s]\n\t%s%s" % (
|
||||||
NameDisplay.displayer.display(sp),
|
NameDisplay.displayer.display(sp),
|
||||||
sp.get_gramps_id(), disp_rel, mdate)
|
sp.get_gramps_id(), disp_rel, mdate)
|
||||||
@ -1106,9 +1106,9 @@ class FamilyView:
|
|||||||
m = self.parent.db.get_person_from_handle(mother_handle)
|
m = self.parent.db.get_person_from_handle(mother_handle)
|
||||||
|
|
||||||
father = self.nameof(_("Father"),f,
|
father = self.nameof(_("Father"),f,
|
||||||
const.child_rel_list[frel])
|
Utils.child_relations[frel])
|
||||||
mother = self.nameof(_("Mother"),m,
|
mother = self.nameof(_("Mother"),m,
|
||||||
const.child_rel_list[mrel])
|
Utils.child_relations[mrel])
|
||||||
|
|
||||||
node = model.append()
|
node = model.append()
|
||||||
if not sel:
|
if not sel:
|
||||||
|
@ -56,8 +56,12 @@ except:
|
|||||||
gzip_ok = 0
|
gzip_ok = 0
|
||||||
|
|
||||||
_FAMILY_TRANS = {
|
_FAMILY_TRANS = {
|
||||||
'Married' : 0, 'Unmarried' : 1, 'Partners' : 1,
|
'Married' : RelLib.Family.MARRIED,
|
||||||
'Civil Union' : 2, 'Unknown' : 3, 'Other' : 4
|
'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_type" : (None,self.stop_attr_type),
|
||||||
"attr_value" : (None,self.stop_attr_value),
|
"attr_value" : (None,self.stop_attr_value),
|
||||||
"bookmark" : (self.start_bmark, None),
|
"bookmark" : (self.start_bmark, None),
|
||||||
"witness" : (self.start_witness,self.stop_witness),
|
|
||||||
"bookmarks" : (None, None),
|
"bookmarks" : (None, None),
|
||||||
"child" : (self.start_child,None),
|
"child" : (self.start_child,None),
|
||||||
"childof" : (self.start_childof,None),
|
"childof" : (self.start_childof,None),
|
||||||
@ -426,6 +429,56 @@ class GrampsParser:
|
|||||||
"url" : (self.start_url, None)
|
"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):
|
def find_person_by_gramps_id(self,gramps_id):
|
||||||
intid = self.gid2id.get(gramps_id)
|
intid = self.gid2id.get(gramps_id)
|
||||||
if intid:
|
if intid:
|
||||||
@ -646,6 +699,7 @@ class GrampsParser:
|
|||||||
self.locations = self.locations + 1
|
self.locations = self.locations + 1
|
||||||
|
|
||||||
def start_witness(self,attrs):
|
def start_witness(self,attrs):
|
||||||
|
return
|
||||||
self.in_witness = 1
|
self.in_witness = 1
|
||||||
self.witness_comment = ""
|
self.witness_comment = ""
|
||||||
if attrs.has_key('hlink'):
|
if attrs.has_key('hlink'):
|
||||||
@ -664,8 +718,13 @@ class GrampsParser:
|
|||||||
|
|
||||||
def start_event(self,attrs):
|
def start_event(self,attrs):
|
||||||
self.event = RelLib.Event()
|
self.event = RelLib.Event()
|
||||||
|
self.event.set_handle(Utils.create_id())
|
||||||
self.db.add_event(self.event,self.trans)
|
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"):
|
if attrs.has_key("conf"):
|
||||||
self.event.conf = int(attrs["conf"])
|
self.event.conf = int(attrs["conf"])
|
||||||
else:
|
else:
|
||||||
@ -682,7 +741,7 @@ class GrampsParser:
|
|||||||
if attrs.has_key("priv"):
|
if attrs.has_key("priv"):
|
||||||
self.attribute.private = int(attrs["priv"])
|
self.attribute.private = int(attrs["priv"])
|
||||||
if attrs.has_key('type'):
|
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'):
|
if attrs.has_key('value'):
|
||||||
self.attribute.set_value(attrs["value"])
|
self.attribute.set_value(attrs["value"])
|
||||||
if self.photo:
|
if self.photo:
|
||||||
@ -790,9 +849,12 @@ class GrampsParser:
|
|||||||
self.family = self.find_family_by_gramps_id(handle)
|
self.family = self.find_family_by_gramps_id(handle)
|
||||||
|
|
||||||
if attrs.has_key("type"):
|
if attrs.has_key("type"):
|
||||||
self.family.set_relationship(
|
ftype = _FAMILY_TRANS.get(attrs["type"],RelLib.Family.UNKNOWN)
|
||||||
_FAMILY_TRANS.get(attrs["type"],
|
if ftype == RelLib.Family.UNKNOWN:
|
||||||
RelLib.Family.UNKNOWN))
|
self.family.set_relationship((ftype,attrs['type']))
|
||||||
|
else:
|
||||||
|
self.family.set_relationship((ftype,""))
|
||||||
|
|
||||||
if attrs.has_key("complete"):
|
if attrs.has_key("complete"):
|
||||||
self.family.set_complete_flag(int(attrs['complete']))
|
self.family.set_complete_flag(int(attrs['complete']))
|
||||||
else:
|
else:
|
||||||
@ -1169,24 +1231,25 @@ class GrampsParser:
|
|||||||
gtk.main_iteration()
|
gtk.main_iteration()
|
||||||
|
|
||||||
def stop_event(self,*tag):
|
def stop_event(self,*tag):
|
||||||
self.event.name = self.event_type
|
|
||||||
|
|
||||||
if self.family:
|
if self.family:
|
||||||
self.family.add_event_handle(self.event.get_handle())
|
self.family.add_event_handle(self.event.get_handle())
|
||||||
else:
|
else:
|
||||||
if self.event_type == "Birth":
|
ref = RelLib.EventRef()
|
||||||
self.person.set_birth_handle(self.event.get_handle())
|
ref.ref = self.event.get_handle()
|
||||||
elif self.event_type == "Death":
|
if self.event.get_type()[0] == RelLib.Event.BIRTH:
|
||||||
self.person.set_death_handle(self.event.get_handle())
|
self.person.set_birth_ref(ref)
|
||||||
|
elif self.event.get_type()[0] == RelLib.Event.DEATH:
|
||||||
|
self.person.set_death_ref(ref)
|
||||||
else:
|
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.db.commit_event(self.event,self.trans,self.change)
|
||||||
self.event = None
|
self.event = None
|
||||||
|
|
||||||
def stop_name(self,tag):
|
def stop_name(self,tag):
|
||||||
if self.in_witness:
|
#if self.in_witness:
|
||||||
self.witness = RelLib.Witness(RelLib.Event.NAME,tag)
|
# self.witness = RelLib.Witness(RelLib.Event.NAME,tag)
|
||||||
else:
|
#else:
|
||||||
if self.name.get_type() == "":
|
if self.name.get_type() == "":
|
||||||
self.name.set_type("Birth Name")
|
self.name.set_type("Birth Name")
|
||||||
self.person.set_primary_name (self.name)
|
self.person.set_primary_name (self.name)
|
||||||
@ -1194,6 +1257,7 @@ class GrampsParser:
|
|||||||
self.name = None
|
self.name = None
|
||||||
|
|
||||||
def stop_ref(self,tag):
|
def stop_ref(self,tag):
|
||||||
|
return
|
||||||
self.witness = RelLib.Witness(RelLib.Event.ID,tag)
|
self.witness = RelLib.Witness(RelLib.Event.ID,tag)
|
||||||
|
|
||||||
def stop_place(self,tag):
|
def stop_place(self,tag):
|
||||||
|
@ -1253,7 +1253,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
|
|||||||
# remove when transitition done.
|
# remove when transitition done.
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
self.set_birth_ref( event_ref)
|
||||||
|
|
||||||
def set_birth_ref(self,event_ref):
|
def set_birth_ref(self,event_ref):
|
||||||
@ -1276,7 +1276,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
|
|||||||
# remove when transitition done.
|
# remove when transitition done.
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
self.set_death_ref( event_ref)
|
||||||
|
|
||||||
def set_death_ref(self,event_ref):
|
def set_death_ref(self,event_ref):
|
||||||
@ -1339,7 +1339,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
|
|||||||
# remove when transitition done.
|
# remove when transitition done.
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
self.add_event_ref( event_ref)
|
||||||
|
|
||||||
def add_event_ref(self,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:
|
for event_handle in event_list:
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
event_ref_list.append( event_ref)
|
||||||
self.set_event_ref_list(event_ref_list)
|
self.set_event_ref_list(event_ref_list)
|
||||||
|
|
||||||
@ -2081,7 +2081,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
|
|||||||
# remove when transitition done.
|
# remove when transitition done.
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
self.add_event_ref(event_ref)
|
||||||
|
|
||||||
def add_event_ref(self,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:
|
for event_handle in event_list:
|
||||||
event_ref = EventRef()
|
event_ref = EventRef()
|
||||||
event_ref.set_reference_handle(event_handle)
|
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)
|
event_ref_list.append( event_ref)
|
||||||
self.set_event_ref_list(event_ref_list)
|
self.set_event_ref_list(event_ref_list)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user