6665: New errors when using pygobject 3.8: Cannot get n_columns on flatbasemodel
svn: r22244
This commit is contained in:
parent
83ebd2658b
commit
3d23affc8a
@ -105,5 +105,5 @@ class CitationListModel(CitationBaseModel, FlatBaseModel):
|
|||||||
self.smap = None
|
self.smap = None
|
||||||
FlatBaseModel.destroy(self)
|
FlatBaseModel.destroy(self)
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
@ -177,7 +177,7 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
|||||||
if self._get_node(data[5]):
|
if self._get_node(data[5]):
|
||||||
self.add_node(data[5], handle, sort_key, handle, secondary=True)
|
self.add_node(data[5], handle, sort_key, handle, secondary=True)
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_header(self, node):
|
def column_header(self, node):
|
||||||
|
@ -110,7 +110,7 @@ class EventModel(FlatBaseModel):
|
|||||||
self.smap = None
|
self.smap = None
|
||||||
FlatBaseModel.destroy(self)
|
FlatBaseModel.destroy(self)
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_description(self,data):
|
def column_description(self,data):
|
||||||
|
@ -104,7 +104,7 @@ class FamilyModel(FlatBaseModel):
|
|||||||
"""
|
"""
|
||||||
return 8
|
return 8
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_father(self, data):
|
def column_father(self, data):
|
||||||
|
@ -277,6 +277,8 @@ class FlatNodeMap(object):
|
|||||||
iter = Gtk.TreeIter()
|
iter = Gtk.TreeIter()
|
||||||
iter.stamp = self.stamp
|
iter.stamp = self.stamp
|
||||||
##GTK3: user data may only be an integer, we store the index
|
##GTK3: user data may only be an integer, we store the index
|
||||||
|
##PROBLEM: pygobject 3.8 seems to store 0 as None, we need to correct
|
||||||
|
## when using user_data for that!
|
||||||
iter.user_data = self._hndl2index[handle]
|
iter.user_data = self._hndl2index[handle]
|
||||||
return iter
|
return iter
|
||||||
|
|
||||||
@ -327,8 +329,8 @@ class FlatNodeMap(object):
|
|||||||
"""
|
"""
|
||||||
index = iter.user_data
|
index = iter.user_data
|
||||||
if index is None:
|
if index is None:
|
||||||
#Nothing on this level
|
#problem in pygobject 3.8, passing 0 stores None
|
||||||
return False
|
index = 0
|
||||||
|
|
||||||
if self._reverse :
|
if self._reverse :
|
||||||
index -= 1
|
index -= 1
|
||||||
@ -452,7 +454,7 @@ class FlatNodeMap(object):
|
|||||||
# FlatBaseModel
|
# FlatBaseModel
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
class FlatBaseModel(GObject.GObject, Gtk.TreeModel):
|
||||||
"""
|
"""
|
||||||
The base class for all flat treeview models.
|
The base class for all flat treeview models.
|
||||||
It keeps a FlatNodeMap, and obtains data from database as needed
|
It keeps a FlatNodeMap, and obtains data from database as needed
|
||||||
@ -464,7 +466,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
search=None, skip=set(),
|
search=None, skip=set(),
|
||||||
sort_map=None):
|
sort_map=None):
|
||||||
cput = time.clock()
|
cput = time.clock()
|
||||||
GObject.GObject.__init__(self)
|
super(FlatBaseModel, self).__init__()
|
||||||
#inheriting classes must set self.map to obtain the data
|
#inheriting classes must set self.map to obtain the data
|
||||||
self.prev_handle = None
|
self.prev_handle = None
|
||||||
self.prev_data = None
|
self.prev_data = None
|
||||||
@ -713,7 +715,11 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
"""
|
"""
|
||||||
Get the gramps handle for an iter.
|
Get the gramps handle for an iter.
|
||||||
"""
|
"""
|
||||||
index = self.node_map.real_index(iter.user_data)
|
ud = iter.user_data
|
||||||
|
if ud is None:
|
||||||
|
#problem in pygobject 3.8, passing 0 stores None
|
||||||
|
ud = 0
|
||||||
|
index = self.node_map.real_index(ud)
|
||||||
return self.node_map.get_handle(index)
|
return self.node_map.get_handle(index)
|
||||||
|
|
||||||
# The following implement the public interface of Gtk.TreeModel
|
# The following implement the public interface of Gtk.TreeModel
|
||||||
@ -727,9 +733,13 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
return Gtk.TreeModelFlags.LIST_ONLY #| Gtk.TreeModelFlags.ITERS_PERSIST
|
return Gtk.TreeModelFlags.LIST_ONLY #| Gtk.TreeModelFlags.ITERS_PERSIST
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def do_get_n_columns(self):
|
||||||
|
"""Internal method. Don't inherit"""
|
||||||
|
return self.on_get_n_columns()
|
||||||
|
|
||||||
|
def on_get_n_columns(self):
|
||||||
"""
|
"""
|
||||||
Return the number of columns. Must be implemented in the child objects
|
Return the number of columns. Must be implemented in the child objects
|
||||||
See Gtk.TreeModel
|
See Gtk.TreeModel. Inherit as needed
|
||||||
"""
|
"""
|
||||||
#print 'do_get_n_col'
|
#print 'do_get_n_col'
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -785,8 +795,12 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
See Gtk.TreeModel.
|
See Gtk.TreeModel.
|
||||||
col is the model column that is needed, not the visible column!
|
col is the model column that is needed, not the visible column!
|
||||||
"""
|
"""
|
||||||
#print 'do_get_val', iter, iter.user_data, col
|
#print ('do_get_val', iter, iter.user_data, col)
|
||||||
handle = self.node_map._index2hndl[iter.user_data][1]
|
ud = iter.user_data
|
||||||
|
if ud is None:
|
||||||
|
#problem in pygobject 3.8, passing 0 stores None
|
||||||
|
ud = 0
|
||||||
|
handle = self.node_map._index2hndl[ud][1]
|
||||||
val = self._get_value(handle, col)
|
val = self._get_value(handle, col)
|
||||||
#print 'val is', val, type(val)
|
#print 'val is', val, type(val)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class MediaModel(FlatBaseModel):
|
|||||||
"""
|
"""
|
||||||
return 8
|
return 8
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_description(self, data):
|
def column_description(self, data):
|
||||||
|
@ -97,7 +97,7 @@ class NoteModel(FlatBaseModel):
|
|||||||
"""
|
"""
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
"""Return the column number of the Note tab."""
|
"""Return the column number of the Note tab."""
|
||||||
return len(self.fmap) + 1
|
return len(self.fmap) + 1
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class PeopleBaseModel(object):
|
|||||||
self.lru_bdate.clear()
|
self.lru_bdate.clear()
|
||||||
self.lru_ddate.clear()
|
self.lru_ddate.clear()
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
""" Return the number of columns in the model """
|
""" Return the number of columns in the model """
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class PlaceBaseModel(object):
|
|||||||
self.fmap = None
|
self.fmap = None
|
||||||
self.smap = None
|
self.smap = None
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_place_name(self, data):
|
def column_place_name(self, data):
|
||||||
|
@ -105,7 +105,7 @@ class RepositoryModel(FlatBaseModel):
|
|||||||
self.smap = None
|
self.smap = None
|
||||||
FlatBaseModel.destroy(self)
|
FlatBaseModel.destroy(self)
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_id(self,data):
|
def column_id(self,data):
|
||||||
|
@ -87,7 +87,7 @@ class SourceModel(FlatBaseModel):
|
|||||||
self.smap = None
|
self.smap = None
|
||||||
FlatBaseModel.destroy(self)
|
FlatBaseModel.destroy(self)
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def on_get_n_columns(self):
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
def column_title(self,data):
|
def column_title(self,data):
|
||||||
|
@ -235,7 +235,7 @@ class NodeMap(object):
|
|||||||
# TreeBaseModel
|
# TreeBaseModel
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class TreeBaseModel(GObject.Object, Gtk.TreeModel):
|
class TreeBaseModel(GObject.GObject, Gtk.TreeModel):
|
||||||
"""
|
"""
|
||||||
The base class for all hierarchical treeview models. The model defines the
|
The base class for all hierarchical treeview models. The model defines the
|
||||||
mapping between a unique node and a path. Paths are defined by a tuple.
|
mapping between a unique node and a path. Paths are defined by a tuple.
|
||||||
@ -288,7 +288,7 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
group_can_have_handle = False,
|
group_can_have_handle = False,
|
||||||
has_secondary=False):
|
has_secondary=False):
|
||||||
cput = time.clock()
|
cput = time.clock()
|
||||||
GObject.GObject.__init__(self)
|
super(TreeBaseModel, self).__init__()
|
||||||
#We create a stamp to recognize invalid iterators. From the docs:
|
#We create a stamp to recognize invalid iterators. From the docs:
|
||||||
#Set the stamp to be equal to your model's stamp, to mark the
|
#Set the stamp to be equal to your model's stamp, to mark the
|
||||||
#iterator as valid. When your model's structure changes, you should
|
#iterator as valid. When your model's structure changes, you should
|
||||||
@ -867,6 +867,10 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
return 0 #Gtk.TreeModelFlags.ITERS_PERSIST
|
return 0 #Gtk.TreeModelFlags.ITERS_PERSIST
|
||||||
|
|
||||||
def do_get_n_columns(self):
|
def do_get_n_columns(self):
|
||||||
|
"""Internal method. Don't inherit"""
|
||||||
|
return self.on_get_n_columns()
|
||||||
|
|
||||||
|
def on_get_n_columns(self):
|
||||||
"""
|
"""
|
||||||
Return the number of columns. Must be implemented in the child objects
|
Return the number of columns. Must be implemented in the child objects
|
||||||
See Gtk.TreeModel
|
See Gtk.TreeModel
|
||||||
|
Loading…
Reference in New Issue
Block a user