nickname/call name changes

svn: r6555
This commit is contained in:
Don Allingham 2006-05-05 21:16:24 +00:00
parent 508a42d6f4
commit 19236f8c67
11 changed files with 123 additions and 84 deletions

View File

@ -1,3 +1,15 @@
2006-05-05 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadGedcom.py: nickname changes
* src/GrampsDb/_ReadXML.py: nickname changes
* src/GrampsDb/_WriteGedcom.py: nickname changes
* src/GrampsDb/_WriteXML.py: nickname changes
* src/Editors/_EditPerson.py: nickname/call name changes
* src/Editors/_EditName.py: nickname/call name changes
* src/RelLib/_AttributeType.py: nickname changes
* src/RelLib/_Name.py: call name changes
* src/RelLib/_Person.py: nickname changes
* src/MergePeople.py: nickname elimination
2006-05-05 Alex Roitman <shura@gramps-project.org> 2006-05-05 Alex Roitman <shura@gramps-project.org>
* src/DisplayTabs/_MediaBackRefList.py: Import model. * src/DisplayTabs/_MediaBackRefList.py: Import model.

View File

@ -114,20 +114,34 @@ class EditName(EditSecondary):
self.db.readonly) self.db.readonly)
self.given_field = MonitoredEntry( self.given_field = MonitoredEntry(
self.top.get_widget("alt_given"), self.obj.set_first_name, self.top.get_widget("alt_given"),
self.obj.get_first_name, self.db.readonly) self.obj.set_first_name,
self.obj.get_first_name,
self.db.readonly)
self.call_field = MonitoredEntry(
self.top.get_widget("call"),
self.obj.set_call_name,
self.obj.get_call_name,
self.db.readonly)
self.title_field = MonitoredEntry( self.title_field = MonitoredEntry(
self.top.get_widget("alt_title"), self.obj.set_title, self.top.get_widget("alt_title"),
self.obj.get_title, self.db.readonly) self.obj.set_title,
self.obj.get_title,
self.db.readonly)
self.suffix_field = MonitoredEntry( self.suffix_field = MonitoredEntry(
self.top.get_widget("alt_suffix"), self.obj.set_suffix, self.top.get_widget("alt_suffix"),
self.obj.get_suffix, self.db.readonly) self.obj.set_suffix,
self.obj.get_suffix,
self.db.readonly)
self.patronymic_field = MonitoredEntry( self.patronymic_field = MonitoredEntry(
self.top.get_widget("patronymic"), self.obj.set_patronymic, self.top.get_widget("patronymic"),
self.obj.get_patronymic, self.db.readonly) self.obj.set_patronymic,
self.obj.get_patronymic,
self.db.readonly)
self.surname_field = MonitoredEntry( self.surname_field = MonitoredEntry(
self.top.get_widget("alt_surname"), self.top.get_widget("alt_surname"),
@ -137,8 +151,10 @@ class EditName(EditSecondary):
changed=self.update_group_as) changed=self.update_group_as)
self.prefix_field = MonitoredEntry( self.prefix_field = MonitoredEntry(
self.top.get_widget("alt_prefix"), self.obj.set_surname_prefix, self.top.get_widget("alt_prefix"),
self.obj.get_surname_prefix, self.db.readonly) self.obj.set_surname_prefix,
self.obj.get_surname_prefix,
self.db.readonly)
self.date = MonitoredDate( self.date = MonitoredDate(
self.top.get_widget("date"), self.top.get_widget("date"),

View File

@ -207,6 +207,12 @@ class EditPerson(EditPrimary):
self.pname.get_suffix, self.pname.get_suffix,
self.db.readonly) self.db.readonly)
self.call = GrampsWidgets.MonitoredEntry(
self.top.get_widget("call"),
self.pname.set_call_name,
self.pname.get_call_name,
self.db.readonly)
self.given = GrampsWidgets.MonitoredEntry( self.given = GrampsWidgets.MonitoredEntry(
self.top.get_widget("given_name"), self.top.get_widget("given_name"),
self.pname.set_first_name, self.pname.set_first_name,
@ -559,7 +565,7 @@ class EditPerson(EditPrimary):
any changes. any changes.
""" """
for obj in (self.suffix, self.prefix, self.given, self.title, for obj in (self.suffix, self.prefix, self.given, self.title,
self.ntype_field, self.surname_field): self.ntype_field, self.surname_field, self.call):
obj.update() obj.update()
def load_person_image(self): def load_person_image(self):

View File

@ -2379,13 +2379,19 @@ class GedcomParser:
state.name.set_suffix(matches[2]) state.name.set_suffix(matches[2])
def func_name_nick(self,matches,state): def func_name_nick(self,matches,state):
state.person.set_nick_name(matches[2]) attr = RelLib.Attribute()
attr.set_type(RelLib.AttributeType.NICKNAME)
attr.set_value(matches[2])
state.person.add_attribute(attr)
def func_name_aka(self,matches,state): def func_name_aka(self,matches,state):
lname = matches[2].split() lname = matches[2].split()
l = len(lname) l = len(lname)
if l == 1: if l == 1:
state.person.set_nick_name(matches[2]) attr = RelLib.Attribute()
attr.set_type(RelLib.AttributeType.NICKNAME)
attr.set_value(matches[2])
state.person.add_attribute(attr)
else: else:
name = RelLib.Name() name = RelLib.Name()
name.set_surname(lname[-1]) name.set_surname(lname[-1])

View File

@ -1601,7 +1601,10 @@ class GrampsParser:
def stop_nick(self,tag): def stop_nick(self,tag):
if self.person: if self.person:
self.person.set_nick_name(tag) attr = RelLib.Attribute()
attr.set_type(RelLib.AttributeType.NICKNAME)
attr.set_value(tag)
self.person.add_attribute(attr)
def stop_note(self,tag): def stop_note(self,tag):
self.in_note = 0 self.in_note = 0

View File

@ -885,13 +885,14 @@ class GedcomWriter:
restricted = self.restrict and Utils.probably_alive (person,self.db) restricted = self.restrict and Utils.probably_alive (person,self.db)
self.prefn(person) self.prefn(person)
primaryname = person.get_primary_name () primaryname = person.get_primary_name ()
nickname = ""
if restricted and self.living: if restricted and self.living:
primaryname = RelLib.Name (primaryname) primaryname = RelLib.Name (primaryname)
primaryname.set_first_name ("Living") primaryname.set_first_name ("Living")
nickname = "" #nickname = ""
else: else:
primaryname = person.get_primary_name () primaryname = person.get_primary_name ()
nickname = person.get_nick_name () #nickname = person.get_nick_name ()
if restricted and self.exclnotes: if restricted and self.exclnotes:
primaryname = RelLib.Name (primaryname) primaryname = RelLib.Name (primaryname)

View File

@ -397,7 +397,6 @@ class XmlWriter:
for name in person.get_alternate_names(): for name in person.get_alternate_names():
self.dump_name(name,True,index+1) self.dump_name(name,True,index+1)
self.write_line("nick",person.get_nick_name(),index+1)
self.dump_event_ref(person.birth_ref,index+1) self.dump_event_ref(person.birth_ref,index+1)
self.dump_event_ref(person.death_ref,index+1) self.dump_event_ref(person.death_ref,index+1)
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():

View File

@ -456,11 +456,6 @@ class MergePeople:
The other person's name is stored as an alternate name if it is The other person's name is stored as an alternate name if it is
not entirely identical to the destination person's primary name. not entirely identical to the destination person's primary name.
In the current implementation, If only one person has a
nickname, it is assigned as the merged person's nickname. If
both people have nicknames, then the nickname of the second
person is lost.
Remaining alternate names are then added to the merged Remaining alternate names are then added to the merged
person's alternate names. person's alternate names.
""" """
@ -471,11 +466,6 @@ class MergePeople:
if not p2_name.is_equal(p1_name): if not p2_name.is_equal(p1_name):
new.add_alternate_name(p2_name) new.add_alternate_name(p2_name)
if self.p1.get_nick_name() == "":
new.set_nick_name(self.p2.get_nick_name())
else:
new.set_nick_name(self.p1.get_nick_name())
for name in self.p1.get_alternate_names(): for name in self.p1.get_alternate_names():
new.add_alternate_name(name) new.add_alternate_name(name)
for name in self.p2.get_alternate_names(): for name in self.p2.get_alternate_names():

View File

@ -33,6 +33,7 @@ class AttributeType(GrampsType):
NATIONAL = 4 NATIONAL = 4
NUM_CHILD = 5 NUM_CHILD = 5
SSN = 6 SSN = 6
NICKNAME = 7
_CUSTOM = CUSTOM _CUSTOM = CUSTOM
_DEFAULT = ID _DEFAULT = ID
@ -47,6 +48,7 @@ class AttributeType(GrampsType):
(NUM_CHILD , _("Number of Children"), "Number of Children"), (NUM_CHILD , _("Number of Children"), "Number of Children"),
(SSN , _("Social Security Number"), "Social Security Number"), (SSN , _("Social Security Number"), "Social Security Number"),
(NUM_CHILD , _("Number of Children"), "Number of Children"), (NUM_CHILD , _("Number of Children"), "Number of Children"),
(NICKNAME , _("Nickname"), "Nickname"),
] ]
_I2SMAP = init_map(_DATAMAP, 0, 1) _I2SMAP = init_map(_DATAMAP, 0, 1)

View File

@ -68,7 +68,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
(privacy,source_list,note,date, (privacy,source_list,note,date,
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
name_type,self.prefix,self.patronymic,self.sname, name_type,self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) = data self.group_as,self.sort_as,self.display_as,self.call) = data
self.type = NameType(name_type) self.type = NameType(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self,source_list)
@ -90,6 +90,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.group_as = source.group_as self.group_as = source.group_as
self.sort_as = source.sort_as self.sort_as = source.sort_as
self.display_as = source.display_as self.display_as = source.display_as
self.call = source.call
else: else:
PrivacyBase.__init__(self,source) PrivacyBase.__init__(self,source)
SourceBase.__init__(self,source) SourceBase.__init__(self,source)
@ -106,6 +107,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.group_as = "" self.group_as = ""
self.sort_as = self.DEF self.sort_as = self.DEF
self.display_as = self.DEF self.display_as = self.DEF
self.call = ''
def serialize(self): def serialize(self):
return (PrivacyBase.serialize(self), return (PrivacyBase.serialize(self),
@ -114,13 +116,13 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
DateBase.serialize(self), DateBase.serialize(self),
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
self.type.serialize(),self.prefix,self.patronymic,self.sname, self.type.serialize(),self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) self.group_as,self.sort_as,self.display_as,self.call)
def unserialize(self,data): def unserialize(self,data):
(privacy,source_list,note,date, (privacy,source_list,note,date,
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
name_type,self.prefix,self.patronymic,self.sname, name_type,self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) = data self.group_as,self.sort_as,self.display_as,self.call) = data
self.type.unserialize(name_type) self.type.unserialize(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self,source_list)
@ -136,7 +138,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
@rtype: list @rtype: list
""" """
return [self.first_name,self.surname,self.suffix,self.title, return [self.first_name,self.surname,self.suffix,self.title,
str(self.type),self.prefix,self.patronymic] str(self.type),self.prefix,self.patronymic, self.call]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -218,6 +220,20 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
""" """
return self.display_as return self.display_as
def get_call_name(self):
"""
Returns the call name. The call name's exact definition is not predetermined,
and may be locale specific.
"""
return self.call
def set_call_name(self,val):
"""
Returns the call name. The call name's exact definition is not predetermined,
and may be locale specific.
"""
self.call = val
def get_surname_prefix(self): def get_surname_prefix(self):
""" """
Returns the prefix (or article) of a surname. The prefix is not Returns the prefix (or article) of a surname. The prefix is not

View File

@ -49,6 +49,7 @@ from _EventRef import EventRef
from _LdsOrd import LdsOrd from _LdsOrd import LdsOrd
from _PersonRef import PersonRef from _PersonRef import PersonRef
from _MarkerType import MarkerType from _MarkerType import MarkerType
from _AttributeType import AttributeType
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -102,7 +103,6 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
self.event_ref_list = [] self.event_ref_list = []
self.family_list = [] self.family_list = []
self.parent_family_list = [] self.parent_family_list = []
self.nickname = ""
self.alternate_names = [] self.alternate_names = []
self.person_ref_list = [] self.person_ref_list = []
self.gender = Person.UNKNOWN self.gender = Person.UNKNOWN
@ -147,23 +147,22 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
self.gender, # 2 self.gender, # 2
self.primary_name.serialize(), # 3 self.primary_name.serialize(), # 3
[name.serialize() for name in self.alternate_names], # 4 [name.serialize() for name in self.alternate_names], # 4
unicode(self.nickname), # 5 death_ref, # 5
death_ref, # 6 birth_ref, # 6
birth_ref, # 7 [er.serialize() for er in self.event_ref_list], # 7
[er.serialize() for er in self.event_ref_list], # 8 self.family_list, # 8
self.family_list, # 9 self.parent_family_list, # 9
self.parent_family_list, # 10 MediaBase.serialize(self), # 10
MediaBase.serialize(self), # 11 AddressBase.serialize(self), # 11
AddressBase.serialize(self), # 12 AttributeBase.serialize(self), # 12
AttributeBase.serialize(self), # 13 UrlBase.serialize(self), # 13
UrlBase.serialize(self), # 14 LdsOrdBase.serialize(self), # 14
LdsOrdBase.serialize(self), # 15 SourceBase.serialize(self), # 15
SourceBase.serialize(self), # 16 NoteBase.serialize(self), # 16
NoteBase.serialize(self), # 17 self.change, # 17
self.change, # 18 self.marker.serialize(), # 18
self.marker.serialize(), # 19 self.private, # 19
self.private, # 20 [pr.serialize() for pr in self.person_ref_list] # 20
[pr.serialize() for pr in self.person_ref_list] # 21
) )
def unserialize(self, data): def unserialize(self, data):
@ -181,23 +180,22 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
self.gender, # 2 self.gender, # 2
primary_name, # 3 primary_name, # 3
alternate_names, # 4 alternate_names, # 4
self.nickname, # 5 death_ref, # 5
death_ref, # 6 birth_ref, # 6
birth_ref, # 7 event_ref_list, # 7
event_ref_list, # 8 self.family_list, # 8
self.family_list, # 9 self.parent_family_list, # 9
self.parent_family_list, # 10 media_list, # 10
media_list, # 11 address_list, # 11
address_list, # 12 attribute_list, # 12
attribute_list, # 13 urls, # 13
urls, # 14 lds_ord_list, # 14
lds_ord_list, # 15 source_list, # 15
source_list, # 16 note, # 16
note, # 17 self.change, # 17
self.change, # 18 marker, # 18
marker, # 19 self.private, # 19
self.private, # 20 person_ref_list, # 20
person_ref_list, # 21
) = data ) = data
self.marker.unserialize(marker) self.marker.unserialize(marker)
@ -299,7 +297,7 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
@return: Returns the list of all textual attributes of the object. @return: Returns the list of all textual attributes of the object.
@rtype: list @rtype: list
""" """
return [self.nickname, self.gramps_id] return [self.gramps_id]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -402,23 +400,13 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase,
""" """
self.alternate_names.append(name) self.alternate_names.append(name)
def set_nick_name(self, name): def get_nick_name(self):
""" nicks = [ attr for attr in self.attribute_list \
Sets the nickname field for the Person if int(attr.type) == AttributeType.NICKNAME ]
if len(nicks) == 0:
@param name: Nickname to be assigned return u''
@type name: str else:
""" return nicks[0].get_value()
self.nickname = name
def get_nick_name(self) :
"""
Returns the nickname for the Person
@returns: Returns the nickname associated with the Person
@rtype str
"""
return self.nickname
def set_gender(self, gender) : def set_gender(self, gender) :
""" """