2
# Gramps - a GTK+/GNOME based genealogy program
4
# Copyright (C) 2000-2006 Donald N. Allingham
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
# $Id: sourcemodel.py 18361 2011-10-23 03:13:50Z paul-franklin $
22
#-------------------------------------------------------------------------
26
#-------------------------------------------------------------------------
28
log = logging.getLogger(".")
30
#-------------------------------------------------------------------------
34
#-------------------------------------------------------------------------
37
#-------------------------------------------------------------------------
41
#-------------------------------------------------------------------------
45
from gui.views.treemodels.flatbasemodel import FlatBaseModel
47
#-------------------------------------------------------------------------
51
#-------------------------------------------------------------------------
52
class SourceModel(FlatBaseModel):
54
def __init__(self,db,scol=0, order=gtk.SORT_ASCENDING,search=None,
55
skip=set(), sort_map=None):
56
self.map = db.get_raw_source_data
57
self.gen_cursor = db.get_source_cursor
76
FlatBaseModel.__init__(self,db,scol, order,tooltip_column=7,search=search,
77
skip=skip, sort_map=sort_map)
81
Unset all elements that can prevent garbage collection
84
self.gen_cursor = None
88
FlatBaseModel.destroy(self)
90
def on_get_n_columns(self):
91
return len(self.fmap)+1
93
def column_title(self,data):
94
return unicode(data[2])
96
def column_handle(self,data):
97
return unicode(data[0])
99
def column_author(self,data):
100
return unicode(data[3])
102
def column_abbrev(self,data):
103
return unicode(data[7])
105
def column_id(self,data):
106
return unicode(data[1])
108
def column_pubinfo(self,data):
109
return unicode(data[4])
111
def column_change(self,data):
112
return Utils.format_time(data[8])
114
def sort_change(self,data):
115
return "%012x" % data[8]
117
def column_tooltip(self,data):
120
t = ToolTips.TipFromFunction(self.db, lambda:
121
self.db.get_source_from_handle(data[0]))
123
log.error("Failed to create tooltip.",exc_info=True)