event/name type fixes

svn: r4780
This commit is contained in:
Don Allingham 2005-06-03 22:38:14 +00:00
parent e523edce30
commit b239854bb4
7 changed files with 42 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2005-06-03 Don Allingham <don@gramps-project.org>
* src/DisplayModels.py: remove unused print
* src/ListBox.py: get EventBox working for event types
* src/PedView.py: handle event types
* src/ReadXML.py: handle name types properly
* src/RelLib.py: add type checking for set_type
2005-06-03 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DisplayModels.py (RepositoryModel): Display repository type as text
* src/RelLib.py (Repository): Serialize type as tuple not unicode

Binary file not shown.

View File

@ -220,7 +220,6 @@ class ChildModel(gtk.ListStore):
def column_birth_day(self,data):
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""

View File

@ -270,8 +270,18 @@ class EventListBox(ReorderListBox):
ReorderListBox.__init__(self, parent, person, obj, label,
button_list, evalues, DdTargets.EVENT)
self.name_map = {}
self.val_map = Utils.personal_events
self.custom = RelLib.Event.CUSTOM
for key in self.val_map.keys():
self.name_map[self.val_map[key]] = key
def set_name(self,index,value):
self.data[index][1].set_name(value)
val = self.name_map.get(value,self.custom)
if val == self.custom:
self.data[index][1].set_type((val,value))
else:
self.data[index][1].set_type((val,self.val_map[val]))
self.change_list.add(self.data[index])
def set_description(self,index,value):

View File

@ -46,6 +46,7 @@ import GrampsCfg
import Relationship
import NameDisplay
import RelLib
import Utils
#-------------------------------------------------------------------------
#
@ -690,7 +691,9 @@ class PedigreeView:
if event:
if line_count < 3:
return event.get_date()
text += _(event.get_name())
i,s = event.get_type()
name = Utils.family_relations[i]
text += name
text += "\n"
text += event.get_date()
text += "\n"

View File

@ -64,6 +64,14 @@ _FAMILY_TRANS = {
'Other' : RelLib.Family.CUSTOM,
}
_NAME_TRANS = {
"Unknown" : RelLib.Name.UNKNOWN,
"Custom" : RelLib.Name.CUSTOM,
"Also Known As" : RelLib.Name.AKA,
"Birth Name" : RelLib.Name.BIRTH,
"Married Name" : RelLib.Name.MARRIED,
}
#-------------------------------------------------------------------------
#
# Importing data into the currently open database.
@ -893,7 +901,11 @@ class GrampsParser:
if not self.in_witness:
self.name = RelLib.Name()
if attrs.has_key("type"):
self.name.set_type(attrs["type"])
tval = _NAME_TRANS[attrs['type']]
if tval == RelLib.Name.CUSTOM:
self.name.set_type((tval,attrs["type"]))
else:
self.name.set_type((tval,Utils.name_types[tval]))
if attrs.has_key("sort"):
self.name.set_sort_as(int(attrs["sort"]))
if attrs.has_key("display"):
@ -1242,7 +1254,6 @@ class GrampsParser:
self.person.set_death_ref(ref)
else:
self.person.add_event_ref(ref)
print self.event.get_date()
self.db.commit_event(self.event,self.trans,self.change)
self.event = None
@ -1254,6 +1265,7 @@ class GrampsParser:
self.name.set_type("Birth Name")
self.person.set_primary_name (self.name)
self.person.get_primary_name().build_sort_name()
print "*",self.person.primary_name.get_name()
self.name = None
def stop_ref(self,tag):
@ -1293,6 +1305,7 @@ class GrampsParser:
def stop_person(self,*tag):
self.db.commit_person(self.person,self.trans,self.change)
print self.person.handle,self.person.primary_name.get_name()
self.person = None
while gtk.events_pending():
gtk.main_iteration()

View File

@ -2369,6 +2369,7 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
@param the_type: Type to assign to the Event
@type the_type: tuple
"""
assert type(the_type) == tuple
self.type = the_type
def get_type(self):
@ -3535,6 +3536,7 @@ class Attribute(PrivateSourceNote):
def set_type(self,val):
"""sets the type (or key) of the Attribute instance"""
assert type(the_type) == tuple
self.type = val
def get_type(self):
@ -3801,9 +3803,10 @@ class Name(PrivateSourceNote,DateBase):
"""
self.prefix = val
def set_type(self,type):
def set_type(self,the_type):
"""sets the type of the Name instance"""
self.type = type
assert type(the_type) == tuple
self.type = the_type
def get_type(self):
"""returns the type of the Name instance"""