Improved Edit Person window, support for private records and confidence levels

svn: r264
This commit is contained in:
Don Allingham 2001-07-29 06:06:16 +00:00
parent 07614b9f63
commit 378f986dac
7 changed files with 3809 additions and 1091 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -150,6 +150,10 @@ class GrampsParser(handler.ContentHandler):
def start_event(self,attrs):
self.event = Event()
self.event_type = u2l(string.capwords(attrs["type"]))
if attrs.has_key("conf"):
self.event.confidence = string.atoi(attrs["conf"])
if attrs.has_key("priv"):
self.event.private = string.atoi(attrs["priv"])
#---------------------------------------------------------------------
#
@ -158,6 +162,10 @@ class GrampsParser(handler.ContentHandler):
#---------------------------------------------------------------------
def start_attribute(self,attrs):
self.attribute = Attribute()
if attrs.has_key("conf"):
self.attribute.confidence = string.atoi(attrs["conf"])
if attrs.has_key("priv"):
self.attribute.privacy = string.atoi(attrs["priv"])
if attrs.has_key('type'):
self.in_old_attr = 1
self.attribute.setType(u2l(string.capwords(attrs["type"])))
@ -176,6 +184,10 @@ class GrampsParser(handler.ContentHandler):
def start_address(self,attrs):
self.address = Address()
self.person.addAddress(self.address)
if attrs.has_key("conf"):
self.address.confidence = string.atoi(attrs["conf"])
if attrs.has_key("priv"):
self.address.private = string.atoi(attrs["priv"])
#---------------------------------------------------------------------
#
@ -245,7 +257,11 @@ class GrampsParser(handler.ContentHandler):
desc = ""
try:
url = Url(u2l(attrs["href"]),desc)
url = Url()
url.set_path(u2l(attrs["href"]))
url.set_description(desc)
if attrs.has_key("priv"):
url.setPrivacy(string.atoi(attrs['priv']))
self.person.addUrl(url)
except KeyError:
return
@ -295,6 +311,10 @@ class GrampsParser(handler.ContentHandler):
#---------------------------------------------------------------------
def start_name(self,attrs):
self.name = Name()
if attrs.has_key("conf"):
self.name.confidence = string.atoi(attrs["conf"])
if attrs.has_key("priv"):
self.name.private = string.atoi(attrs["priv"])
#---------------------------------------------------------------------
#

View File

@ -81,11 +81,39 @@ class Photo:
#
#-------------------------------------------------------------------------
class Attribute:
def __init__(self):
self.type = ""
self.value = ""
self.source_ref = SourceRef()
self.note = Note()
def __init__(self,source=None):
if source:
self.type = source.type
self.value = source.value
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note)
else:
self.note = None
self.confidence = 2
self.private = 0
else:
self.type = ""
self.value = ""
self.source_ref = None
self.note = Note()
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def setNote(self,text):
self.note.set(text)
@ -103,6 +131,8 @@ class Attribute:
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
def setType(self,val):
@ -123,27 +153,66 @@ class Attribute:
#
#-------------------------------------------------------------------------
class Address:
def __init__(self):
self.street = ""
self.city = ""
self.state = ""
self.country = ""
self.postal = ""
self.date = Date()
self.note = Note()
self.source_ref = SourceRef()
def __init__(self,source=None):
if source:
self.street = source.street
self.city = source.city
self.state = source.state
self.country = source.country
self.postal = source.postal
self.date = Date(source.date)
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note)
else:
self.note = None
self.confidence = source.confidence
self.private = source.private
else:
self.street = ""
self.city = ""
self.state = ""
self.country = ""
self.postal = ""
self.date = Date()
self.note = None
self.source_ref = None
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def setSourceRef(self,id) :
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
def setNote(self,text):
if self.note == None:
self.note = Note()
self.note.set(text)
def getNote(self):
return self.note.get()
if self.note == None:
return ""
else:
return self.note.get()
def setNoteObj(self,obj):
self.note = obj
@ -197,13 +266,43 @@ class Address:
#-------------------------------------------------------------------------
class Name:
def __init__(self):
self.FirstName = ""
self.Surname = ""
self.Suffix = ""
self.Title = ""
self.source_ref = None
self.note = None
def __init__(self,source=None):
if source:
self.FirstName = source.FirstName
self.Surname = source.Surname
self.Suffix = source.Suffix
self.Title = source.Title
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note)
else:
self.note = None
self.private = 0
self.confidence = 2
else:
self.FirstName = ""
self.Surname = ""
self.Suffix = ""
self.Title = ""
self.source_ref = None
self.note = None
self.private = 0
self.confidence = 2
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def setName(self,first,last,suffix):
self.FirstName = first
@ -280,9 +379,21 @@ class Name:
#-------------------------------------------------------------------------
class Url:
def __init__(self,path="",desc=""):
self.path = path
self.desc = desc
def __init__(self,source=None):
if source:
self.path = source.path
self.desc = source.desc
self.private = source.private
else:
self.path = ""
self.desc = ""
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def set_path(self,path):
self.path = path
@ -342,12 +453,18 @@ class Person:
def getAlternateNames(self):
return self.alternateNames
def setAlternateNames(self,list):
self.alternateNames = list
def addAlternateName(self,name):
self.alternateNames.append(name)
def getUrlList(self):
return self.urls
def setUrlList(self,list):
self.urls = list
def addUrl(self,url):
self.urls.append(url)
@ -430,6 +547,9 @@ class Person:
def getAddressList(self) :
return self.addressList
def setAddressList(self,list) :
self.addressList = list
def addAttribute(self,attribute) :
self.attributeList.append(attribute)
@ -444,6 +564,9 @@ class Person:
def getAttributeList(self) :
return self.attributeList
def setAttributeList(self,list) :
self.attributeList = list
def getAltFamilyList(self) :
return self.AltFamilyList
@ -506,7 +629,9 @@ class Event:
if source.note:
self.note = Note(source.note)
else:
self.source_ref = None
self.note = None
self.confidence = source.confidence
self.private = source.private
else:
self.place = ""
self.date = Date()
@ -514,6 +639,20 @@ class Event:
self.name = ""
self.source_ref = None
self.note = None
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def set(self,name,date,place,description):
self.name = name

View File

@ -59,9 +59,12 @@ def fix(line):
#
#
#-------------------------------------------------------------------------
def writeNote(g,val,note):
def writeNote(g,val,note,indent=0):
if not note:
return
if indent != 0:
g.write(" " * indent)
g.write("<" + val + ">")
g.write(fix(note))
g.write("</" + val + ">\n")
@ -87,18 +90,20 @@ def dump_my_event(g,name,event):
date = event.getSaveDate()
place = event.getPlace()
description = event.getDescription()
if not name and not date and not place and not description:
if (not name or name == "Birth" or name == "Death") and \
not date and not place and not description:
return
g.write("<event type=\"" + fix(name) + "\">\n")
write_line(g,"date",date)
write_line(g,"place",place)
write_line(g,"description",description)
g.write(' <event type="%s" conf="%d" priv="%d">\n' % \
(fix(name),event.getConfidence(),event.getPrivacy()))
write_line(g,"date",date,3)
write_line(g,"place",place,3)
write_line(g,"description",description,3)
if event.getNote() != "":
writeNote(g,"note",event.getNote())
writeNote(g,"note",event.getNote(),3)
dump_source_ref(g,event.getSourceRef())
g.write("</event>\n")
g.write(" </event>\n")
#-------------------------------------------------------------------------
#
@ -139,7 +144,7 @@ def write_ref(g,label,person):
#-------------------------------------------------------------------------
def write_id(g,label,person):
if person:
g.write('<%s id="%s">\n' % (label,person.getId()))
g.write(' <%s id="%s">\n' % (label,person.getId()))
#-------------------------------------------------------------------------
#
@ -159,9 +164,9 @@ def write_family_id(g,family):
#
#
#-------------------------------------------------------------------------
def write_line(g,label,value):
def write_line(g,label,value,indent=1):
if value:
g.write('<%s>%s</%s>\n' % (label,fix(value),label))
g.write('%s<%s>%s</%s>\n' % (' '*indent,label,fix(value),label))
#-------------------------------------------------------------------------
#
@ -169,16 +174,17 @@ def write_line(g,label,value):
#
#-------------------------------------------------------------------------
def dump_name(g,label,name):
g.write('<%s>\n' % label)
write_line(g,"first",name.getFirstName())
write_line(g,"last",name.getSurname())
write_line(g,"suffix",name.getSuffix())
write_line(g,"title",name.getTitle())
g.write(' <%s conf="%s" priv="%s">\n' % \
(label,name.getConfidence(),name.getPrivacy()))
write_line(g,"first",name.getFirstName(),3)
write_line(g,"last",name.getSurname(),3)
write_line(g,"suffix",name.getSuffix(),3)
write_line(g,"title",name.getTitle(),3)
if name.getNote() != "":
writeNote(g,"note",name.getNote())
dump_source_ref(g,name.getSourceRef())
g.write('</%s>\n' % label)
g.write(' </%s>\n' % label)
#-------------------------------------------------------------------------
#
@ -209,27 +215,27 @@ def exportData(database, filename, callback):
g.write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n")
g.write("<database>\n")
g.write("<header>\n")
g.write("<created date=\"%s %s %s\"" % (date[2],string.upper(date[1]),date[4]))
g.write(" <header>\n")
g.write(" <created date=\"%s %s %s\"" % (date[2],string.upper(date[1]),date[4]))
g.write(" version=\"" + const.version + "\"")
g.write(" people=\"%d\"" % (len(database.getPersonMap().values())))
g.write(" families=\"%d\"/>\n" % len(database.getFamilyMap().values()))
g.write("<researcher>\n")
write_line(g,"resname",owner.getName())
write_line(g,"resaddr",owner.getAddress())
write_line(g,"rescity",owner.getCity())
write_line(g,"resstate",owner.getState())
write_line(g,"rescountry",owner.getCountry())
write_line(g,"respostal",owner.getPostalCode())
write_line(g,"resphone",owner.getPhone())
write_line(g,"resemail",owner.getEmail())
g.write("</researcher>\n")
g.write("</header>\n")
g.write(" <researcher>\n")
write_line(g,"resname",owner.getName(),3)
write_line(g,"resaddr",owner.getAddress(),3)
write_line(g,"rescity",owner.getCity(),3)
write_line(g,"resstate",owner.getState(),3)
write_line(g,"rescountry",owner.getCountry(),3)
write_line(g,"respostal",owner.getPostalCode(),3)
write_line(g,"resphone",owner.getPhone(),3)
write_line(g,"resemail",owner.getEmail(),3)
g.write(" </researcher>\n")
g.write(" </header>\n")
g.write("<people")
g.write(" <people")
person = database.getDefaultPerson()
if person:
g.write(" default=\"" + person.getId() + "\"")
g.write(' default="%s"' % person.getId())
g.write(">\n")
total = len(personList) + len(familyList)
@ -243,9 +249,9 @@ def exportData(database, filename, callback):
write_id(g,"person",person)
if person.getGender() == Person.male:
write_line(g,"gender","M")
write_line(g,"gender","M",2)
else:
write_line(g,"gender","F")
write_line(g,"gender","F",2)
dump_name(g,"name",person.getPrimaryName())
for name in person.getAlternateNames():
dump_name(g,"aka",name)
@ -272,7 +278,8 @@ def exportData(database, filename, callback):
if len(person.getAddressList()) > 0:
g.write("<addresses>\n")
for address in person.getAddressList():
g.write('<address>\n')
g.write('<address conf="%d" priv="%d">\n' % \
(address.getConfidence(), address.getPrivacy()))
write_line(g,"date",address.getDateObj().getSaveDate())
write_line(g,"street",address.getStreet())
write_line(g,"city",address.getCity())
@ -289,7 +296,9 @@ def exportData(database, filename, callback):
g.write("<attributes>\n")
for attr in person.getAttributeList():
if attr.getSourceRef() or attr.getNote():
g.write('<attribute>\n')
g.write('<attribute conf="%d" priv="%d">\n' % \
(attr.getConfidence(),attr.getPrivacy()))
write_line(g,"attr_type",attr.getType())
write_line(g,"attr_value",attr.getValue())
dump_source_ref(g,attr.getSourceRef())
@ -304,7 +313,7 @@ def exportData(database, filename, callback):
if len(person.getUrlList()) > 0:
g.write("<urls>\n")
for url in person.getUrlList():
g.write('<url href="' + url.get_path() + '"')
g.write('<url priv="%d" href="%s"' % (url.getPrivacy(),url.get_path()))
if url.get_description() != "":
g.write(' description="' + url.get_description() + '"')
g.write('/>\n')

View File

@ -112,6 +112,18 @@ childRelations = {
_("Unknown") : "Unknown",
}
#-------------------------------------------------------------------------
#
# Confidence
#
#-------------------------------------------------------------------------
confidence = [ _("Very Low"),
_("Low"),
_("Normal"),
_("High"),
_("Very High")
]
#-------------------------------------------------------------------------
#
# Family event string mappings
@ -453,3 +465,4 @@ marriageEvents = initialize_marriage_event_list()
familyAttributes = initialize_family_attribute_list()
familyRelations = initialize_family_relation_list()
places = []
surnames = []

View File

@ -94,8 +94,6 @@ bookmarks = None
id2col = {}
surnameList = []
topWindow = None
statusbar = None
gtop = None
@ -817,8 +815,8 @@ def read_file(filename):
for person in database.getPersonMap().values():
lastname = person.getPrimaryName().getSurname()
if lastname and lastname not in surnameList:
surnameList.append(lastname)
if lastname and lastname not in const.surnames:
const.surnames.append(lastname)
full_update()
statusbar.set_progress(0.0)
@ -1736,11 +1734,9 @@ def update_after_edit(person):
#-------------------------------------------------------------------------
def load_person(person):
if person == None:
EditPerson.EditPerson(Person(),database,surnameList,\
new_after_edit)
EditPerson.EditPerson(Person(),database,new_after_edit)
else:
EditPerson.EditPerson(person,database,surnameList,\
update_after_edit)
EditPerson.EditPerson(person,database,update_after_edit)
#-------------------------------------------------------------------------
#
@ -2175,7 +2171,8 @@ def apply_filter():
name = name_tuple[0]
if datacomp(person):
id2col[person] = i
if not alt:
id2col[person] = i
if person.getGender():
gender = const.male
else: