From c56fb05d1cb0013628c547ce732cd64d868587fc Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 18 Jan 2013 00:04:18 +0000 Subject: [PATCH] Remove handle and tooltip columns from models svn: r21162 --- gramps/gui/selectors/baseselector.py | 31 +++++--------- gramps/gui/selectors/selectcitation.py | 3 -- gramps/gui/selectors/selectevent.py | 3 -- gramps/gui/selectors/selectfamily.py | 3 -- gramps/gui/selectors/selectnote.py | 3 -- gramps/gui/selectors/selectobject.py | 3 -- gramps/gui/selectors/selectperson.py | 3 -- gramps/gui/selectors/selectplace.py | 3 -- gramps/gui/selectors/selectrepository.py | 3 -- gramps/gui/selectors/selectsource.py | 3 -- gramps/gui/views/listview.py | 3 +- .../gui/views/treemodels/citationbasemodel.py | 13 ------ .../gui/views/treemodels/citationlistmodel.py | 8 +--- .../gui/views/treemodels/citationtreemodel.py | 13 +----- gramps/gui/views/treemodels/eventmodel.py | 16 ++------ gramps/gui/views/treemodels/familymodel.py | 16 ++------ gramps/gui/views/treemodels/flatbasemodel.py | 40 ++++++++++--------- gramps/gui/views/treemodels/mediamodel.py | 10 ++--- gramps/gui/views/treemodels/notemodel.py | 12 ++---- gramps/gui/views/treemodels/peoplemodel.py | 23 +++-------- gramps/gui/views/treemodels/placemodel.py | 22 +++------- gramps/gui/views/treemodels/repomodel.py | 13 +----- gramps/gui/views/treemodels/sourcemodel.py | 14 ++----- gramps/gui/views/treemodels/treebasemodel.py | 30 ++++++++------ gramps/plugins/lib/libpersonview.py | 1 - gramps/plugins/lib/libplaceview.py | 1 - gramps/plugins/view/citationlistview.py | 1 - gramps/plugins/view/citationtreeview.py | 1 - gramps/plugins/view/eventview.py | 1 - gramps/plugins/view/familyview.py | 1 - gramps/plugins/view/mediaview.py | 1 - gramps/plugins/view/noteview.py | 2 +- gramps/plugins/view/repoview.py | 1 - gramps/plugins/view/sourceview.py | 1 - 34 files changed, 84 insertions(+), 218 deletions(-) diff --git a/gramps/gui/selectors/baseselector.py b/gramps/gui/selectors/baseselector.py index fb0f22401..87733ea11 100644 --- a/gramps/gui/selectors/baseselector.py +++ b/gramps/gui/selectors/baseselector.py @@ -179,12 +179,19 @@ class BaseSelector(ManagedWindow): def get_selected_ids(self): mlist = [] - self.selection.selected_foreach(self.select_function,mlist) + self.selection.selected_foreach(self.select_function, mlist) return mlist - def select_function(self,store,path,iter,id_list): - handle_column = self.get_handle_column() - id_list.append(self.model.get_value(iter, handle_column)) + def first_selected(self): + """ first selected entry in the Selector tree + """ + mlist = [] + self.selection.selected_foreach(self.select_function, mlist) + return mlist[0] if mlist else None + + def select_function(self, store, path, iter_, id_list): + handle = store.get_handle_from_iter(iter_) + id_list.append(handle) def run(self): val = self.window.run() @@ -230,10 +237,6 @@ class BaseSelector(ManagedWindow): def get_from_handle_func2(self): return None - def get_handle_column(self): - # return 3 - assert False, "Must be defined in the subclass" - def set_show_search_bar(self, value): """make the search bar at the top shown """ @@ -245,18 +248,6 @@ class BaseSelector(ManagedWindow): else : self.search_bar.hide() - def begintree(self, store, path, node, sel_list): - handle_column = self.get_handle_column() - handle = store.get_value(node, handle_column) - sel_list.append(handle) - - def first_selected(self): - """ first selected entry in the Selector tree - """ - mlist = [] - self.selection.selected_foreach(self.begintree, mlist) - return mlist[0] if mlist else None - def column_order(self): """ returns a tuple indicating the column order of the model diff --git a/gramps/gui/selectors/selectcitation.py b/gramps/gui/selectors/selectcitation.py index 9508eac55..890c1043d 100644 --- a/gramps/gui/selectors/selectcitation.py +++ b/gramps/gui/selectors/selectcitation.py @@ -72,6 +72,3 @@ class SelectCitation(BaseSelector): def get_from_handle_func2(self): return self.db.get_citation_from_handle - - def get_handle_column(self): - return 9 diff --git a/gramps/gui/selectors/selectevent.py b/gramps/gui/selectors/selectevent.py index b94e0caa7..33511f5e5 100644 --- a/gramps/gui/selectors/selectevent.py +++ b/gramps/gui/selectors/selectevent.py @@ -68,6 +68,3 @@ class SelectEvent(BaseSelector): def get_from_handle_func(self): return self.db.get_event_from_handle - - def get_handle_column(self): - return 8 diff --git a/gramps/gui/selectors/selectfamily.py b/gramps/gui/selectors/selectfamily.py index 520220bfb..84bbc34b7 100644 --- a/gramps/gui/selectors/selectfamily.py +++ b/gramps/gui/selectors/selectfamily.py @@ -65,6 +65,3 @@ class SelectFamily(BaseSelector): def get_from_handle_func(self): return self.db.get_family_from_handle - - def get_handle_column(self): - return 8 diff --git a/gramps/gui/selectors/selectnote.py b/gramps/gui/selectors/selectnote.py index 49356bb05..f98b2f8e7 100644 --- a/gramps/gui/selectors/selectnote.py +++ b/gramps/gui/selectors/selectnote.py @@ -71,6 +71,3 @@ class SelectNote(BaseSelector): def get_from_handle_func(self): return self.db.get_note_from_handle - - def get_handle_column(self): - return 6 diff --git a/gramps/gui/selectors/selectobject.py b/gramps/gui/selectors/selectobject.py index 3873d5d00..c2dbb5931 100644 --- a/gramps/gui/selectors/selectobject.py +++ b/gramps/gui/selectors/selectobject.py @@ -66,9 +66,6 @@ class SelectObject(BaseSelector): def get_from_handle_func(self): return self.db.get_object_from_handle - def get_handle_column(self): - return 8 - def get_column_titles(self): return [ (_('Title'), 350, BaseSelector.TEXT, 0), diff --git a/gramps/gui/selectors/selectperson.py b/gramps/gui/selectors/selectperson.py index bae478be4..b5a5423e4 100644 --- a/gramps/gui/selectors/selectperson.py +++ b/gramps/gui/selectors/selectperson.py @@ -86,9 +86,6 @@ class SelectPerson(BaseSelector): def get_from_handle_func(self): return self.db.get_person_from_handle - def get_handle_column(self): - return PeopleBaseModel.COLUMN_INT_ID - def exact_search(self): """ Returns a tuple indicating columns requiring an exact search diff --git a/gramps/gui/selectors/selectplace.py b/gramps/gui/selectors/selectplace.py index 62acf51d7..32d147173 100644 --- a/gramps/gui/selectors/selectplace.py +++ b/gramps/gui/selectors/selectplace.py @@ -72,6 +72,3 @@ class SelectPlace(BaseSelector): def get_from_handle_func(self): return self.db.get_place_from_handle - - def get_handle_column(self): - return PlaceListModel.HANDLE_COL diff --git a/gramps/gui/selectors/selectrepository.py b/gramps/gui/selectors/selectrepository.py index 6c0a913aa..741500801 100644 --- a/gramps/gui/selectors/selectrepository.py +++ b/gramps/gui/selectors/selectrepository.py @@ -62,8 +62,5 @@ class SelectRepository(BaseSelector): (_('ID'), 75, BaseSelector.TEXT, 1) ] - def get_handle_column(self): - return 14 - def get_from_handle_func(self): return self.db.get_repository_from_handle diff --git a/gramps/gui/selectors/selectsource.py b/gramps/gui/selectors/selectsource.py index a5b28f0c4..8d43b1c87 100644 --- a/gramps/gui/selectors/selectsource.py +++ b/gramps/gui/selectors/selectsource.py @@ -64,6 +64,3 @@ class SelectSource(BaseSelector): def get_from_handle_func(self): return self.db.get_source_from_handle - - def get_handle_column(self): - return 7 diff --git a/gramps/gui/views/listview.py b/gramps/gui/views/listview.py index 520901419..3f75772cc 100644 --- a/gramps/gui/views/listview.py +++ b/gramps/gui/views/listview.py @@ -103,7 +103,7 @@ class ListView(NavigationView): FILTER_TYPE = None # Set in inheriting class QR_CATEGORY = -1 - def __init__(self, title, pdata, dbstate, uistate, handle_col, + def __init__(self, title, pdata, dbstate, uistate, make_model, signal_map, bm_type, nav_group, multiple=False, filter_class=None): NavigationView.__init__(self, title, pdata, dbstate, uistate, @@ -118,7 +118,6 @@ class ListView(NavigationView): self.sort_col = 0 self.sort_order = Gtk.SortType.ASCENDING self.columns = [] - self.handle_col = handle_col self.make_model = make_model self.model = None self.signal_map = signal_map diff --git a/gramps/gui/views/treemodels/citationbasemodel.py b/gramps/gui/views/treemodels/citationbasemodel.py index 95b116db7..abbf7a0fe 100644 --- a/gramps/gui/views/treemodels/citationbasemodel.py +++ b/gramps/gui/views/treemodels/citationbasemodel.py @@ -122,9 +122,6 @@ class CitationBaseModel(object): # There is a problem returning None here. return '' - def citation_handle(self, data): - return cuni(data[COLUMN_HANDLE]) - def citation_change(self, data): return format_time(data[COLUMN_CHANGE]) @@ -194,14 +191,8 @@ class CitationBaseModel(object): except: return '' - def citation_tooltip(self, data): - return cuni('Citation tooltip') - # Fields access when 'data' is a Source - def source_handle(self, data): - return cuni(data[COLUMN2_HANDLE]) - def source_src_title(self, data): return cuni(data[COLUMN2_TITLE]) @@ -230,10 +221,6 @@ class CitationBaseModel(object): def source_sort2_change(self, data): return "%012x" % data[COLUMN2_CHANGE] - def source_tooltip(self, data): - return cuni('Source tooltip') - def dummy_sort_key(self, data): # dummy sort key for columns that don't have data return None - diff --git a/gramps/gui/views/treemodels/citationlistmodel.py b/gramps/gui/views/treemodels/citationlistmodel.py index 612a8c96e..f02359308 100644 --- a/gramps/gui/views/treemodels/citationlistmodel.py +++ b/gramps/gui/views/treemodels/citationlistmodel.py @@ -75,8 +75,6 @@ class CitationListModel(CitationBaseModel, FlatBaseModel): self.citation_src_pinfo, self.citation_src_private, self.citation_src_chan, - self.citation_handle, - self.citation_tooltip ] self.smap = [ self.citation_page, @@ -92,11 +90,9 @@ class CitationListModel(CitationBaseModel, FlatBaseModel): self.citation_src_pinfo, self.citation_src_private, self.citation_src_chan, - self.citation_handle, - self.citation_tooltip ] - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=12, - search=search, skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/citationtreemodel.py b/gramps/gui/views/treemodels/citationtreemodel.py index ce2552f6d..eb1dbf49c 100644 --- a/gramps/gui/views/treemodels/citationtreemodel.py +++ b/gramps/gui/views/treemodels/citationtreemodel.py @@ -83,8 +83,6 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): self.source_src_auth, # COL_SRC_AUTH (Source only) self.source_src_abbr, # COL_SRC_ABBR (Source only) self.source_src_pinfo, # COL_SRC_PINFO (Source only) - self.source_handle, - self.source_tooltip ] self.smap = [ self.source_src_title, @@ -96,15 +94,12 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): self.source_src_auth, self.source_src_abbr, self.source_src_pinfo, - self.source_handle, - self.source_tooltip ] TreeBaseModel.__init__(self, self.db, scol=scol, order=order, - tooltip_column=9, search=search, skip=skip, sort_map=sort_map, - nrgroups = 1, - group_can_have_handle = True, + nrgroups=1, + group_can_have_handle=True, has_secondary=True) def destroy(self): @@ -141,8 +136,6 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): None, None, None, - self.citation_handle, - self.citation_tooltip ] self.smap2 = [ self.citation_page, @@ -154,8 +147,6 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): self.dummy_sort_key, self.dummy_sort_key, self.dummy_sort_key, - self.citation_handle, - self.citation_tooltip ] def get_tree_levels(self): diff --git a/gramps/gui/views/treemodels/eventmodel.py b/gramps/gui/views/treemodels/eventmodel.py index d026830ab..c35332a31 100644 --- a/gramps/gui/views/treemodels/eventmodel.py +++ b/gramps/gui/views/treemodels/eventmodel.py @@ -84,8 +84,6 @@ class EventModel(FlatBaseModel): self.column_private, self.column_change, self.column_participant, - self.column_handle, - self.column_tooltip, ] self.smap = [ self.column_description, @@ -96,11 +94,9 @@ class EventModel(FlatBaseModel): self.column_private, self.sort_change, self.column_participant, - self.column_handle, - self.column_tooltip, - ] - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=8, - search=search, skip=skip, sort_map=sort_map) + ] + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -159,9 +155,6 @@ class EventModel(FlatBaseModel): return '' - def column_handle(self,data): - return cuni(data[COLUMN_HANDLE]) - def column_private(self, data): if data[COLUMN_PRIV]: return 'gramps-lock' @@ -174,6 +167,3 @@ class EventModel(FlatBaseModel): def column_change(self,data): return format_time(data[COLUMN_CHANGE]) - - def column_tooltip(self,data): - return cuni('Event tooltip') diff --git a/gramps/gui/views/treemodels/familymodel.py b/gramps/gui/views/treemodels/familymodel.py index 0ae192ae3..9d658ca66 100644 --- a/gramps/gui/views/treemodels/familymodel.py +++ b/gramps/gui/views/treemodels/familymodel.py @@ -71,9 +71,7 @@ class FamilyModel(FlatBaseModel): self.column_private, self.column_tags, self.column_change, - self.column_handle, self.column_tag_color, - self.column_tooltip, ] self.smap = [ self.column_id, @@ -84,12 +82,10 @@ class FamilyModel(FlatBaseModel): self.column_private, self.column_tags, self.sort_change, - self.column_handle, self.column_tag_color, - self.column_tooltip, ] - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=9, - search=search, skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -106,14 +102,11 @@ class FamilyModel(FlatBaseModel): """ Return the color column. """ - return 9 + return 8 def do_get_n_columns(self): return len(self.fmap)+1 - def column_handle(self, data): - return cuni(data[0]) - def column_father(self, data): if data[2]: person = self.db.get_person_from_handle(data[2]) @@ -182,9 +175,6 @@ class FamilyModel(FlatBaseModel): def column_change(self, data): return format_time(data[12]) - def column_tooltip(self, data): - return cuni('Family tooltip') - def get_tag_name(self, tag_handle): """ Return the tag name from the given tag handle. diff --git a/gramps/gui/views/treemodels/flatbasemodel.py b/gramps/gui/views/treemodels/flatbasemodel.py index fb4c72178..433910017 100644 --- a/gramps/gui/views/treemodels/flatbasemodel.py +++ b/gramps/gui/views/treemodels/flatbasemodel.py @@ -459,7 +459,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): """ def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, - tooltip_column=None, search=None, skip=set(), + search=None, skip=set(), sort_map=None): cput = time.clock() GObject.GObject.__init__(self) @@ -489,7 +489,6 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): self.set_search(search) self._reverse = (order == Gtk.SortType.DESCENDING) - self._tooltip_column = tooltip_column self.rebuild_data() _LOG.debug(self.__class__.__name__ + ' __init__ ' + @@ -558,12 +557,6 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): self._reverse = not self._reverse self.node_map.reverse_order() - def tooltip_column(self): - """ - Return the column for tooltips. - """ - return self._tooltip_column - def color_column(self): """ Return the color column. @@ -719,6 +712,21 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): """ return self.on_get_path_from_handle(handle) + def get_iter_from_handle(self, handle): + """ + Get the iter for a gramps handle. + """ + return self.node_map.new_iter(handle) + + def get_handle_from_iter(self, iter): + """ + Get the gramps handle for an iter. + """ + index = self.node_map.real_index(iter.user_data) + return self.node_map.get_handle(index) + + # The following implement the public interface of Gtk.TreeModel + def do_get_flags(self): """ Returns the GtkTreeModelFlags for this particular type of model @@ -749,8 +757,6 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): See Gtk.TreeModel """ #print 'do_get_col_type' - if index == self._tooltip_column: - return object return str def do_get_iter_first(self): @@ -792,15 +798,13 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): handle = self.node_map._index2hndl[iter.user_data][1] val = self.get_value_from_handle(handle, col) #print 'val is', val, type(val) - if col == self._tooltip_column: - return val + + #GTK 3 should convert unicode objects automatically, but this + # gives wrong column values, so we convert for python 2.7 + if not isinstance(val, str): + return val.encode('utf-8') else: - #GTK 3 should convert unicode objects automatically, but this - # gives wrong column values, so we convert for python 2.7 - if not isinstance(val, str): - return val.encode('utf-8') - else: - return val + return val def do_iter_previous(self, iter): #print 'do_iter_previous' diff --git a/gramps/gui/views/treemodels/mediamodel.py b/gramps/gui/views/treemodels/mediamodel.py index 500d1a8fd..ba3c00a58 100644 --- a/gramps/gui/views/treemodels/mediamodel.py +++ b/gramps/gui/views/treemodels/mediamodel.py @@ -68,9 +68,7 @@ class MediaModel(FlatBaseModel): self.column_private, self.column_tags, self.column_change, - self.column_handle, self.column_tag_color, - self.column_tooltip ] self.smap = [ @@ -82,12 +80,10 @@ class MediaModel(FlatBaseModel): self.column_private, self.column_tags, self.sort_change, - self.column_handle, self.column_tag_color, - self.column_tooltip ] - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=10, - search=search, skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -104,7 +100,7 @@ class MediaModel(FlatBaseModel): """ Return the color column. """ - return 9 + return 8 def do_get_n_columns(self): return len(self.fmap)+1 diff --git a/gramps/gui/views/treemodels/notemodel.py b/gramps/gui/views/treemodels/notemodel.py index d4379a1fb..29290537f 100644 --- a/gramps/gui/views/treemodels/notemodel.py +++ b/gramps/gui/views/treemodels/notemodel.py @@ -66,7 +66,6 @@ class NoteModel(FlatBaseModel): self.column_private, self.column_tags, self.column_change, - self.column_handle, self.column_tag_color ] self.smap = [ @@ -76,11 +75,10 @@ class NoteModel(FlatBaseModel): self.column_private, self.column_tags, self.sort_change, - self.column_handle, self.column_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, - skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -97,16 +95,12 @@ class NoteModel(FlatBaseModel): """ Return the color column. """ - return 7 + return 6 def do_get_n_columns(self): """Return the column number of the Note tab.""" return len(self.fmap) + 1 - def column_handle(self, data): - """Return the handle of the Note.""" - return data[Note.POS_HANDLE] - def column_id(self, data): """Return the id of the Note.""" return cuni(data[Note.POS_ID]) diff --git a/gramps/gui/views/treemodels/peoplemodel.py b/gramps/gui/views/treemodels/peoplemodel.py index 4ffafd90b..04d6f5c14 100644 --- a/gramps/gui/views/treemodels/peoplemodel.py +++ b/gramps/gui/views/treemodels/peoplemodel.py @@ -94,8 +94,6 @@ class PeopleBaseModel(object): """ _GENDER = [ _('female'), _('male'), _('unknown') ] - # The following is accessed from the Person Selector - COLUMN_INT_ID = 11 # dynamic calculation of column indices # LRU cache size _CACHE_SIZE = 250 @@ -119,9 +117,7 @@ class PeopleBaseModel(object): self.column_private, self.column_tags, self.column_change, - self.column_int_id, self.column_tag_color, - self.column_tooltip, ] self.smap = [ self.sort_name, @@ -135,9 +131,7 @@ class PeopleBaseModel(object): self.column_private, self.column_tags, self.sort_change, - self.column_int_id, self.column_tag_color, - self.column_tooltip, ] #columns are accessed on every mouse over, so it is worthwhile to @@ -163,7 +157,7 @@ class PeopleBaseModel(object): """ Return the color column. """ - return 12 + return 11 def clear_local_cache(self, handle=None): """ Clear the LRU cache """ @@ -440,12 +434,6 @@ class PeopleBaseModel(object): return "" + cgi.escape(place_title) + "" return "" - def column_tooltip(self, data): - return 'Person tooltip' - - def column_int_id(self, data): - return data[0] - def get_tag_name(self, tag_handle): """ Return the tag name from the given tag handle. @@ -480,9 +468,8 @@ class PersonListModel(PeopleBaseModel, FlatBaseModel): def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, skip=set(), sort_map=None): PeopleBaseModel.__init__(self, db) - FlatBaseModel.__init__(self, db, search=search, skip=skip, - tooltip_column=12, - scol=scol, order=order, sort_map=sort_map) + FlatBaseModel.__init__(self, db, search=search, skip=skip, scol=scol, + order=order, sort_map=sort_map) def clear_cache(self, handle=None): """ Clear the LRU cache """ @@ -503,8 +490,8 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel): skip=set(), sort_map=None): PeopleBaseModel.__init__(self, db) - TreeBaseModel.__init__(self, db, 12, search=search, skip=skip, - scol=scol, order=order, sort_map=sort_map) + TreeBaseModel.__init__(self, db, search=search, skip=skip, scol=scol, + order=order, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/placemodel.py b/gramps/gui/views/treemodels/placemodel.py index 922c3a814..542d02902 100644 --- a/gramps/gui/views/treemodels/placemodel.py +++ b/gramps/gui/views/treemodels/placemodel.py @@ -76,8 +76,6 @@ COUNTRYLEVELS = { #------------------------------------------------------------------------- class PlaceBaseModel(object): - HANDLE_COL = 15 - def __init__(self, db): self.gen_cursor = db.get_place_cursor self.map = db.get_raw_place_data @@ -97,8 +95,6 @@ class PlaceBaseModel(object): self.column_private, self.column_change, self.column_place_name, - self.column_handle, - self.column_tooltip ] self.smap = [ self.column_name, @@ -116,7 +112,6 @@ class PlaceBaseModel(object): self.column_private, self.sort_change, self.column_place_name, - self.column_handle, ] def destroy(self): @@ -132,9 +127,6 @@ class PlaceBaseModel(object): def do_get_n_columns(self): return len(self.fmap)+1 - def column_handle(self, data): - return cuni(data[0]) - def column_place_name(self, data): return cuni(data[2]) @@ -234,9 +226,6 @@ class PlaceBaseModel(object): def column_change(self, data): return format_time(data[11]) - def column_tooltip(self, data): - return cuni('Place tooltip') - #------------------------------------------------------------------------- # # PlaceListModel @@ -250,8 +239,8 @@ class PlaceListModel(PlaceBaseModel, FlatBaseModel): skip=set(), sort_map=None): PlaceBaseModel.__init__(self, db) - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=15, - search=search, skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -277,10 +266,9 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): PlaceBaseModel.__init__(self, db) TreeBaseModel.__init__(self, db, scol=scol, order=order, - tooltip_column=15, - search=search, skip=skip, sort_map=sort_map, - nrgroups = 3, - group_can_have_handle = True) + search=search, skip=skip, sort_map=sort_map, + nrgroups=3, + group_can_have_handle=True) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/repomodel.py b/gramps/gui/views/treemodels/repomodel.py index 078225f7a..975189711 100644 --- a/gramps/gui/views/treemodels/repomodel.py +++ b/gramps/gui/views/treemodels/repomodel.py @@ -71,8 +71,6 @@ class RepositoryModel(FlatBaseModel): self.column_search_url, self.column_private, self.column_change, - self.column_handle, - self.column_tooltip ] self.smap = [ @@ -90,11 +88,10 @@ class RepositoryModel(FlatBaseModel): self.column_search_url, self.column_private, self.sort_change, - self.column_handle, ] - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=15, - search=search, skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -111,9 +108,6 @@ class RepositoryModel(FlatBaseModel): def do_get_n_columns(self): return len(self.fmap)+1 - def column_handle(self,data): - return cuni(data[0]) - def column_id(self,data): return cuni(data[1]) @@ -220,9 +214,6 @@ class RepositoryModel(FlatBaseModel): return cuni(url.path) return "" - def column_tooltip(self,data): - return cuni('Repository tooltip') - def column_private(self, data): if data[8]: return 'gramps-lock' diff --git a/gramps/gui/views/treemodels/sourcemodel.py b/gramps/gui/views/treemodels/sourcemodel.py index af3003488..25a5ace49 100644 --- a/gramps/gui/views/treemodels/sourcemodel.py +++ b/gramps/gui/views/treemodels/sourcemodel.py @@ -50,7 +50,7 @@ from .flatbasemodel import FlatBaseModel #------------------------------------------------------------------------- class SourceModel(FlatBaseModel): - def __init__(self,db,scol=0, order=Gtk.SortType.ASCENDING,search=None, + def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, skip=set(), sort_map=None): self.map = db.get_raw_source_data self.gen_cursor = db.get_source_cursor @@ -62,8 +62,6 @@ class SourceModel(FlatBaseModel): self.column_pubinfo, self.column_private, self.column_change, - self.column_handle, - self.column_tooltip ] self.smap = [ self.column_title, @@ -74,8 +72,8 @@ class SourceModel(FlatBaseModel): self.column_private, self.sort_change, ] - FlatBaseModel.__init__(self,db,scol, order,tooltip_column=8,search=search, - skip=skip, sort_map=sort_map) + FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, + sort_map=sort_map) def destroy(self): """ @@ -94,9 +92,6 @@ class SourceModel(FlatBaseModel): def column_title(self,data): return cuni(data[2]) - def column_handle(self,data): - return cuni(data[0]) - def column_author(self,data): return cuni(data[3]) @@ -121,6 +116,3 @@ class SourceModel(FlatBaseModel): def sort_change(self,data): return "%012x" % data[8] - - def column_tooltip(self,data): - return cuni('Source tooltip') diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index 5293961b0..f710713c7 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -267,7 +267,6 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): Creation: db : the database - tooltip_column : column number of tooltip search : the search that must be shown skip : values not to show scol : column on which to sort @@ -290,7 +289,7 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): # LRU cache size _CACHE_SIZE = 250 - def __init__(self, db, tooltip_column, + def __init__(self, db, search=None, skip=set(), scol=0, order=Gtk.SortType.ASCENDING, sort_map=None, nrgroups = 1, @@ -347,8 +346,6 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): self.lru_data = LRU(TreeBaseModel._CACHE_SIZE) - self._tooltip_column = tooltip_column - self.__total = 0 self.__displayed = 0 @@ -414,12 +411,6 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): """ return self.__total - def tooltip_column(self): - """ - Return the tooltip column. - """ - return self._tooltip_column - def color_column(self): """ Return the color column. @@ -869,6 +860,23 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): """ return self.do_get_path(self.get_iter(self.get_node(handle))) + def get_iter_from_handle(self, handle): + """ + Get the iter for a gramps handle. + """ + return self.get_iter(self._get_node(handle)) + + def get_handle_from_iter(self, iter): + """ + Get the gramps handle for an iter. Return None if the iter does + not correspond to a gramps object. + """ + node = self.get_node_from_iter(iter) + handle = node.handle + if handle and not isinstance(handle, UNITYPE): + handle = handle.decode('utf-8') + return handle + # The following implement the public interface of Gtk.TreeModel def do_get_flags(self): @@ -888,8 +896,6 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): """ See Gtk.TreeModel """ - if index == self._tooltip_column: - return object return str def do_get_value(self, iter, col): diff --git a/gramps/plugins/lib/libpersonview.py b/gramps/plugins/lib/libpersonview.py index 1b6b479e5..d6db7cc30 100644 --- a/gramps/plugins/lib/libpersonview.py +++ b/gramps/plugins/lib/libpersonview.py @@ -134,7 +134,6 @@ class BasePersonView(ListView): ListView.__init__( self, title, pdata, dbstate, uistate, - len(BasePersonView.COLUMNS), model, signal_map, PersonBookmarks, nav_group, multiple=True, diff --git a/gramps/plugins/lib/libplaceview.py b/gramps/plugins/lib/libplaceview.py index b65276dc1..98bef078e 100644 --- a/gramps/plugins/lib/libplaceview.py +++ b/gramps/plugins/lib/libplaceview.py @@ -138,7 +138,6 @@ class PlaceBaseView(ListView): ListView.__init__( self, title, pdata, dbstate, uistate, - 15, model, signal_map, PlaceBookmarks, nav_group, multiple=True, diff --git a/gramps/plugins/view/citationlistview.py b/gramps/plugins/view/citationlistview.py index 315808d20..8b6e08fd8 100644 --- a/gramps/plugins/view/citationlistview.py +++ b/gramps/plugins/view/citationlistview.py @@ -140,7 +140,6 @@ class CitationListView(ListView): ListView.__init__( self, _('Citation View'), pdata, dbstate, uistate, - len(self.COLUMNS), CitationListModel, signal_map, CitationBookmarks, nav_group, multiple=True, diff --git a/gramps/plugins/view/citationtreeview.py b/gramps/plugins/view/citationtreeview.py index aa538be9c..4c861ede0 100644 --- a/gramps/plugins/view/citationtreeview.py +++ b/gramps/plugins/view/citationtreeview.py @@ -141,7 +141,6 @@ class CitationTreeView(ListView): ListView.__init__( self, _('Citation Tree View'), pdata, dbstate, uistate, - len(self.COLUMNS), CitationTreeModel, signal_map, CitationBookmarks, nav_group, multiple=True, diff --git a/gramps/plugins/view/eventview.py b/gramps/plugins/view/eventview.py index c7b902364..700d44114 100644 --- a/gramps/plugins/view/eventview.py +++ b/gramps/plugins/view/eventview.py @@ -115,7 +115,6 @@ class EventView(ListView): ListView.__init__( self, _('Events'), pdata, dbstate, uistate, - len(EventView.COLUMNS), EventModel, signal_map, EventBookmarks, nav_group, diff --git a/gramps/plugins/view/familyview.py b/gramps/plugins/view/familyview.py index 051beabf9..0801c9ff6 100644 --- a/gramps/plugins/view/familyview.py +++ b/gramps/plugins/view/familyview.py @@ -114,7 +114,6 @@ class FamilyView(ListView): ListView.__init__( self, _('Families'), pdata, dbstate, uistate, - len(FamilyView.COLUMNS), FamilyModel, signal_map, FamilyBookmarks, nav_group, diff --git a/gramps/plugins/view/mediaview.py b/gramps/plugins/view/mediaview.py index b8eb36a1e..04b696242 100644 --- a/gramps/plugins/view/mediaview.py +++ b/gramps/plugins/view/mediaview.py @@ -137,7 +137,6 @@ class MediaView(ListView): ListView.__init__( self, _('Media'), pdata, dbstate, uistate, - len(MediaView.COLUMNS), MediaModel, signal_map, MediaBookmarks, nav_group, diff --git a/gramps/plugins/view/noteview.py b/gramps/plugins/view/noteview.py index 7c3fab126..4417d87e4 100644 --- a/gramps/plugins/view/noteview.py +++ b/gramps/plugins/view/noteview.py @@ -110,7 +110,7 @@ class NoteView(ListView): ListView.__init__( self, _('Notes'), pdata, dbstate, uistate, - len(NoteView.COLUMNS), NoteModel, signal_map, + NoteModel, signal_map, NoteBookmarks, nav_group, filter_class=NoteSidebarFilter, multiple=True) diff --git a/gramps/plugins/view/repoview.py b/gramps/plugins/view/repoview.py index 0ebda2cc2..3f9f63abb 100644 --- a/gramps/plugins/view/repoview.py +++ b/gramps/plugins/view/repoview.py @@ -125,7 +125,6 @@ class RepositoryView(ListView): ListView.__init__( self, _('Repositories'), pdata, dbstate, uistate, - len(RepositoryView.COLUMNS), RepositoryModel, signal_map, RepoBookmarks, nav_group, multiple=True, diff --git a/gramps/plugins/view/sourceview.py b/gramps/plugins/view/sourceview.py index 444c71cf7..1712a3278 100644 --- a/gramps/plugins/view/sourceview.py +++ b/gramps/plugins/view/sourceview.py @@ -112,7 +112,6 @@ class SourceView(ListView): ListView.__init__( self, _('Sources'), pdata, dbstate, uistate, - len(SourceView.COLUMNS), SourceModel, signal_map, SourceBookmarks, nav_group, multiple=True,