Remove handle and tooltip columns from models
svn: r21162
This commit is contained in:
parent
64a8895df9
commit
c56fb05d1c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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):
|
||||
|
@ -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')
|
||||
|
@ -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.
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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])
|
||||
|
@ -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 "<i>" + cgi.escape(place_title) + "</i>"
|
||||
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):
|
||||
"""
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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'
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -138,7 +138,6 @@ class PlaceBaseView(ListView):
|
||||
|
||||
ListView.__init__(
|
||||
self, title, pdata, dbstate, uistate,
|
||||
15,
|
||||
model, signal_map,
|
||||
PlaceBookmarks, nav_group,
|
||||
multiple=True,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -115,7 +115,6 @@ class EventView(ListView):
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Events'), pdata, dbstate, uistate,
|
||||
len(EventView.COLUMNS),
|
||||
EventModel,
|
||||
signal_map,
|
||||
EventBookmarks, nav_group,
|
||||
|
@ -114,7 +114,6 @@ class FamilyView(ListView):
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Families'), pdata, dbstate, uistate,
|
||||
len(FamilyView.COLUMNS),
|
||||
FamilyModel,
|
||||
signal_map,
|
||||
FamilyBookmarks, nav_group,
|
||||
|
@ -137,7 +137,6 @@ class MediaView(ListView):
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Media'), pdata, dbstate, uistate,
|
||||
len(MediaView.COLUMNS),
|
||||
MediaModel,
|
||||
signal_map,
|
||||
MediaBookmarks, nav_group,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user