2004-03-22 10:11:35 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# 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
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
* 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$
|
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-17 01:54:27 +05:30
|
|
|
from TransUtils import sgettext as _
|
2004-08-24 09:18:15 +05:30
|
|
|
import time
|
2005-04-05 20:32:59 +05:30
|
|
|
import cgi
|
2005-08-18 11:28:28 +05:30
|
|
|
import sys
|
2005-09-16 20:55:27 +05:30
|
|
|
import traceback
|
2005-12-30 09:27:31 +05:30
|
|
|
import locale
|
2004-04-28 09:36:25 +05:30
|
|
|
|
2006-03-19 08:55:31 +05:30
|
|
|
import cPickle as pickle
|
|
|
|
|
2006-01-21 03:13:40 +05:30
|
|
|
try:
|
|
|
|
set()
|
|
|
|
except:
|
|
|
|
from sets import Set as set
|
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-03-08 03:20:41 +05:30
|
|
|
import gobject
|
|
|
|
import gtk
|
2004-04-28 09:36:25 +05:30
|
|
|
import pango
|
2004-03-08 03:20:41 +05:30
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from RelLib import *
|
2005-01-01 09:57:15 +05:30
|
|
|
import NameDisplay
|
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
|
2004-04-28 09:36:25 +05:30
|
|
|
|
2005-05-11 19:34:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Localized constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-30 09:27:31 +05:30
|
|
|
_codeset = GrampsLocale.codeset
|
2005-05-11 19:34:47 +05:30
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-06-27 08:40:06 +05:30
|
|
|
|
|
|
|
_ID_COL = 1
|
|
|
|
_GENDER_COL= 2
|
|
|
|
_NAME_COL = 3
|
|
|
|
_DEATH_COL = 6
|
|
|
|
_BIRTH_COL = 7
|
2005-04-05 20:32:59 +05:30
|
|
|
_EVENT_COL = 8
|
2004-06-27 08:40:06 +05:30
|
|
|
_FAMILY_COL= 9
|
2006-02-04 06:26:54 +05:30
|
|
|
_CHANGE_COL= 19
|
|
|
|
_MARKER_COL= 20
|
2004-03-23 10:31:19 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python 2.3 has a bug in the unicode sorting using locale.strcoll. Seems
|
|
|
|
# to have a buffer overrun. We can convince it to do the right thing by
|
|
|
|
# forcing the string to be nul terminated, sorting, then stripping off the
|
|
|
|
# nul.
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if sys.version_info[0:2] == (2,3):
|
|
|
|
def locale_sort(mylist):
|
|
|
|
mylist = map(lambda x: x + "\x00", mylist)
|
|
|
|
mylist.sort(locale.strcoll)
|
|
|
|
return map(lambda x: x[:-1], mylist)
|
|
|
|
else:
|
|
|
|
def locale_sort(mylist):
|
|
|
|
mylist.sort(locale.strcoll)
|
|
|
|
return mylist
|
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PeopleModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-03-08 03:20:41 +05:30
|
|
|
class PeopleModel(gtk.GenericTreeModel):
|
|
|
|
|
2006-03-18 11:17:39 +05:30
|
|
|
def __init__(self,db,data_filter=None,invert_result=False,skip=[]):
|
2004-03-08 03:20:41 +05:30
|
|
|
gtk.GenericTreeModel.__init__(self)
|
2004-03-22 10:11:35 +05:30
|
|
|
|
2004-03-08 03:20:41 +05:30
|
|
|
self.db = db
|
2006-02-04 04:01:46 +05:30
|
|
|
|
2005-04-08 16:19:26 +05:30
|
|
|
self.invert_result = invert_result
|
2005-06-05 09:31:56 +05:30
|
|
|
self.sortnames = {}
|
2005-09-16 20:55:27 +05:30
|
|
|
self.marker_color_column = 11
|
|
|
|
self.tooltip_column = 12
|
2006-01-20 11:03:38 +05:30
|
|
|
self.prev_handle = None
|
|
|
|
self.prev_data = None
|
2006-03-18 11:17:39 +05:30
|
|
|
self.rebuild_data(data_filter,skip)
|
2006-01-20 11:03:38 +05:30
|
|
|
|
2006-03-10 04:07:19 +05:30
|
|
|
def rebuild_data(self,data_filter=None,skip=[]):
|
|
|
|
self.calculate_data(data_filter,skip)
|
2005-03-31 10:00:44 +05:30
|
|
|
self.assign_data()
|
|
|
|
|
2006-03-19 08:55:31 +05:30
|
|
|
def calculate_data(self,dfilter=None,skip=[]):
|
|
|
|
if dfilter:
|
|
|
|
self.dfilter = dfilter
|
2005-03-31 10:00:44 +05:30
|
|
|
self.temp_top_path2iter = []
|
|
|
|
self.temp_iter2path = {}
|
|
|
|
self.temp_path2iter = {}
|
|
|
|
self.temp_sname_sub = {}
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
if not self.db.is_open():
|
|
|
|
return
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
ngn = NameDisplay.displayer.name_grouping_name
|
|
|
|
nsn = NameDisplay.displayer.sorted_name
|
2006-01-21 03:13:40 +05:30
|
|
|
|
2006-03-19 08:55:31 +05:30
|
|
|
flist = set(skip)
|
|
|
|
self.sortnames = {}
|
|
|
|
|
|
|
|
cursor = self.db.surnames.cursor()
|
|
|
|
node = cursor.first()
|
2006-01-21 09:04:57 +05:30
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
while node:
|
2006-01-21 03:13:40 +05:30
|
|
|
n,d = node
|
2006-03-19 08:55:31 +05:30
|
|
|
d = pickle.loads(d)
|
|
|
|
handle = d[0]
|
|
|
|
primary_name = Name(data=d[_NAME_COL])
|
|
|
|
#surname = ngn(self.db,primary_name)
|
|
|
|
surname = n
|
|
|
|
|
|
|
|
if not (handle in skip or (dfilter and not dfilter.match(handle))):
|
|
|
|
self.sortnames[handle] = nsn(primary_name)
|
|
|
|
self.temp_sname_sub[surname] = [handle]
|
|
|
|
|
|
|
|
node = cursor.next_dup()
|
|
|
|
while node:
|
|
|
|
n,d = node
|
|
|
|
d = pickle.loads(d)
|
|
|
|
handle = d[0]
|
|
|
|
primary_name = Name(data=d[_NAME_COL])
|
|
|
|
if not (handle in skip or (dfilter and not dfilter.match(handle))):
|
|
|
|
self.sortnames[handle] = nsn(primary_name)
|
|
|
|
try:
|
|
|
|
self.temp_sname_sub[surname].append(handle)
|
|
|
|
except:
|
|
|
|
self.temp_sname_sub[surname] = [handle]
|
|
|
|
node = cursor.next_dup()
|
|
|
|
|
|
|
|
node = cursor.next_nodup()
|
2005-06-05 09:31:56 +05:30
|
|
|
cursor.close()
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
self.temp_top_path2iter = locale_sort(self.temp_sname_sub.keys())
|
2005-03-31 10:00:44 +05:30
|
|
|
for name in self.temp_top_path2iter:
|
2005-06-05 09:31:56 +05:30
|
|
|
self.build_sub_entry(name)
|
2006-02-09 10:40:20 +05:30
|
|
|
|
|
|
|
def clear_cache(self):
|
|
|
|
self.prev_handle = None
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
def build_sub_entry(self,name):
|
2006-02-04 04:01:46 +05:30
|
|
|
self.prev_handle = None
|
2006-03-19 08:55:31 +05:30
|
|
|
slist = [ (locale.strxfrm(self.sortnames[x]),x) \
|
|
|
|
for x in self.temp_sname_sub[name] ]
|
|
|
|
slist.sort()
|
|
|
|
entries = [ x[1] for x in slist ]
|
2006-01-22 07:36:46 +05:30
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
val = 0
|
2006-01-22 07:36:46 +05:30
|
|
|
for person_handle in entries:
|
2005-06-05 09:31:56 +05:30
|
|
|
tpl = (name,val)
|
|
|
|
self.temp_iter2path[person_handle] = tpl
|
|
|
|
self.temp_path2iter[tpl] = person_handle
|
|
|
|
val += 1
|
2004-12-10 05:08:43 +05:30
|
|
|
|
2005-03-31 10:00:44 +05:30
|
|
|
def assign_data(self):
|
|
|
|
self.top_path2iter = self.temp_top_path2iter
|
|
|
|
self.iter2path = self.temp_iter2path
|
|
|
|
self.path2iter = self.temp_path2iter
|
|
|
|
self.sname_sub = self.temp_sname_sub
|
2004-12-10 05:08:43 +05:30
|
|
|
|
2004-03-08 03:20:41 +05:30
|
|
|
def on_get_flags(self):
|
2005-04-05 20:32:59 +05:30
|
|
|
'''returns the GtkTreeModelFlags for this particular type of model'''
|
|
|
|
return gtk.TREE_MODEL_ITERS_PERSIST
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_get_n_columns(self):
|
2004-08-26 09:33:11 +05:30
|
|
|
return len(COLUMN_DEFS)
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_get_path(self, node):
|
2005-04-05 20:32:59 +05:30
|
|
|
'''returns the tree path (a tuple of indices at the various
|
|
|
|
levels) for a particular node.'''
|
2004-08-20 03:05:16 +05:30
|
|
|
try:
|
|
|
|
return (self.top_path2iter.index(node),)
|
2004-10-01 00:02:56 +05:30
|
|
|
except:
|
2004-03-08 03:20:41 +05:30
|
|
|
(surname,index) = self.iter2path[node]
|
2004-08-20 03:05:16 +05:30
|
|
|
return (self.top_path2iter.index(surname),index)
|
2004-03-08 03:20:41 +05:30
|
|
|
|
2005-03-31 10:00:44 +05:30
|
|
|
def is_visable(self,handle):
|
|
|
|
return self.iter2path.has_key(handle)
|
|
|
|
|
2004-03-08 03:20:41 +05:30
|
|
|
def on_get_column_type(self,index):
|
2004-08-26 09:33:11 +05:30
|
|
|
# return column data-type, from table
|
2004-10-01 00:02:56 +05:30
|
|
|
return COLUMN_DEFS[index][COLUMN_DEF_TYPE]
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_get_iter(self, path):
|
|
|
|
try:
|
2004-04-28 09:36:25 +05:30
|
|
|
if len(path)==1: # Top Level
|
2004-03-08 03:20:41 +05:30
|
|
|
return self.top_path2iter[path[0]]
|
2004-04-28 09:36:25 +05:30
|
|
|
else: # Sublevel
|
2004-03-08 03:20:41 +05:30
|
|
|
surname = self.top_path2iter[path[0]]
|
|
|
|
return self.path2iter[(surname,path[1])]
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def on_get_value(self,node,col):
|
|
|
|
# test for header or data row-type
|
|
|
|
if self.sname_sub.has_key(node):
|
2005-09-16 20:55:27 +05:30
|
|
|
# Header rows dont get the background color set
|
|
|
|
if col==self.marker_color_column:
|
|
|
|
return None
|
2004-08-26 09:33:11 +05:30
|
|
|
# test for 'header' column being empty (most are)
|
|
|
|
if not COLUMN_DEFS[col][COLUMN_DEF_HEADER]:
|
|
|
|
return u''
|
|
|
|
# return values for 'header' row, calling a function
|
|
|
|
# according to column_defs table
|
|
|
|
val = COLUMN_DEFS[col][COLUMN_DEF_HEADER](self,node)
|
|
|
|
return val
|
2004-03-08 03:20:41 +05:30
|
|
|
else:
|
2004-08-26 09:33:11 +05:30
|
|
|
# return values for 'data' row, calling a function
|
|
|
|
# according to column_defs table
|
2004-08-25 09:07:48 +05:30
|
|
|
try:
|
2006-01-20 11:03:38 +05:30
|
|
|
if node != self.prev_handle:
|
|
|
|
self.prev_data = self.db.get_raw_person_data(str(node))
|
|
|
|
self.prev_handle = node
|
|
|
|
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.prev_data,node)
|
2004-08-25 09:07:48 +05:30
|
|
|
except:
|
2006-03-06 05:09:20 +05:30
|
|
|
if col == _MARKER_COL:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return u'error'
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_iter_next(self, node):
|
2005-04-05 20:32:59 +05:30
|
|
|
'''returns the next node at this level of the tree'''
|
2004-08-20 03:05:16 +05:30
|
|
|
try:
|
|
|
|
path = self.top_path2iter.index(node)
|
|
|
|
if path+1 == len(self.top_path2iter):
|
|
|
|
return None
|
|
|
|
return self.top_path2iter[path+1]
|
|
|
|
except:
|
2004-03-08 03:20:41 +05:30
|
|
|
(surname,val) = self.iter2path[node]
|
|
|
|
return self.path2iter.get((surname,val+1))
|
|
|
|
|
|
|
|
def on_iter_children(self,node):
|
2004-03-22 10:11:35 +05:30
|
|
|
"""Return the first child of the node"""
|
2004-03-08 03:20:41 +05:30
|
|
|
if node == None:
|
|
|
|
return self.top_path2iter[0]
|
2004-04-28 09:36:25 +05:30
|
|
|
else:
|
|
|
|
return self.path2iter.get((node,0))
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_iter_has_child(self, node):
|
2005-04-05 20:32:59 +05:30
|
|
|
'''returns true if this node has children'''
|
2004-03-08 03:20:41 +05:30
|
|
|
if node == None:
|
2004-08-20 03:05:16 +05:30
|
|
|
return len(self.sname_sub)
|
2004-03-22 10:11:35 +05:30
|
|
|
if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0:
|
2004-10-01 00:02:56 +05:30
|
|
|
return True
|
|
|
|
return False
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_iter_n_children(self,node):
|
2004-03-22 10:11:35 +05:30
|
|
|
if node == None:
|
2004-08-20 03:05:16 +05:30
|
|
|
return len(self.sname_sub)
|
|
|
|
try:
|
2004-03-08 03:20:41 +05:30
|
|
|
return len(self.sname_sub[node])
|
2004-08-20 03:05:16 +05:30
|
|
|
except:
|
|
|
|
return 0
|
2004-03-08 03:20:41 +05:30
|
|
|
|
|
|
|
def on_iter_nth_child(self,node,n):
|
2004-08-20 03:05:16 +05:30
|
|
|
try:
|
2004-12-10 05:08:43 +05:30
|
|
|
if node == None:
|
|
|
|
return self.top_path2iter[n]
|
|
|
|
try:
|
|
|
|
return self.path2iter[(node,n)]
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
except IndexError:
|
2004-03-08 03:20:41 +05:30
|
|
|
return None
|
|
|
|
|
|
|
|
def on_iter_parent(self, node):
|
2005-04-05 20:32:59 +05:30
|
|
|
'''returns the parent of this node'''
|
2004-03-22 10:11:35 +05:30
|
|
|
path = self.iter2path.get(node)
|
2004-03-08 03:20:41 +05:30
|
|
|
if path:
|
|
|
|
return path[0]
|
|
|
|
return None
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_sort_name(self,data,node):
|
2006-02-04 03:33:53 +05:30
|
|
|
n = Name()
|
|
|
|
n.unserialize(data[_NAME_COL])
|
|
|
|
return n.get_sort_name()
|
2004-03-23 10:31:19 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_spouse(self,data,node):
|
2005-04-05 20:32:59 +05:30
|
|
|
spouses_names = u""
|
2004-08-24 09:44:08 +05:30
|
|
|
handle = data[0]
|
|
|
|
for family_handle in data[_FAMILY_COL]:
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
for spouse_id in [family.get_father_handle(), family.get_mother_handle()]:
|
|
|
|
if not spouse_id:
|
|
|
|
continue
|
|
|
|
if spouse_id == handle:
|
|
|
|
continue
|
|
|
|
spouse = self.db.get_person_from_handle(spouse_id)
|
|
|
|
if len(spouses_names) > 0:
|
|
|
|
spouses_names += ", "
|
2005-01-01 09:57:15 +05:30
|
|
|
spouses_names += NameDisplay.displayer.display(spouse)
|
2005-04-05 20:32:59 +05:30
|
|
|
return spouses_names
|
2004-06-03 08:58:46 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_name(self,data,node):
|
2006-02-04 03:33:53 +05:30
|
|
|
n = Name()
|
|
|
|
n.unserialize(data[_NAME_COL])
|
|
|
|
return NameDisplay.displayer.sorted_name(n)
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_id(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
return data[_ID_COL]
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_change(self,data,node):
|
2005-12-30 09:27:31 +05:30
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[_CHANGE_COL])),
|
2005-05-11 19:34:47 +05:30
|
|
|
_codeset)
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_gender(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
return _GENDER[data[_GENDER_COL]]
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_birth_day(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
if data[_BIRTH_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
b=EventRef()
|
|
|
|
b.unserialize(data[_BIRTH_COL])
|
|
|
|
birth = self.db.get_event_from_handle(b.ref)
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(birth)
|
|
|
|
if date_str != "":
|
|
|
|
return cgi.escape(date_str)
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2005-06-02 08:50:42 +05:30
|
|
|
for event_ref in data[_EVENT_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2005-06-02 10:14:51 +05:30
|
|
|
etype = event.get_type()[0]
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(event)
|
2005-06-02 10:14:51 +05:30
|
|
|
if (etype in [Event.BAPTISM, Event.CHRISTEN]
|
2005-08-06 08:27:37 +05:30
|
|
|
and date_str != ""):
|
|
|
|
return "<i>" + cgi.escape(date_str) + "</i>"
|
2005-04-05 20:32:59 +05:30
|
|
|
|
|
|
|
return u""
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_death_day(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
if data[_DEATH_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
dr = EventRef()
|
|
|
|
dr.unserialize(data[_DEATH_COL])
|
|
|
|
death = self.db.get_event_from_handle(dr.ref)
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(death)
|
|
|
|
if date_str != "":
|
|
|
|
return cgi.escape(date_str)
|
2005-04-05 20:32:59 +05:30
|
|
|
|
2005-06-02 10:14:51 +05:30
|
|
|
for event_ref in data[_EVENT_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2005-06-02 10:14:51 +05:30
|
|
|
etype = event.get_type()[0]
|
2005-08-06 08:27:37 +05:30
|
|
|
date_str = DateHandler.get_date(event)
|
2005-06-02 10:14:51 +05:30
|
|
|
if (etype in [Event.BURIAL, Event.CREMATION]
|
2005-08-06 08:27:37 +05:30
|
|
|
and date_str != ""):
|
|
|
|
return "<i>" + cgi.escape(date_str) + "</i>"
|
2005-04-05 20:32:59 +05:30
|
|
|
|
|
|
|
return u""
|
2005-03-20 05:14:01 +05:30
|
|
|
|
|
|
|
def column_cause_of_death(self,data,node):
|
|
|
|
if data[_DEATH_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
dr = EventRef()
|
|
|
|
dr.unserialize(data[_DEATH_COL])
|
|
|
|
return self.db.get_event_from_handle(dr.ref).get_cause()
|
2005-03-20 05:14:01 +05:30
|
|
|
else:
|
|
|
|
return u""
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_birth_place(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
if data[_BIRTH_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
br = EventRef()
|
|
|
|
br.unserialize(data[_BIRTH_COL])
|
|
|
|
event = self.db.get_event_from_handle(br.ref)
|
2004-03-22 10:11:35 +05:30
|
|
|
if event:
|
2005-04-05 20:32:59 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
if place_title != "":
|
|
|
|
return cgi.escape(place_title)
|
|
|
|
|
2005-06-02 10:14:51 +05:30
|
|
|
for event_ref in data[_EVENT_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2005-06-02 10:14:51 +05:30
|
|
|
etype = event.get_type()[0]
|
|
|
|
if etype in [Event.BAPTISM, Event.CHRISTEN]:
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2005-04-05 20:32:59 +05:30
|
|
|
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
if place_title != "":
|
|
|
|
return "<i>" + cgi.escape(place_title) + "</i>"
|
|
|
|
|
2004-03-10 10:45:06 +05:30
|
|
|
return u""
|
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_death_place(self,data,node):
|
2004-06-27 08:40:06 +05:30
|
|
|
if data[_DEATH_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
dr = EventRef()
|
|
|
|
dr.unserialize(data[_DEATH_COL])
|
|
|
|
event = self.db.get_event_from_handle(dr.ref)
|
2004-03-22 10:11:35 +05:30
|
|
|
if event:
|
2005-04-05 20:32:59 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
if place_title != "":
|
|
|
|
return cgi.escape(place_title)
|
|
|
|
|
2005-06-02 10:14:51 +05:30
|
|
|
for event_ref in data[_EVENT_COL]:
|
2006-02-04 03:33:53 +05:30
|
|
|
er = EventRef()
|
|
|
|
er.unserialize(event_ref)
|
|
|
|
event = self.db.get_event_from_handle(er.ref)
|
2005-06-02 10:14:51 +05:30
|
|
|
etype = event.get_type()[0]
|
|
|
|
if etype in [Event.BURIAL, Event.CREMATION]:
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2005-04-05 20:32:59 +05:30
|
|
|
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
if place_title != "":
|
|
|
|
return "<i>" + cgi.escape(place_title) + "</i>"
|
|
|
|
|
2004-03-10 10:45:06 +05:30
|
|
|
return u""
|
|
|
|
|
2005-09-16 20:55:27 +05:30
|
|
|
def column_marker_text(self,data,node):
|
|
|
|
try:
|
|
|
|
if data[_MARKER_COL]:
|
|
|
|
if data[_MARKER_COL][0] == PrimaryObject.MARKER_CUSTOM:
|
|
|
|
return data[_MARKER_COL][1]
|
2006-02-04 06:26:54 +05:30
|
|
|
elif data[_MARKER_COL][0] in Utils.marker_types.keys():
|
2005-09-16 20:55:27 +05:30
|
|
|
return Utils.marker_types[data[_MARKER_COL][0]]
|
|
|
|
except IndexError:
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def column_marker_color(self,data,node):
|
|
|
|
try:
|
|
|
|
if data[_MARKER_COL]:
|
|
|
|
if data[_MARKER_COL][0] == PrimaryObject.MARKER_COMPLETE:
|
|
|
|
return u"#46a046" # green
|
|
|
|
if data[_MARKER_COL][0] == PrimaryObject.MARKER_TODO:
|
|
|
|
return u"#df421e" # red
|
|
|
|
if data[_MARKER_COL][0] == PrimaryObject.MARKER_CUSTOM:
|
|
|
|
return u"#eed680" # blue
|
|
|
|
except IndexError:
|
|
|
|
pass
|
|
|
|
return None
|
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def column_tooltip(self,data,node):
|
2006-03-10 00:37:13 +05:30
|
|
|
if const.use_tips:
|
|
|
|
return ToolTips.TipFromFunction(self.db, lambda: self.db.get_person_from_handle(data[0]))
|
|
|
|
else:
|
|
|
|
return u''
|
2005-08-19 19:56:03 +05:30
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
def column_int_id(self,data,node):
|
|
|
|
return node
|
|
|
|
|
|
|
|
def column_header(self,node):
|
|
|
|
return node
|
|
|
|
|
|
|
|
def column_header_view(self,node):
|
2004-12-10 05:08:43 +05:30
|
|
|
return True
|
2004-08-26 09:33:11 +05:30
|
|
|
|
2004-04-28 09:36:25 +05:30
|
|
|
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
2004-08-26 09:33:11 +05:30
|
|
|
|
|
|
|
# table of column definitions
|
|
|
|
# (unless this is declared after the PeopleModel class, an error is thrown)
|
|
|
|
COLUMN_DEFS = [
|
|
|
|
# data column (method) header column (method) column data type
|
2005-03-20 05:14:01 +05:30
|
|
|
(PeopleModel.column_name, PeopleModel.column_header, str),
|
|
|
|
(PeopleModel.column_id, None, str),
|
|
|
|
(PeopleModel.column_gender, None, str),
|
|
|
|
(PeopleModel.column_birth_day, None, str),
|
|
|
|
(PeopleModel.column_birth_place,None, str),
|
|
|
|
(PeopleModel.column_death_day, None, str),
|
|
|
|
(PeopleModel.column_death_place,None, str),
|
|
|
|
(PeopleModel.column_spouse, None, str),
|
|
|
|
(PeopleModel.column_change, None, str),
|
|
|
|
(PeopleModel.column_cause_of_death, None, str),
|
2005-09-16 20:55:27 +05:30
|
|
|
(PeopleModel.column_marker_text, None, str),
|
|
|
|
(PeopleModel.column_marker_color, None, str),
|
2004-08-26 09:33:11 +05:30
|
|
|
# the order of the above columns must match PeopleView.column_names
|
|
|
|
|
|
|
|
# these columns are hidden, and must always be last in the list
|
2005-08-19 19:56:03 +05:30
|
|
|
(PeopleModel.column_tooltip, None, object),
|
2006-03-19 08:55:31 +05:30
|
|
|
# (PeopleModel.column_sort_name, None, str),
|
2005-03-20 05:14:01 +05:30
|
|
|
(PeopleModel.column_int_id, None, str),
|
2004-08-26 09:33:11 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
# dynamic calculation of column indices, for use by various Views
|
2006-03-19 08:55:31 +05:30
|
|
|
COLUMN_INT_ID = 13
|
2004-08-26 09:33:11 +05:30
|
|
|
|
|
|
|
# indices into main column definition table
|
|
|
|
COLUMN_DEF_LIST = 0
|
|
|
|
COLUMN_DEF_HEADER = 1
|
|
|
|
COLUMN_DEF_TYPE = 2
|