diff --git a/ChangeLog b/ChangeLog index f51a49087..9a88a7649 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-17 Richard Taylor + * 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 * various: merge changes made in gramps20 branch with main trunk. diff --git a/src/DisplayModels.py b/src/DisplayModels.py index 0ce0ebfd9..e7879da42 100644 --- a/src/DisplayModels.py +++ b/src/DisplayModels.py @@ -63,13 +63,14 @@ _codeset = locale.nl_langinfo(locale.CODESET) #------------------------------------------------------------------------- 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) self.set_property("leak_references",False) self.db = db self.sort_func = self.smap[scol] self.sort_col = scol self.reverse = (order == gtk.SORT_DESCENDING) + self.tooltip_column = tooltip_column self.rebuild_data() def set_sort_column(self,col): @@ -288,6 +289,7 @@ class SourceModel(BaseModel): self.column_pubinfo, self.column_change, self.column_handle, + self.column_tooltip ] self.smap = [ self.column_title, @@ -297,7 +299,7 @@ class SourceModel(BaseModel): self.column_pubinfo, self.sort_change, ] - BaseModel.__init__(self,db,scol,order) + BaseModel.__init__(self,db,scol,order,tooltip_column=7) def on_get_n_columns(self): return len(self.fmap)+1 @@ -326,6 +328,9 @@ class SourceModel(BaseModel): def sort_change(self,data): return time.localtime(data[8]) + def column_tooltip(self,data): + return unicode(data[2]) + #------------------------------------------------------------------------- # # PlaceModel @@ -349,6 +354,7 @@ class PlaceModel(BaseModel): self.column_latitude, self.column_change, self.column_handle, + self.column_tooltip ] self.smap = [ self.column_name, @@ -364,7 +370,7 @@ class PlaceModel(BaseModel): self.column_change, self.column_handle, ] - BaseModel.__init__(self,db,scol,order) + BaseModel.__init__(self,db,scol,order,tooltip_column=12) def on_get_n_columns(self): return len(self.fmap)+1 @@ -427,6 +433,9 @@ class PlaceModel(BaseModel): return unicode(time.strftime(_date_format,time.localtime(data[11])), _codeset) + def column_tooltip(self,data): + return unicode(data[2]) + #------------------------------------------------------------------------- # # MediaModel @@ -446,6 +455,7 @@ class MediaModel(BaseModel): self.column_change, self.column_date, self.column_handle, + self.column_tooltip ] self.smap = [ self.column_description, @@ -456,7 +466,7 @@ class MediaModel(BaseModel): self.column_date, self.column_handle, ] - BaseModel.__init__(self,db,scol,order) + BaseModel.__init__(self,db,scol,order,tooltip_column=7) def on_get_n_columns(self): return len(self.fmap)+1 @@ -491,6 +501,9 @@ class MediaModel(BaseModel): return unicode(time.strftime(_date_format,time.localtime(data[8])), _codeset) + def column_tooltip(self,data): + return unicode(data[4]) + #------------------------------------------------------------------------- # # EventModel @@ -511,6 +524,7 @@ class EventModel(BaseModel): self.column_cause, self.column_change, self.column_handle, + self.column_tooltip, ] self.smap = [ self.column_description, @@ -522,7 +536,7 @@ class EventModel(BaseModel): self.sort_change, self.column_handle, ] - BaseModel.__init__(self,db,scol,order) + BaseModel.__init__(self,db,scol,order,tooltip_column=8) def on_get_n_columns(self): return len(self.fmap)+1 @@ -567,6 +581,9 @@ class EventModel(BaseModel): return unicode(time.strftime(_date_format,time.localtime(data[11])), _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): self.gen_cursor = db.get_repository_cursor + self.get_handles = db.get_repository_handles self.map = db.repository_map self.fmap = [ self.column_name, @@ -590,8 +608,10 @@ class RepositoryModel(BaseModel): self.column_country, self.column_email, self.column_search_url, - self.column_handle, + self.column_handle, + self.column_tooltip ] + self.smap = [ self.column_name, self.column_id, @@ -606,7 +626,8 @@ class RepositoryModel(BaseModel): self.column_search_url, self.column_handle, ] - BaseModel.__init__(self,db,scol,order) + + BaseModel.__init__(self,db,scol,order,tooltip_column=12) def on_get_n_columns(self): return len(self.fmap)+1 @@ -673,3 +694,6 @@ class RepositoryModel(BaseModel): def column_home_url(self,data): return unicode(data[7]) + + def column_tooltip(self,data): + return unicode(data[3]) diff --git a/src/PageView.py b/src/PageView.py index d0c46f972..6448d9db6 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -21,6 +21,7 @@ # $Id$ import gtk +import TreeTips NAVIGATION_NONE = -1 NAVIGATION_PERSON = 0 @@ -353,12 +354,16 @@ class ListView(PageView): self.columns.append(column) self.list.append_column(column) index += 1 - + + def build_tree(self): self.model = self.make_model(self.dbstate.db,self.sort_col) self.list.set_model(self.model) 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): for sig in self.signal_map: db.connect(sig, self.signal_map[sig]) diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 00f34583a..6f099d7fa 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -107,6 +107,7 @@ class PeopleModel(gtk.GenericTreeModel): self.top_visible = {} self.invert_result = invert_result self.sortnames = {} + self.tooltip_column = 10 self.rebuild_data(data_filter) def rebuild_data(self,data_filter=None,skip=None): @@ -407,6 +408,9 @@ class PeopleModel(gtk.GenericTreeModel): return u"" + def column_tooltip(self,data,node): + return NameDisplay.displayer.sorted_name(data[_NAME_COL]) + def column_int_id(self,data,node): return node @@ -435,6 +439,7 @@ COLUMN_DEFS = [ # the order of the above columns must match PeopleView.column_names # 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_int_id, None, str), ] diff --git a/src/PersonView.py b/src/PersonView.py index 4870e439e..d1f78f6d6 100644 --- a/src/PersonView.py +++ b/src/PersonView.py @@ -50,6 +50,7 @@ import EditPerson import NameDisplay import Utils import QuestionDialog +import TreeTips from DdTargets import DdTargets @@ -433,6 +434,10 @@ class PersonView(PageView.PersonNavView): self.dbstate.db, self.DataFilter, self.filter_invert.get_active()) 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): if obj.get_active(): self.filterbar.show() diff --git a/src/RepositoryView.py b/src/RepositoryView.py index e1688b71d..7d67b3c9f 100644 --- a/src/RepositoryView.py +++ b/src/RepositoryView.py @@ -38,6 +38,7 @@ import EditRepository import DisplayModels import const import Utils + from QuestionDialog import QuestionDialog, ErrorDialog #------------------------------------------------------------------------- @@ -75,15 +76,17 @@ class RepositoryView(PageView.ListView): 'repository-delete' : self.row_delete, 'repository-rebuild' : self.build_tree, } - + PageView.ListView.__init__(self,'Repository View',dbstate,uistate, column_names,len(column_names), DisplayModels.RepositoryModel, signal_map) + def column_order(self): return self.dbstate.db.get_repository_column_order() + def get_stock(self): return 'gramps-repository'