2004-03-22 10:11:35 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2009-07-13 01:15:17 +05:30
|
|
|
# Copyright (C) 2009 Gary Burton
|
2009-11-07 18:34:45 +05:30
|
|
|
# Copyright (C) 2009 Nick Hall
|
|
|
|
# Copyright (C) 2009 Benny Malengier
|
2004-03-22 10:11:35 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2006-04-08 11:26:31 +05:30
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
2004-03-22 10:11:35 +05:30
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2006-04-08 11:26:31 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2004-03-22 10:11:35 +05:30
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2006-04-08 11:26:31 +05:30
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-03-22 10:11:35 +05:30
|
|
|
#
|
|
|
|
|
* src/RelLib.py (Transaction.__len__): Redefine length.
* src/ChooseParents.py, src/EditPerson.py, src/EditSource.py,
src/EventEdit.py, src/FamilyView.py, src/gramps_main.py,
src/ImageSelect.py, src/Marriage.py, src/MediaView.py,
src/PedView.py, src/PeopleModel.py, src/PlaceView.py,
src/SelectChild.py, src/SelectObject.py, src/Sources.py,
src/SourceView.py, src/Utils.py, src/Witness.py,
src/WriteXML.py: Switch from find_* to try_to_find_* methods.
svn: r3193
2004-05-26 08:56:18 +05:30
|
|
|
# $Id$
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
TreeModel for the GRAMPS Person tree.
|
|
|
|
"""
|
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-06-16 21:19:17 +05:30
|
|
|
from __future__ import with_statement
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2004-08-24 09:18:15 +05:30
|
|
|
import time
|
2005-04-05 20:32:59 +05:30
|
|
|
import cgi
|
2004-04-28 09:36:25 +05:30
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2009-11-07 18:34:45 +05:30
|
|
|
# GTK modules
|
2006-03-05 10:15:44 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-11-07 18:34:45 +05:30
|
|
|
import gtk
|
2006-03-05 10:15:44 +05:30
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2009-11-07 18:34:45 +05:30
|
|
|
# set up logging
|
2004-04-28 09:36:25 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-11-07 18:34:45 +05:30
|
|
|
import logging
|
|
|
|
_LOG = logging.getLogger(".")
|
2004-03-08 03:20:41 +05:30
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-10 21:38:56 +05:30
|
|
|
import const
|
2008-02-19 01:37:09 +05:30
|
|
|
from gen.lib import Name, EventRef, EventType, EventRoleType, MarkerType
|
2010-01-14 09:38:04 +05:30
|
|
|
from gen.display.name import displayer as name_displayer
|
2005-08-06 08:27:37 +05:30
|
|
|
import DateHandler
|
2005-08-19 19:56:03 +05:30
|
|
|
import ToolTips
|
2005-12-30 09:27:31 +05:30
|
|
|
import GrampsLocale
|
2006-10-30 09:39:43 +05:30
|
|
|
from Lru import LRU
|
2009-11-07 18:34:45 +05:30
|
|
|
from gui.views.treemodels.treebasemodel import TreeBaseModel
|
2009-12-08 05:54:56 +05:30
|
|
|
import config
|
2004-04-28 09:36:25 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# COLUMN constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
COLUMN_ID = 1
|
|
|
|
COLUMN_GENDER = 2
|
|
|
|
COLUMN_NAME = 3
|
|
|
|
COLUMN_DEATH = 5
|
|
|
|
COLUMN_BIRTH = 6
|
|
|
|
COLUMN_EVENT = 7
|
|
|
|
COLUMN_FAMILY = 8
|
|
|
|
COLUMN_CHANGE = 17
|
|
|
|
COLUMN_MARKER = 18
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2009-12-08 05:54:56 +05:30
|
|
|
invalid_date_format = config.get('preferences.invalid-date-format')
|
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PeopleModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-11-07 18:34:45 +05:30
|
|
|
class PeopleModel(TreeBaseModel):
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
Basic GenericTreeModel interface to handle the Tree interface for
|
|
|
|
the PersonView
|
|
|
|
"""
|
2006-05-17 06:18:46 +05:30
|
|
|
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
# The following is accessed from PersonView - CHECK
|
|
|
|
COLUMN_INT_ID = 12 # dynamic calculation of column indices
|
2006-05-17 06:18:46 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None,
|
|
|
|
skip=set(), sort_map=None):
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
Initialize the model building the initial data
|
|
|
|
"""
|
2010-01-09 16:40:32 +05:30
|
|
|
TreeBaseModel.__init__(self, db, search=search, skip=skip,
|
|
|
|
tooltip_column=11, marker_column=10,
|
|
|
|
scol=scol, order=order, sort_map=sort_map)
|
2009-11-07 18:34:45 +05:30
|
|
|
|
2010-01-09 16:40:32 +05:30
|
|
|
def _set_base_data(self):
|
|
|
|
"""See TreeBaseModel, we also set some extra lru caches
|
|
|
|
"""
|
|
|
|
self.gen_cursor = self.db.get_person_cursor
|
|
|
|
self.number_items = self.db.get_number_of_people
|
|
|
|
self.map = self.db.get_raw_person_data
|
2009-11-07 18:34:45 +05:30
|
|
|
|
|
|
|
self.fmap = [
|
|
|
|
self.column_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_gender,
|
|
|
|
self.column_birth_day,
|
|
|
|
self.column_birth_place,
|
|
|
|
self.column_death_day,
|
|
|
|
self.column_death_place,
|
|
|
|
self.column_spouse,
|
|
|
|
self.column_change,
|
|
|
|
self.column_marker_text,
|
|
|
|
self.column_marker_color,
|
|
|
|
self.column_tooltip,
|
|
|
|
self.column_int_id,
|
|
|
|
]
|
|
|
|
self.smap = [
|
|
|
|
self.sort_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_gender,
|
|
|
|
self.sort_birth_day,
|
|
|
|
self.column_birth_place,
|
|
|
|
self.sort_death_day,
|
|
|
|
self.column_death_place,
|
|
|
|
self.column_spouse,
|
|
|
|
self.column_change,
|
|
|
|
self.column_marker_text,
|
|
|
|
self.column_marker_color,
|
|
|
|
self.column_tooltip,
|
|
|
|
self.column_int_id,
|
|
|
|
]
|
2009-12-11 23:00:54 +05:30
|
|
|
self.hmap = [self.column_header] + [None]*len(self.smap)
|
2010-01-09 16:40:32 +05:30
|
|
|
|
|
|
|
self.lru_name = LRU(TreeBaseModel._CACHE_SIZE)
|
|
|
|
self.lru_bdate = LRU(TreeBaseModel._CACHE_SIZE)
|
|
|
|
self.lru_ddate = LRU(TreeBaseModel._CACHE_SIZE)
|
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
def clear_cache(self):
|
|
|
|
""" Clear the LRU cache """
|
|
|
|
TreeBaseModel.clear_cache(self)
|
|
|
|
self.lru_name.clear()
|
|
|
|
self.lru_bdate.clear()
|
|
|
|
self.lru_ddate.clear()
|
2006-05-12 23:50:18 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
def on_get_n_columns(self):
|
|
|
|
""" Return the number of columns in the model """
|
|
|
|
return len(self.fmap)+1
|
2006-05-12 23:50:18 +05:30
|
|
|
|
2009-12-17 04:26:55 +05:30
|
|
|
def get_tree_levels(self):
|
|
|
|
"""
|
|
|
|
Return the headings of the levels in the hierarchy.
|
|
|
|
"""
|
|
|
|
return ['Group As', 'Name']
|
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
def add_row(self, handle, data):
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
2009-11-07 18:34:45 +05:30
|
|
|
Add nodes to the node map for a single person.
|
2006-01-21 03:13:40 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
handle The handle of the gramps object.
|
|
|
|
data The object data.
|
|
|
|
"""
|
2007-06-28 11:11:40 +05:30
|
|
|
ngn = name_displayer.name_grouping_data
|
|
|
|
nsn = name_displayer.raw_sorted_name
|
2007-02-18 01:29:21 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
name_data = data[COLUMN_NAME]
|
|
|
|
group_name = ngn(self.db, name_data)
|
2009-11-17 05:43:03 +05:30
|
|
|
sort_key = self.sort_func(data)
|
2007-04-02 04:07:10 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
#if group_name not in self.group_list:
|
|
|
|
#self.group_list.append(group_name)
|
|
|
|
#self.add_node(None, group_name, group_name, None)
|
2007-01-30 10:05:13 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
# add as node: parent, child, sortkey, handle; parent and child are
|
|
|
|
# nodes in the treebasemodel, and will be used as iters
|
|
|
|
self.add_node(group_name, handle, sort_key, handle)
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def sort_name(self, data):
|
2006-02-04 03:33:53 +05:30
|
|
|
n = Name()
|
2009-11-07 18:34:45 +05:30
|
|
|
n.unserialize(data[COLUMN_NAME])
|
2007-06-28 11:11:40 +05:30
|
|
|
return name_displayer.sort_string(n)
|
2004-03-23 10:31:19 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_spouse(self, data):
|
2005-04-05 20:32:59 +05:30
|
|
|
spouses_names = u""
|
2004-08-24 09:44:08 +05:30
|
|
|
handle = data[0]
|
2009-11-07 18:34:45 +05:30
|
|
|
for family_handle in data[COLUMN_FAMILY]:
|
2004-08-24 09:44:08 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2006-04-08 11:26:31 +05:30
|
|
|
for spouse_id in [family.get_father_handle(),
|
2006-04-08 06:23:44 +05:30
|
|
|
family.get_mother_handle()]:
|
2004-08-24 09:44:08 +05:30
|
|
|
if not spouse_id:
|
|
|
|
continue
|
|
|
|
if spouse_id == handle:
|
|
|
|
continue
|
|
|
|
spouse = self.db.get_person_from_handle(spouse_id)
|
2009-06-26 00:31:40 +05:30
|
|
|
if spouses_names:
|
2006-04-08 11:26:31 +05:30
|
|
|
spouses_names += ", "
|
2007-06-28 11:11:40 +05:30
|
|
|
spouses_names += name_displayer.display(spouse)
|
2005-04-05 20:32:59 +05:30
|
|
|
return spouses_names
|
2004-06-03 08:58:46 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_name(self, data):
|
|
|
|
handle = data[0]
|
|
|
|
if handle in self.lru_name:
|
|
|
|
name = self.lru_name[handle]
|
2009-06-26 00:31:40 +05:30
|
|
|
else:
|
2009-11-07 18:34:45 +05:30
|
|
|
name = name_displayer.raw_sorted_name(data[COLUMN_NAME])
|
|
|
|
if not self._in_build:
|
2009-11-17 05:43:03 +05:30
|
|
|
self.lru_name[handle] = name
|
2006-10-30 07:07:43 +05:30
|
|
|
return name
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_id(self, data):
|
2009-11-07 18:34:45 +05:30
|
|
|
return data[COLUMN_ID]
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_change(self, data):
|
2006-04-08 11:26:31 +05:30
|
|
|
return unicode(
|
2006-05-17 06:18:46 +05:30
|
|
|
time.strftime('%x %X',
|
2009-11-07 18:34:45 +05:30
|
|
|
time.localtime(data[COLUMN_CHANGE])),
|
2006-05-17 06:18:46 +05:30
|
|
|
GrampsLocale.codeset)
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_gender(self, data):
|
2010-01-08 21:29:05 +05:30
|
|
|
return PeopleModel._GENDER[data[COLUMN_GENDER]]
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_birth_day(self, data):
|
|
|
|
handle = data[0]
|
|
|
|
if handle in self.lru_bdate:
|
|
|
|
value = self.lru_bdate[handle]
|
2009-06-26 00:31:40 +05:30
|
|
|
else:
|
2009-11-17 05:43:03 +05:30
|
|
|
value = self._get_birth_data(data, False)
|
2009-11-07 18:34:45 +05:30
|
|
|
if not self._in_build:
|
2009-11-17 05:43:03 +05:30
|
|
|
self.lru_bdate[handle] = value
|
2006-11-29 10:59:25 +05:30
|
|
|
return value
|
2009-11-07 18:34:45 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def sort_birth_day(self, data):
|
|
|
|
handle = data[0]
|
|
|
|
return self._get_birth_data(data, True)
|
2006-11-29 10:59:25 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def _get_birth_data(self, data, sort_mode):
|
2009-11-07 18:34:45 +05:30
|
|
|
index = data[COLUMN_BIRTH]
|
2006-05-24 02:37:26 +05:30
|
|
|
if index != -1:
|
|
|
|
try:
|
2009-11-07 18:34:45 +05:30
|
|
|
local = data[COLUMN_EVENT][index]
|
2006-05-24 02:37:26 +05:30
|
|
|
b = EventRef()
|
|
|
|
b.unserialize(local)
|
|
|
|
birth = self.db.get_event_from_handle(b.ref)
|
2009-11-07 18:34:45 +05:30
|
|
|
if sort_mode:
|
|
|
|
retval = "%09d" % birth.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
date_str = DateHandler.get_date(birth)
|
|
|
|
if date_str != "":
|
|
|
|
retval = cgi.escape(date_str)
|
2008-04-20 04:11:48 +05:30
|
|
|
if not DateHandler.get_date_valid(birth):
|
2008-04-22 07:06:03 +05:30
|
|
|
return invalid_date_format % retval
|
2008-04-20 04:11:48 +05:30
|
|
|
else:
|
|
|
|
return retval
|
2006-05-24 02:37:26 +05:30
|
|
|
except:
|
|
|
|
return u''
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
for event_ref in data[COLUMN_EVENT]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2006-12-11 00:18:29 +05:30
|
|
|
etype = event.get_type()
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(event)
|
2006-04-20 08:40:23 +05:30
|
|
|
if (etype in [EventType.BAPTISM, EventType.CHRISTEN]
|
2006-12-11 00:18:29 +05:30
|
|
|
and er.get_role() == EventRoleType.PRIMARY
|
2005-08-06 08:27:37 +05:30
|
|
|
and date_str != ""):
|
2009-11-07 18:34:45 +05:30
|
|
|
if sort_mode:
|
|
|
|
retval = "%09d" % event.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
retval = u"<i>%s</i>" % cgi.escape(date_str)
|
2008-04-20 04:11:48 +05:30
|
|
|
if not DateHandler.get_date_valid(event):
|
2008-04-22 07:06:03 +05:30
|
|
|
return invalid_date_format % retval
|
2008-04-20 04:11:48 +05:30
|
|
|
else:
|
|
|
|
return retval
|
2005-04-05 20:32:59 +05:30
|
|
|
|
|
|
|
return u""
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_death_day(self, data):
|
|
|
|
handle = data[0]
|
|
|
|
if handle in self.lru_ddate:
|
|
|
|
value = self.lru_ddate[handle]
|
2009-06-26 00:31:40 +05:30
|
|
|
else:
|
2009-11-17 05:43:03 +05:30
|
|
|
value = self._get_death_data(data, False)
|
2009-11-07 18:34:45 +05:30
|
|
|
if not self._in_build:
|
2009-11-17 05:43:03 +05:30
|
|
|
self.lru_ddate[handle] = value
|
2006-11-29 10:59:25 +05:30
|
|
|
return value
|
2009-11-07 18:34:45 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def sort_death_day(self, data):
|
|
|
|
handle = data[0]
|
|
|
|
return self._get_death_data(data, True)
|
2006-11-29 10:59:25 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def _get_death_data(self, data, sort_mode):
|
2009-11-07 18:34:45 +05:30
|
|
|
index = data[COLUMN_DEATH]
|
2006-05-24 02:37:26 +05:30
|
|
|
if index != -1:
|
|
|
|
try:
|
2009-11-07 18:34:45 +05:30
|
|
|
local = data[COLUMN_EVENT][index]
|
2006-05-24 02:37:26 +05:30
|
|
|
ref = EventRef()
|
|
|
|
ref.unserialize(local)
|
|
|
|
event = self.db.get_event_from_handle(ref.ref)
|
2009-11-07 18:34:45 +05:30
|
|
|
if sort_mode:
|
|
|
|
retval = "%09d" % event.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
date_str = DateHandler.get_date(event)
|
|
|
|
if date_str != "":
|
|
|
|
retval = cgi.escape(date_str)
|
2008-04-20 04:11:48 +05:30
|
|
|
if not DateHandler.get_date_valid(event):
|
2008-04-22 07:06:03 +05:30
|
|
|
return invalid_date_format % retval
|
2008-04-20 04:11:48 +05:30
|
|
|
else:
|
|
|
|
return retval
|
2006-05-24 02:37:26 +05:30
|
|
|
except:
|
|
|
|
return u''
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
for event_ref in data[COLUMN_EVENT]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2006-11-07 17:35:40 +05:30
|
|
|
etype = event.get_type()
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(event)
|
2009-11-07 18:34:45 +05:30
|
|
|
if (etype in [EventType.BURIAL,
|
|
|
|
EventType.CREMATION,
|
|
|
|
EventType.CAUSE_DEATH]
|
2006-11-23 04:00:47 +05:30
|
|
|
and er.get_role() == EventRoleType.PRIMARY
|
2007-01-30 10:05:13 +05:30
|
|
|
and date_str):
|
2009-11-07 18:34:45 +05:30
|
|
|
if sort_mode:
|
|
|
|
retval = "%09d" % event.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
retval = "<i>%s</i>" % cgi.escape(date_str)
|
2008-04-20 04:11:48 +05:30
|
|
|
if not DateHandler.get_date_valid(event):
|
2008-04-22 07:06:03 +05:30
|
|
|
return invalid_date_format % retval
|
2008-04-20 04:11:48 +05:30
|
|
|
else:
|
|
|
|
return retval
|
2005-04-05 20:32:59 +05:30
|
|
|
return u""
|
2005-03-20 05:14:01 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_birth_place(self, data):
|
2009-11-07 18:34:45 +05:30
|
|
|
index = data[COLUMN_BIRTH]
|
2006-05-24 02:37:26 +05:30
|
|
|
if index != -1:
|
|
|
|
try:
|
2009-11-07 18:34:45 +05:30
|
|
|
local = data[COLUMN_EVENT][index]
|
2006-05-24 02:37:26 +05:30
|
|
|
br = EventRef()
|
|
|
|
br.unserialize(local)
|
|
|
|
event = self.db.get_event_from_handle(br.ref)
|
|
|
|
if event:
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
place_title = place.get_title()
|
2007-01-30 10:05:13 +05:30
|
|
|
if place_title:
|
2006-05-24 02:37:26 +05:30
|
|
|
return cgi.escape(place_title)
|
|
|
|
except:
|
|
|
|
return u''
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
for event_ref in data[COLUMN_EVENT]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2006-11-07 17:35:40 +05:30
|
|
|
etype = event.get_type()
|
2009-06-26 00:31:40 +05:30
|
|
|
if (etype in [EventType.BAPTISM, EventType.CHRISTEN] and
|
|
|
|
er.get_role() == EventRoleType.PRIMARY):
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2006-04-08 06:23:44 +05:30
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
place_title = place.get_title()
|
2007-01-30 10:05:13 +05:30
|
|
|
if place_title:
|
|
|
|
return "<i>%s</i>" % cgi.escape(place_title)
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2004-03-10 10:45:06 +05:30
|
|
|
return u""
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_death_place(self, data):
|
2009-11-07 18:34:45 +05:30
|
|
|
index = data[COLUMN_DEATH]
|
2006-05-24 02:37:26 +05:30
|
|
|
if index != -1:
|
|
|
|
try:
|
2009-11-07 18:34:45 +05:30
|
|
|
local = data[COLUMN_EVENT][index]
|
2006-05-24 02:37:26 +05:30
|
|
|
dr = EventRef()
|
|
|
|
dr.unserialize(local)
|
|
|
|
event = self.db.get_event_from_handle(dr.ref)
|
|
|
|
if event:
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
place_title = place.get_title()
|
2007-01-30 10:05:13 +05:30
|
|
|
if place_title:
|
2006-05-24 02:37:26 +05:30
|
|
|
return cgi.escape(place_title)
|
|
|
|
except:
|
|
|
|
return u''
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
for event_ref in data[COLUMN_EVENT]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2006-11-07 17:35:40 +05:30
|
|
|
etype = event.get_type()
|
2009-11-07 18:34:45 +05:30
|
|
|
if (etype in [EventType.BURIAL, EventType.CREMATION,
|
|
|
|
EventType.CAUSE_DEATH]
|
2009-01-01 06:28:18 +05:30
|
|
|
and er.get_role() == EventRoleType.PRIMARY):
|
2009-06-26 00:31:40 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2006-04-08 11:26:31 +05:30
|
|
|
place = self.db.get_place_from_handle(place_handle)
|
|
|
|
place_title = place.get_title()
|
2005-04-05 20:32:59 +05:30
|
|
|
if place_title != "":
|
|
|
|
return "<i>" + cgi.escape(place_title) + "</i>"
|
2004-03-10 10:45:06 +05:30
|
|
|
return u""
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_marker_text(self, data):
|
2009-11-07 18:34:45 +05:30
|
|
|
if COLUMN_MARKER < len(data):
|
|
|
|
return str(data[COLUMN_MARKER])
|
2005-09-16 20:55:27 +05:30
|
|
|
return ""
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_marker_color(self, data):
|
2005-09-16 20:55:27 +05:30
|
|
|
try:
|
2009-11-07 18:34:45 +05:30
|
|
|
if data[COLUMN_MARKER]:
|
|
|
|
if data[COLUMN_MARKER][0] == MarkerType.COMPLETE:
|
2006-05-12 23:50:18 +05:30
|
|
|
return self.complete_color
|
2009-11-07 18:34:45 +05:30
|
|
|
if data[COLUMN_MARKER][0] == MarkerType.TODO_TYPE:
|
2006-05-12 23:50:18 +05:30
|
|
|
return self.todo_color
|
2009-11-07 18:34:45 +05:30
|
|
|
if data[COLUMN_MARKER][0] == MarkerType.CUSTOM:
|
2006-05-12 23:50:18 +05:30
|
|
|
return self.custom_color
|
2005-09-16 20:55:27 +05:30
|
|
|
except IndexError:
|
|
|
|
pass
|
|
|
|
return None
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_tooltip(self, data):
|
2007-09-08 11:24:02 +05:30
|
|
|
if const.USE_TIPS:
|
2006-04-08 11:26:31 +05:30
|
|
|
return ToolTips.TipFromFunction(
|
|
|
|
self.db,
|
|
|
|
lambda: self.db.get_person_from_handle(data[0])
|
|
|
|
)
|
2006-03-10 00:37:13 +05:30
|
|
|
else:
|
|
|
|
return u''
|
2005-08-19 19:56:03 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def column_int_id(self, data):
|
|
|
|
return data[0]
|
2004-08-26 09:33:11 +05:30
|
|
|
|
2006-04-08 06:23:44 +05:30
|
|
|
def column_header(self, node):
|
2010-01-09 16:40:32 +05:30
|
|
|
return node.name
|
2004-08-26 09:33:11 +05:30
|
|
|
|
2006-04-08 06:23:44 +05:30
|
|
|
def column_header_view(self, node):
|
2004-12-10 05:08:43 +05:30
|
|
|
return True
|
2004-08-26 09:33:11 +05:30
|
|
|
|