2005-08-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>

* src/DisplayModels.py: added basic tooltip support to models
	* src/PageView.py: added basic tooltip support
	* src/PeopleModel.py: added basic tooltip support


svn: r5109
This commit is contained in:
Richard Taylor 2005-08-19 12:44:44 +00:00
parent 704e0c4787
commit fbfdbae3bd
6 changed files with 56 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2005-08-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/DisplayModels.py: added basic tooltip support to models
* src/PageView.py: added basic tooltip support
* src/PeopleModel.py: added basic tooltip support
2005-08-17 Alex Roitman <shura@gramps-project.org> 2005-08-17 Alex Roitman <shura@gramps-project.org>
* various: merge changes made in gramps20 branch with main trunk. * various: merge changes made in gramps20 branch with main trunk.

View File

@ -63,13 +63,14 @@ _codeset = locale.nl_langinfo(locale.CODESET)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class BaseModel(gtk.GenericTreeModel): class BaseModel(gtk.GenericTreeModel):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,tooltip_column=None):
gtk.GenericTreeModel.__init__(self) gtk.GenericTreeModel.__init__(self)
self.set_property("leak_references",False) self.set_property("leak_references",False)
self.db = db self.db = db
self.sort_func = self.smap[scol] self.sort_func = self.smap[scol]
self.sort_col = scol self.sort_col = scol
self.reverse = (order == gtk.SORT_DESCENDING) self.reverse = (order == gtk.SORT_DESCENDING)
self.tooltip_column = tooltip_column
self.rebuild_data() self.rebuild_data()
def set_sort_column(self,col): def set_sort_column(self,col):
@ -288,6 +289,7 @@ class SourceModel(BaseModel):
self.column_pubinfo, self.column_pubinfo,
self.column_change, self.column_change,
self.column_handle, self.column_handle,
self.column_tooltip
] ]
self.smap = [ self.smap = [
self.column_title, self.column_title,
@ -297,7 +299,7 @@ class SourceModel(BaseModel):
self.column_pubinfo, self.column_pubinfo,
self.sort_change, self.sort_change,
] ]
BaseModel.__init__(self,db,scol,order) BaseModel.__init__(self,db,scol,order,tooltip_column=7)
def on_get_n_columns(self): def on_get_n_columns(self):
return len(self.fmap)+1 return len(self.fmap)+1
@ -326,6 +328,9 @@ class SourceModel(BaseModel):
def sort_change(self,data): def sort_change(self,data):
return time.localtime(data[8]) return time.localtime(data[8])
def column_tooltip(self,data):
return unicode(data[2])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# PlaceModel # PlaceModel
@ -349,6 +354,7 @@ class PlaceModel(BaseModel):
self.column_latitude, self.column_latitude,
self.column_change, self.column_change,
self.column_handle, self.column_handle,
self.column_tooltip
] ]
self.smap = [ self.smap = [
self.column_name, self.column_name,
@ -364,7 +370,7 @@ class PlaceModel(BaseModel):
self.column_change, self.column_change,
self.column_handle, self.column_handle,
] ]
BaseModel.__init__(self,db,scol,order) BaseModel.__init__(self,db,scol,order,tooltip_column=12)
def on_get_n_columns(self): def on_get_n_columns(self):
return len(self.fmap)+1 return len(self.fmap)+1
@ -427,6 +433,9 @@ class PlaceModel(BaseModel):
return unicode(time.strftime(_date_format,time.localtime(data[11])), return unicode(time.strftime(_date_format,time.localtime(data[11])),
_codeset) _codeset)
def column_tooltip(self,data):
return unicode(data[2])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# MediaModel # MediaModel
@ -446,6 +455,7 @@ class MediaModel(BaseModel):
self.column_change, self.column_change,
self.column_date, self.column_date,
self.column_handle, self.column_handle,
self.column_tooltip
] ]
self.smap = [ self.smap = [
self.column_description, self.column_description,
@ -456,7 +466,7 @@ class MediaModel(BaseModel):
self.column_date, self.column_date,
self.column_handle, self.column_handle,
] ]
BaseModel.__init__(self,db,scol,order) BaseModel.__init__(self,db,scol,order,tooltip_column=7)
def on_get_n_columns(self): def on_get_n_columns(self):
return len(self.fmap)+1 return len(self.fmap)+1
@ -491,6 +501,9 @@ class MediaModel(BaseModel):
return unicode(time.strftime(_date_format,time.localtime(data[8])), return unicode(time.strftime(_date_format,time.localtime(data[8])),
_codeset) _codeset)
def column_tooltip(self,data):
return unicode(data[4])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# EventModel # EventModel
@ -511,6 +524,7 @@ class EventModel(BaseModel):
self.column_cause, self.column_cause,
self.column_change, self.column_change,
self.column_handle, self.column_handle,
self.column_tooltip,
] ]
self.smap = [ self.smap = [
self.column_description, self.column_description,
@ -522,7 +536,7 @@ class EventModel(BaseModel):
self.sort_change, self.sort_change,
self.column_handle, self.column_handle,
] ]
BaseModel.__init__(self,db,scol,order) BaseModel.__init__(self,db,scol,order,tooltip_column=8)
def on_get_n_columns(self): def on_get_n_columns(self):
return len(self.fmap)+1 return len(self.fmap)+1
@ -567,6 +581,9 @@ class EventModel(BaseModel):
return unicode(time.strftime(_date_format,time.localtime(data[11])), return unicode(time.strftime(_date_format,time.localtime(data[11])),
_codeset) _codeset)
def column_tooltip(self,data):
return unicode(data[4])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -577,6 +594,7 @@ class RepositoryModel(BaseModel):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
self.gen_cursor = db.get_repository_cursor self.gen_cursor = db.get_repository_cursor
self.get_handles = db.get_repository_handles
self.map = db.repository_map self.map = db.repository_map
self.fmap = [ self.fmap = [
self.column_name, self.column_name,
@ -591,7 +609,9 @@ class RepositoryModel(BaseModel):
self.column_email, self.column_email,
self.column_search_url, self.column_search_url,
self.column_handle, self.column_handle,
self.column_tooltip
] ]
self.smap = [ self.smap = [
self.column_name, self.column_name,
self.column_id, self.column_id,
@ -606,7 +626,8 @@ class RepositoryModel(BaseModel):
self.column_search_url, self.column_search_url,
self.column_handle, self.column_handle,
] ]
BaseModel.__init__(self,db,scol,order)
BaseModel.__init__(self,db,scol,order,tooltip_column=12)
def on_get_n_columns(self): def on_get_n_columns(self):
return len(self.fmap)+1 return len(self.fmap)+1
@ -673,3 +694,6 @@ class RepositoryModel(BaseModel):
def column_home_url(self,data): def column_home_url(self,data):
return unicode(data[7]) return unicode(data[7])
def column_tooltip(self,data):
return unicode(data[3])

View File

@ -21,6 +21,7 @@
# $Id$ # $Id$
import gtk import gtk
import TreeTips
NAVIGATION_NONE = -1 NAVIGATION_NONE = -1
NAVIGATION_PERSON = 0 NAVIGATION_PERSON = 0
@ -354,11 +355,15 @@ class ListView(PageView):
self.list.append_column(column) self.list.append_column(column)
index += 1 index += 1
def build_tree(self): def build_tree(self):
self.model = self.make_model(self.dbstate.db,self.sort_col) self.model = self.make_model(self.dbstate.db,self.sort_col)
self.list.set_model(self.model) self.list.set_model(self.model)
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.list,self.model.tooltip_column,True)
def change_db(self,db): def change_db(self,db):
for sig in self.signal_map: for sig in self.signal_map:
db.connect(sig, self.signal_map[sig]) db.connect(sig, self.signal_map[sig])

View File

@ -107,6 +107,7 @@ class PeopleModel(gtk.GenericTreeModel):
self.top_visible = {} self.top_visible = {}
self.invert_result = invert_result self.invert_result = invert_result
self.sortnames = {} self.sortnames = {}
self.tooltip_column = 10
self.rebuild_data(data_filter) self.rebuild_data(data_filter)
def rebuild_data(self,data_filter=None,skip=None): def rebuild_data(self,data_filter=None,skip=None):
@ -407,6 +408,9 @@ class PeopleModel(gtk.GenericTreeModel):
return u"" return u""
def column_tooltip(self,data,node):
return NameDisplay.displayer.sorted_name(data[_NAME_COL])
def column_int_id(self,data,node): def column_int_id(self,data,node):
return node return node
@ -435,6 +439,7 @@ COLUMN_DEFS = [
# the order of the above columns must match PeopleView.column_names # the order of the above columns must match PeopleView.column_names
# these columns are hidden, and must always be last in the list # these columns are hidden, and must always be last in the list
(PeopleModel.column_tooltip, None, str),
(PeopleModel.column_sort_name, None, str), (PeopleModel.column_sort_name, None, str),
(PeopleModel.column_int_id, None, str), (PeopleModel.column_int_id, None, str),
] ]

View File

@ -50,6 +50,7 @@ import EditPerson
import NameDisplay import NameDisplay
import Utils import Utils
import QuestionDialog import QuestionDialog
import TreeTips
from DdTargets import DdTargets from DdTargets import DdTargets
@ -433,6 +434,10 @@ class PersonView(PageView.PersonNavView):
self.dbstate.db, self.DataFilter, self.filter_invert.get_active()) self.dbstate.db, self.DataFilter, self.filter_invert.get_active())
self.person_tree.set_model(self.person_model) self.person_tree.set_model(self.person_model)
if self.person_model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.person_tree,self.person_model.tooltip_column,True)
def filter_toggle(self,obj): def filter_toggle(self,obj):
if obj.get_active(): if obj.get_active():
self.filterbar.show() self.filterbar.show()

View File

@ -38,6 +38,7 @@ import EditRepository
import DisplayModels import DisplayModels
import const import const
import Utils import Utils
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -81,9 +82,11 @@ class RepositoryView(PageView.ListView):
DisplayModels.RepositoryModel, DisplayModels.RepositoryModel,
signal_map) signal_map)
def column_order(self): def column_order(self):
return self.dbstate.db.get_repository_column_order() return self.dbstate.db.get_repository_column_order()
def get_stock(self): def get_stock(self):
return 'gramps-repository' return 'gramps-repository'