geography : add roles to geoperson. some cleaning.

svn: r17418
This commit is contained in:
Serge Noiraud 2011-05-05 13:26:51 +00:00
parent 76887ee818
commit a2d99db5a6
3 changed files with 44 additions and 26 deletions

View File

@ -56,6 +56,7 @@ import gtk
#-------------------------------------------------------------------------
import gen.lib
import Utils
from gen.display.name import displayer as _nd
from gui.views.navigationview import NavigationView
from libformatting import FormattingHelper
import Errors
@ -562,6 +563,28 @@ class GeoGraphyView(osmGpsMap, NavigationView):
self.save_center(self.latit, self.longt)
config.set("geography.zoom",self.new_zoom)
def _get_father_and_mother_name(self, event):
"""
Return the father and mother name of a family event
"""
dbstate = self.dbstate
family_list = [
dbstate.db.get_family_from_handle(ref_handle)
for (ref_type, ref_handle) in
dbstate.db.find_backlink_handles(event.handle)
if ref_type == 'Family'
]
fnam = mnam = _("Unknown")
if family_list:
for family in family_list:
handle = family.get_father_handle()
father = dbstate.db.get_person_from_handle(handle)
handle = family.get_mother_handle()
mother = dbstate.db.get_person_from_handle(handle)
fnam = _nd.display(father) if father else _("Unknown")
mnam = _nd.display(mother) if mother else _("Unknown")
return ( fnam, mnam )
#-------------------------------------------------------------------------
#
# Specific functionalities

View File

@ -188,28 +188,6 @@ class GeoFamily(GeoGraphyView):
else:
self._createmap(self.uistate.get_active('Person'))
def _get_father_and_mother_name(self, event):
"""
Return the father and mother name of a family event
"""
dbstate = self.dbstate
family_list = [
dbstate.db.get_family_from_handle(ref_handle)
for (ref_type, ref_handle) in
dbstate.db.find_backlink_handles(event.handle)
if ref_type == 'Family'
]
fnam = mnam = _("Unknown")
if family_list:
for family in family_list:
handle = family.get_father_handle()
father = dbstate.db.get_person_from_handle(handle)
handle = family.get_mother_handle()
mother = dbstate.db.get_person_from_handle(handle)
fnam = _nd.display(father) if father else _("Unknown")
mnam = _nd.display(mother) if mother else _("Unknown")
return ( fnam, mnam )
def _createpersonmarkers(self, dbstate, person, comment, fam_id):
"""
Create all markers for the specified person.
@ -424,7 +402,10 @@ class GeoFamily(GeoGraphyView):
message = "%s : %s - %s" % ( mark[7], father_name, mother_name )
else:
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
message = "%s => %s" % ( mark[5], evt.get_description())
descr = evt.get_description()
if descr == "":
descr = _('No description')
message = "%s => %s" % ( mark[5], descr)
prevmark = mark
add_item = gtk.MenuItem(message)
add_item.show()

View File

@ -303,6 +303,7 @@ class GeoPerson(GeoGraphyView):
if not event_ref:
continue
event = dbstate.db.get_event_from_handle(event_ref.ref)
role = event_ref.get_role()
eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
@ -331,7 +332,7 @@ class GeoPerson(GeoGraphyView):
person.gramps_id,
place.gramps_id,
event.gramps_id,
None
role
)
else:
self._append_to_places_without_coord(
@ -353,6 +354,7 @@ class GeoPerson(GeoGraphyView):
for event_ref in family.get_event_ref_list():
if event_ref:
event = dbstate.db.get_event_from_handle(event_ref.ref)
role = event_ref.get_role()
if event.get_place_handle():
place_handle = event.get_place_handle()
if place_handle:
@ -376,7 +378,7 @@ class GeoPerson(GeoGraphyView):
person.gramps_id,
place.gramps_id,
event.gramps_id,
None
role
)
else:
self._append_to_places_without_coord( place.gramps_id, descr)
@ -437,7 +439,19 @@ class GeoPerson(GeoGraphyView):
marks, menu, message, mark)
oldplace = mark[0]
message = ""
message = "%s : %s" % ( mark[2], mark[1] )
print "role : ", mark[11]
if ( mark[11] == gen.lib.EventRoleType.PRIMARY ):
message = "%s : %s" % ( mark[2], mark[1] )
elif ( mark[11] == gen.lib.EventRoleType.FAMILY ):
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
(father_name, mother_name) = self._get_father_and_mother_name(evt)
message = "%s : %s - %s" % ( mark[7], father_name, mother_name )
else:
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
descr = evt.get_description()
if descr == "":
descr = _('No description')
message = "%s => %s" % ( mark[11], descr)
prevmark = mark
add_item = gtk.MenuItem(message)
add_item.show()