2004-03-22 10:12:43 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-12 19:11:54 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2004-03-22 10:12:43 +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
|
|
|
|
#
|
2005-05-11 19:34:47 +05:30
|
|
|
# $Id$
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2005-01-01 09:57:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-08-24 09:18:15 +05:30
|
|
|
import time
|
2005-01-01 09:57:15 +05:30
|
|
|
from gettext import gettext as _
|
2005-05-11 19:34:47 +05:30
|
|
|
import locale
|
2006-01-09 16:58:44 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gobject
|
|
|
|
import gtk
|
|
|
|
|
2005-01-01 09:57:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import NameDisplay
|
2005-01-12 19:11:54 +05:30
|
|
|
import DateHandler
|
2005-06-03 15:32:50 +05:30
|
|
|
import RelLib
|
|
|
|
import Utils
|
2005-08-19 19:56:03 +05:30
|
|
|
import ToolTips
|
2005-12-30 09:27:31 +05:30
|
|
|
import GrampsLocale
|
2004-11-19 09:29:53 +05:30
|
|
|
|
2004-11-19 01:51:06 +05:30
|
|
|
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
|
|
|
|
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
|
|
|
|
2006-01-09 06:24:04 +05:30
|
|
|
def sfunc(a,b):
|
|
|
|
return locale.strcoll(a[0],b[0])
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# BaseModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class BaseModel(gtk.GenericTreeModel):
|
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,tooltip_column=None):
|
2004-03-22 10:12:43 +05:30
|
|
|
gtk.GenericTreeModel.__init__(self)
|
2004-08-30 09:20:33 +05:30
|
|
|
self.set_property("leak_references",False)
|
2004-03-22 10:12:43 +05:30
|
|
|
self.db = db
|
2005-05-24 18:38:06 +05:30
|
|
|
self.sort_func = self.smap[scol]
|
|
|
|
self.sort_col = scol
|
|
|
|
self.reverse = (order == gtk.SORT_DESCENDING)
|
2005-08-19 18:14:44 +05:30
|
|
|
self.tooltip_column = tooltip_column
|
2004-03-22 10:12:43 +05:30
|
|
|
self.rebuild_data()
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def set_sort_column(self,col):
|
|
|
|
self.sort_func = self.smap[col]
|
|
|
|
|
2004-10-08 09:29:55 +05:30
|
|
|
def sort_keys(self):
|
2005-05-24 18:38:06 +05:30
|
|
|
cursor = self.gen_cursor()
|
|
|
|
sarray = []
|
|
|
|
data = cursor.next()
|
|
|
|
while data:
|
|
|
|
sarray.append((self.sort_func(data[1]),data[0]))
|
|
|
|
data = cursor.next()
|
|
|
|
cursor.close()
|
2006-01-09 06:24:04 +05:30
|
|
|
sarray.sort(sfunc)
|
2005-05-24 18:38:06 +05:30
|
|
|
if self.reverse:
|
|
|
|
sarray.reverse()
|
|
|
|
return map(lambda x: x[1], sarray)
|
2004-10-08 09:29:55 +05:30
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
def rebuild_data(self):
|
2004-11-19 01:51:06 +05:30
|
|
|
if self.db.is_open():
|
|
|
|
self.datalist = self.sort_keys()
|
2004-12-20 04:25:41 +05:30
|
|
|
i = 0
|
|
|
|
self.indexlist = {}
|
|
|
|
for key in self.datalist:
|
|
|
|
self.indexlist[key] = i
|
|
|
|
i += 1
|
2004-11-19 01:51:06 +05:30
|
|
|
else:
|
|
|
|
self.datalist = []
|
2004-12-20 04:25:41 +05:30
|
|
|
self.indexlist = []
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-31 09:21:05 +05:30
|
|
|
def add_row_by_handle(self,handle):
|
|
|
|
self.datalist = self.sort_keys()
|
2004-12-20 04:25:41 +05:30
|
|
|
i = 0
|
|
|
|
self.indexlist = {}
|
|
|
|
for key in self.datalist:
|
|
|
|
self.indexlist[key] = i
|
|
|
|
i += 1
|
|
|
|
index = self.indexlist[handle]
|
2004-10-06 09:12:54 +05:30
|
|
|
node = self.get_iter(index)
|
|
|
|
self.row_inserted(index,node)
|
2004-08-31 09:21:05 +05:30
|
|
|
|
2004-08-30 09:20:33 +05:30
|
|
|
def delete_row_by_handle(self,handle):
|
2004-12-20 04:25:41 +05:30
|
|
|
index = self.indexlist[handle]
|
2005-04-04 06:41:50 +05:30
|
|
|
|
|
|
|
self.indexlist = {}
|
|
|
|
self.datalist = []
|
|
|
|
i = 0
|
|
|
|
for key in self.sort_keys():
|
|
|
|
if key != handle:
|
|
|
|
self.indexlist[key] = i
|
|
|
|
self.datalist.append(key)
|
|
|
|
i += 1
|
2004-08-30 09:20:33 +05:30
|
|
|
self.row_deleted(index)
|
|
|
|
|
|
|
|
def update_row_by_handle(self,handle):
|
2004-12-20 04:25:41 +05:30
|
|
|
index = self.indexlist[handle]
|
2004-10-06 09:12:54 +05:30
|
|
|
node = self.get_iter(index)
|
|
|
|
self.row_changed(index,node)
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_get_flags(self):
|
|
|
|
'''returns the GtkTreeModelFlags for this particular type of model'''
|
2004-08-19 22:19:16 +05:30
|
|
|
return gtk.TREE_MODEL_LIST_ONLY | gtk.TREE_MODEL_ITERS_PERSIST
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_get_n_columns(self):
|
2004-08-27 09:11:57 +05:30
|
|
|
return 1
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_get_path(self, node):
|
|
|
|
'''returns the tree path (a tuple of indices at the various
|
|
|
|
levels) for a particular node.'''
|
2005-04-23 21:23:30 +05:30
|
|
|
return self.indexlist[node]
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_get_column_type(self,index):
|
2005-08-19 19:56:03 +05:30
|
|
|
if index == self.tooltip_column:
|
|
|
|
return object
|
2004-03-22 10:12:43 +05:30
|
|
|
return gobject.TYPE_STRING
|
|
|
|
|
|
|
|
def on_get_iter(self, path):
|
2004-08-19 22:19:16 +05:30
|
|
|
try:
|
|
|
|
return self.datalist[path[0]]
|
|
|
|
except IndexError:
|
|
|
|
return None
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-10-06 09:12:54 +05:30
|
|
|
def on_get_value(self,node,col):
|
2004-08-25 09:07:48 +05:30
|
|
|
try:
|
2006-01-07 03:38:40 +05:30
|
|
|
return self.fmap[col](self.map(str(node)))
|
2004-08-25 09:07:48 +05:30
|
|
|
except:
|
|
|
|
return u''
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_iter_next(self, node):
|
|
|
|
'''returns the next node at this level of the tree'''
|
2004-08-19 22:19:16 +05:30
|
|
|
try:
|
2004-12-20 04:25:41 +05:30
|
|
|
return self.datalist[self.indexlist[node]+1]
|
2004-08-19 22:19:16 +05:30
|
|
|
except IndexError:
|
|
|
|
return None
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_iter_children(self,node):
|
|
|
|
"""Return the first child of the node"""
|
2005-12-06 12:08:09 +05:30
|
|
|
if node == None and self.datalist:
|
2004-08-19 22:19:16 +05:30
|
|
|
return self.datalist[0]
|
2004-03-22 10:12:43 +05:30
|
|
|
return None
|
|
|
|
|
|
|
|
def on_iter_has_child(self, node):
|
|
|
|
'''returns true if this node has children'''
|
|
|
|
if node == None:
|
2004-08-19 22:19:16 +05:30
|
|
|
return len(self.datalist) > 0
|
2004-08-30 09:20:33 +05:30
|
|
|
return False
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_iter_n_children(self,node):
|
|
|
|
if node == None:
|
2004-08-19 22:19:16 +05:30
|
|
|
return len(self.datalist)
|
2004-10-01 00:02:56 +05:30
|
|
|
return 0
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_iter_nth_child(self,node,n):
|
2004-08-19 08:07:35 +05:30
|
|
|
if node == None:
|
2004-08-19 22:19:16 +05:30
|
|
|
return self.datalist[n]
|
2004-08-19 08:07:35 +05:30
|
|
|
return None
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def on_iter_parent(self, node):
|
|
|
|
'''returns the parent of this node'''
|
|
|
|
return None
|
2004-11-19 01:51:06 +05:30
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceModel(BaseModel):
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
2006-01-07 03:38:40 +05:30
|
|
|
self.map = db.get_raw_source_data
|
2005-05-24 18:38:06 +05:30
|
|
|
self.gen_cursor = db.get_source_cursor
|
2004-03-22 10:12:43 +05:30
|
|
|
self.fmap = [
|
|
|
|
self.column_title,
|
|
|
|
self.column_id,
|
|
|
|
self.column_author,
|
|
|
|
self.column_abbrev,
|
|
|
|
self.column_pubinfo,
|
2004-08-24 09:18:15 +05:30
|
|
|
self.column_change,
|
2004-08-27 09:11:57 +05:30
|
|
|
self.column_handle,
|
2005-08-19 18:14:44 +05:30
|
|
|
self.column_tooltip
|
2004-03-22 10:12:43 +05:30
|
|
|
]
|
2005-05-24 18:38:06 +05:30
|
|
|
self.smap = [
|
|
|
|
self.column_title,
|
|
|
|
self.column_id,
|
|
|
|
self.column_author,
|
|
|
|
self.column_abbrev,
|
|
|
|
self.column_pubinfo,
|
|
|
|
self.sort_change,
|
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=7)
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-27 09:11:57 +05:30
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
def column_title(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[2])
|
|
|
|
|
2004-08-27 09:11:57 +05:30
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
def column_author(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[3])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_abbrev(self,data):
|
2004-11-27 05:01:50 +05:30
|
|
|
return unicode(data[7])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_id(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[1])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_pubinfo(self,data):
|
2004-11-27 05:01:50 +05:30
|
|
|
return unicode(data[4])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
def column_change(self,data):
|
2005-12-30 09:27:31 +05:30
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[8])),
|
|
|
|
GrampsLocale.codeset)
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def sort_change(self,data):
|
|
|
|
return time.localtime(data[8])
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def column_tooltip(self,data):
|
2005-08-19 19:56:03 +05:30
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_source_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.",exc_info=True)
|
2005-08-19 19:56:03 +05:30
|
|
|
return t
|
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PlaceModel
|
2004-03-22 10:12:43 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class PlaceModel(BaseModel):
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
|
|
|
self.gen_cursor = db.get_place_cursor
|
2006-01-07 03:38:40 +05:30
|
|
|
self.map = db.get_raw_place_data
|
2004-03-22 10:12:43 +05:30
|
|
|
self.fmap = [
|
|
|
|
self.column_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_parish,
|
2005-01-12 19:11:54 +05:30
|
|
|
self.column_postal_code,
|
2004-03-22 10:12:43 +05:30
|
|
|
self.column_city,
|
|
|
|
self.column_county,
|
|
|
|
self.column_state,
|
|
|
|
self.column_country,
|
|
|
|
self.column_longitude,
|
|
|
|
self.column_latitude,
|
2004-08-24 09:18:15 +05:30
|
|
|
self.column_change,
|
2004-08-11 09:12:38 +05:30
|
|
|
self.column_handle,
|
2005-08-19 18:14:44 +05:30
|
|
|
self.column_tooltip
|
2004-03-22 10:12:43 +05:30
|
|
|
]
|
2005-05-24 18:38:06 +05:30
|
|
|
self.smap = [
|
|
|
|
self.column_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_parish,
|
|
|
|
self.column_postal_code,
|
|
|
|
self.column_city,
|
|
|
|
self.column_county,
|
|
|
|
self.column_state,
|
|
|
|
self.column_country,
|
|
|
|
self.column_longitude,
|
|
|
|
self.column_latitude,
|
|
|
|
self.column_change,
|
|
|
|
self.column_handle,
|
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=12)
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-27 09:11:57 +05:30
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
2004-08-11 09:12:38 +05:30
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
def column_name(self,data):
|
|
|
|
return unicode(data[2])
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
def column_longitude(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[3])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_latitude(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[4])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_id(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[1])
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_parish(self,data):
|
|
|
|
try:
|
2004-08-11 09:12:38 +05:30
|
|
|
return data[5].get_parish()
|
2004-03-22 10:12:43 +05:30
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_city(self,data):
|
|
|
|
try:
|
2004-08-11 09:12:38 +05:30
|
|
|
return data[5].get_city()
|
2004-03-22 10:12:43 +05:30
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_county(self,data):
|
|
|
|
try:
|
2004-08-11 09:12:38 +05:30
|
|
|
return data[5].get_county()
|
2004-03-22 10:12:43 +05:30
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_state(self,data):
|
|
|
|
try:
|
2004-08-11 09:12:38 +05:30
|
|
|
return data[5].get_state()
|
2004-03-22 10:12:43 +05:30
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_country(self,data):
|
|
|
|
try:
|
2004-08-11 09:12:38 +05:30
|
|
|
return data[5].get_country()
|
2004-03-22 10:12:43 +05:30
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
2005-01-12 19:11:54 +05:30
|
|
|
def column_postal_code(self,data):
|
|
|
|
try:
|
|
|
|
return data[5].get_postal_code()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def sort_change(self,data):
|
|
|
|
return time.localtime(data[11])
|
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
def column_change(self,data):
|
2005-12-30 09:27:31 +05:30
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[11])),
|
2005-05-11 19:34:47 +05:30
|
|
|
_codeset)
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def column_tooltip(self,data):
|
2005-08-19 19:56:03 +05:30
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_place_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.", exc_info=True)
|
2005-08-19 19:56:03 +05:30
|
|
|
return t
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# FamilyModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class FamilyModel(BaseModel):
|
|
|
|
|
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
|
|
|
self.gen_cursor = db.get_family_cursor
|
|
|
|
self.map = db.get_raw_family_data
|
|
|
|
self.fmap = [
|
2006-01-09 06:24:04 +05:30
|
|
|
self.column_id,
|
2006-01-08 11:14:19 +05:30
|
|
|
self.column_father,
|
|
|
|
self.column_mother,
|
|
|
|
self.column_type,
|
|
|
|
self.column_change,
|
|
|
|
self.column_handle,
|
|
|
|
self.column_tooltip
|
|
|
|
]
|
|
|
|
self.smap = [
|
2006-01-09 06:24:04 +05:30
|
|
|
self.column_id,
|
2006-01-08 11:14:19 +05:30
|
|
|
self.sort_father,
|
|
|
|
self.sort_mother,
|
|
|
|
self.column_type,
|
|
|
|
self.sort_change,
|
|
|
|
self.column_handle,
|
|
|
|
self.column_tooltip
|
|
|
|
]
|
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=6)
|
|
|
|
|
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
|
|
|
|
|
|
|
def column_father(self,data):
|
|
|
|
if data[2]:
|
|
|
|
person = self.db.get_person_from_handle(data[2])
|
|
|
|
return unicode(NameDisplay.displayer.sorted_name(person.primary_name))
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def sort_father(self,data):
|
|
|
|
if data[2]:
|
|
|
|
person = self.db.get_person_from_handle(data[2])
|
|
|
|
return person.primary_name.get_sort_name()
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def column_mother(self,data):
|
|
|
|
if data[3]:
|
|
|
|
person = self.db.get_person_from_handle(data[3])
|
|
|
|
return unicode(NameDisplay.displayer.sorted_name(person.primary_name))
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def sort_mother(self,data):
|
|
|
|
if data[3]:
|
|
|
|
person = self.db.get_person_from_handle(data[3])
|
|
|
|
return person.primary_name.get_sort_name()
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def column_type(self,data):
|
|
|
|
t = data[5]
|
|
|
|
if t[0] == RelLib.Family.CUSTOM:
|
|
|
|
val = t[1]
|
|
|
|
else:
|
|
|
|
val = Utils.family_relations[t[0]]
|
|
|
|
return unicode(val)
|
|
|
|
|
|
|
|
def column_id(self,data):
|
|
|
|
return unicode(data[1])
|
|
|
|
|
|
|
|
def sort_change(self,data):
|
|
|
|
return time.localtime(data[13])
|
|
|
|
|
|
|
|
def column_change(self,data):
|
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[13])),
|
|
|
|
_codeset)
|
|
|
|
|
|
|
|
def column_tooltip(self,data):
|
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_family_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.", exc_info=True)
|
2006-01-08 11:14:19 +05:30
|
|
|
return t
|
|
|
|
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# MediaModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class MediaModel(BaseModel):
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
|
|
|
self.gen_cursor = db.get_media_cursor
|
2006-01-07 03:38:40 +05:30
|
|
|
self.map = db.get_raw_object_data
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
self.fmap = [
|
|
|
|
self.column_description,
|
|
|
|
self.column_id,
|
|
|
|
self.column_mime,
|
|
|
|
self.column_path,
|
2004-08-24 09:18:15 +05:30
|
|
|
self.column_change,
|
2005-01-12 19:11:54 +05:30
|
|
|
self.column_date,
|
2004-08-24 09:18:15 +05:30
|
|
|
self.column_handle,
|
2005-08-19 18:14:44 +05:30
|
|
|
self.column_tooltip
|
2004-03-22 10:12:43 +05:30
|
|
|
]
|
2005-05-24 18:38:06 +05:30
|
|
|
self.smap = [
|
|
|
|
self.column_description,
|
|
|
|
self.column_id,
|
|
|
|
self.column_mime,
|
|
|
|
self.column_path,
|
|
|
|
self.sort_change,
|
|
|
|
self.column_date,
|
|
|
|
self.column_handle,
|
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=7)
|
2004-03-22 10:12:43 +05:30
|
|
|
|
2004-08-27 09:11:57 +05:30
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
2004-03-22 10:12:43 +05:30
|
|
|
def column_description(self,data):
|
2005-12-06 12:08:09 +05:30
|
|
|
try:
|
|
|
|
return unicode(data[4])
|
|
|
|
except:
|
|
|
|
return unicode(data[4],'latin1')
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_path(self,data):
|
2005-12-06 12:08:09 +05:30
|
|
|
try:
|
|
|
|
return unicode(data[2])
|
|
|
|
except:
|
|
|
|
return unicode(data[2].encode('iso-8859-1'))
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_mime(self,data):
|
2005-02-16 11:11:33 +05:30
|
|
|
if data[3]:
|
|
|
|
return unicode(data[3])
|
|
|
|
else:
|
|
|
|
return _('Note')
|
2004-03-22 10:12:43 +05:30
|
|
|
|
|
|
|
def column_id(self,data):
|
2004-08-11 09:12:38 +05:30
|
|
|
return unicode(data[1])
|
2004-08-24 09:18:15 +05:30
|
|
|
|
2005-01-12 19:11:54 +05:30
|
|
|
def column_date(self,data):
|
|
|
|
if data[9]:
|
|
|
|
return unicode(DateHandler.displayer.display(data[9]))
|
|
|
|
return u''
|
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def sort_change(self,data):
|
|
|
|
return time.localtime(data[8])
|
|
|
|
|
2004-08-24 09:18:15 +05:30
|
|
|
def column_change(self,data):
|
2005-12-30 09:27:31 +05:30
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[8])),
|
2005-05-11 19:34:47 +05:30
|
|
|
_codeset)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def column_tooltip(self,data):
|
2005-08-19 19:56:03 +05:30
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_object_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.", exc_info=True)
|
2005-08-19 19:56:03 +05:30
|
|
|
return t
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2005-06-07 10:38:50 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EventModel(BaseModel):
|
|
|
|
|
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
|
|
|
self.gen_cursor = db.get_event_cursor
|
2006-01-07 03:38:40 +05:30
|
|
|
self.map = db.get_raw_event_data
|
2005-06-07 10:38:50 +05:30
|
|
|
|
|
|
|
self.fmap = [
|
|
|
|
self.column_description,
|
|
|
|
self.column_id,
|
|
|
|
self.column_type,
|
|
|
|
self.column_date,
|
|
|
|
self.column_place,
|
|
|
|
self.column_cause,
|
2005-06-08 21:20:19 +05:30
|
|
|
self.column_change,
|
2005-06-07 10:38:50 +05:30
|
|
|
self.column_handle,
|
2005-08-19 18:14:44 +05:30
|
|
|
self.column_tooltip,
|
2005-06-07 10:38:50 +05:30
|
|
|
]
|
|
|
|
self.smap = [
|
|
|
|
self.column_description,
|
|
|
|
self.column_id,
|
|
|
|
self.column_type,
|
|
|
|
self.column_date,
|
|
|
|
self.column_place,
|
|
|
|
self.column_cause,
|
2005-06-08 21:20:19 +05:30
|
|
|
self.sort_change,
|
2005-06-07 10:38:50 +05:30
|
|
|
self.column_handle,
|
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=8)
|
2005-06-07 10:38:50 +05:30
|
|
|
|
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
|
|
|
def column_description(self,data):
|
|
|
|
return unicode(data[4])
|
|
|
|
|
|
|
|
def column_cause(self,data):
|
|
|
|
return unicode(data[6])
|
|
|
|
|
|
|
|
def column_place(self,data):
|
|
|
|
if data[5]:
|
|
|
|
return unicode(self.db.get_place_from_handle(data[5]).get_title())
|
|
|
|
else:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_type(self,data):
|
2005-06-16 09:38:42 +05:30
|
|
|
(code,val) = data[2]
|
|
|
|
if code == RelLib.Event.CUSTOM:
|
|
|
|
return unicode(val)
|
|
|
|
else:
|
|
|
|
val = Utils.personal_events.get(code)
|
|
|
|
if not val:
|
|
|
|
val = Utils.family_events.get(code,_("Unknown"))
|
|
|
|
return val
|
2005-06-07 10:38:50 +05:30
|
|
|
|
|
|
|
def column_id(self,data):
|
|
|
|
return unicode(data[1])
|
|
|
|
|
|
|
|
def column_date(self,data):
|
|
|
|
if data[3]:
|
|
|
|
return unicode(DateHandler.displayer.display(data[3]))
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
|
|
|
|
|
|
|
def sort_change(self,data):
|
|
|
|
return time.localtime(data[11])
|
|
|
|
|
|
|
|
def column_change(self,data):
|
2005-12-30 09:27:31 +05:30
|
|
|
return unicode(time.strftime('%x %X',time.localtime(data[11])),
|
2005-06-07 10:38:50 +05:30
|
|
|
_codeset)
|
|
|
|
|
2005-08-19 18:14:44 +05:30
|
|
|
def column_tooltip(self,data):
|
2005-08-19 19:56:03 +05:30
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_event_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.", exc_info=True)
|
2005-08-19 19:56:03 +05:30
|
|
|
return t
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# RepositoryModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class RepositoryModel(BaseModel):
|
|
|
|
|
|
|
|
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
|
|
|
self.gen_cursor = db.get_repository_cursor
|
2005-08-19 18:14:44 +05:30
|
|
|
self.get_handles = db.get_repository_handles
|
2006-01-07 03:38:40 +05:30
|
|
|
self.map = db.get_raw_repository_data
|
2005-05-27 23:13:04 +05:30
|
|
|
self.fmap = [
|
|
|
|
self.column_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_type,
|
|
|
|
self.column_home_url,
|
|
|
|
self.column_postal_code,
|
|
|
|
self.column_city,
|
|
|
|
self.column_county,
|
|
|
|
self.column_state,
|
|
|
|
self.column_country,
|
|
|
|
self.column_email,
|
|
|
|
self.column_search_url,
|
2005-08-19 18:14:44 +05:30
|
|
|
self.column_handle,
|
|
|
|
self.column_tooltip
|
2005-05-27 23:13:04 +05:30
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2005-05-27 23:13:04 +05:30
|
|
|
self.smap = [
|
|
|
|
self.column_name,
|
|
|
|
self.column_id,
|
|
|
|
self.column_type,
|
|
|
|
self.column_home_url,
|
|
|
|
self.column_postal_code,
|
|
|
|
self.column_city,
|
|
|
|
self.column_county,
|
|
|
|
self.column_state,
|
|
|
|
self.column_country,
|
|
|
|
self.column_email,
|
|
|
|
self.column_search_url,
|
|
|
|
self.column_handle,
|
|
|
|
]
|
2005-08-19 18:14:44 +05:30
|
|
|
|
|
|
|
BaseModel.__init__(self,db,scol,order,tooltip_column=12)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
def on_get_n_columns(self):
|
|
|
|
return len(self.fmap)+1
|
|
|
|
|
|
|
|
def column_handle(self,data):
|
|
|
|
return unicode(data[0])
|
|
|
|
|
|
|
|
def column_id(self,data):
|
|
|
|
return unicode(data[1])
|
|
|
|
|
|
|
|
def column_type(self,data):
|
2005-06-03 15:32:50 +05:30
|
|
|
rtype = data[2]
|
|
|
|
if rtype[0] == RelLib.Event.CUSTOM or rtype[0] not in Utils.repository_types:
|
|
|
|
name = rtype[1]
|
|
|
|
else:
|
|
|
|
name = Utils.repository_types[rtype[0]]
|
|
|
|
return unicode(name)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
def column_name(self,data):
|
|
|
|
return unicode(data[3])
|
|
|
|
|
|
|
|
def column_city(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_city()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_county(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_county()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_state(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_state()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_country(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_country()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_postal_code(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_postal_code()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_phone(self,data):
|
|
|
|
try:
|
|
|
|
return data[4].get_phone()
|
|
|
|
except:
|
|
|
|
return u''
|
|
|
|
|
|
|
|
def column_email(self,data):
|
|
|
|
return unicode(data[5])
|
|
|
|
|
|
|
|
def column_search_url(self,data):
|
|
|
|
return unicode(data[6])
|
2005-06-03 10:04:21 +05:30
|
|
|
|
2005-05-27 23:13:04 +05:30
|
|
|
def column_home_url(self,data):
|
|
|
|
return unicode(data[7])
|
2005-08-19 18:14:44 +05:30
|
|
|
|
|
|
|
def column_tooltip(self,data):
|
2005-08-19 19:56:03 +05:30
|
|
|
try:
|
|
|
|
t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_repository_from_handle(data[0]))
|
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Failed to create tooltip.", exc_info=True)
|
2005-08-19 19:56:03 +05:30
|
|
|
return t
|