Remove needless use of handles in FlatBaseModel.do_iter_next

This commit is contained in:
Bastien Jacquet 2014-11-13 05:58:13 +01:00
parent 48eb2842ee
commit d4a99d8488

View File

@ -317,19 +317,15 @@ class FlatNodeMap(object):
if not isinstance(handle, UNITYPE): if not isinstance(handle, UNITYPE):
handle = handle.decode('utf-8') handle = handle.decode('utf-8')
return handle return handle
def find_next_handle(self, iter): def iter_next(self, iter):
""" """
Finds the next handle based off the passed handle. This is accomplished Increments the iter y finding the index associated with the iter,
by finding the index associated with the iter, adding or substracting adding or substracting one.
one to find the next index, then finding the handle associated with
that.
False is returned if no next handle False is returned if no next handle
True, handle tuple otherwise
:param handle: the key of the object for which the next handle shown :param iter: Gtk.TreeModel iterator
in the treeview is needed :param type: Gtk.TreeIter
:param type: an object handle
""" """
index = iter.user_data index = iter.user_data
if index is None: if index is None:
@ -346,11 +342,10 @@ class FlatNodeMap(object):
return False return False
else: else:
index += 1 index += 1
if index >= len(self._index2hndl):
try: return False
return True, self._index2hndl[index][1] iter.user_data = index
except IndexError: return True
return False
def get_first_iter(self): def get_first_iter(self):
""" """
@ -795,14 +790,14 @@ class FlatBaseModel(GObject.GObject, 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)
ud = iter.user_data index = iter.user_data
if ud is None: if index is None:
##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 stores 0 as None, we need to correct ##PROBLEM: pygobject 3.8 stores 0 as None, we need to correct
## when using user_data for that! ## when using user_data for that!
##upstream bug: https://bugzilla.gnome.org/show_bug.cgi?id=698366 ##upstream bug: https://bugzilla.gnome.org/show_bug.cgi?id=698366
ud = 0 index = 0
handle = self.node_map._index2hndl[ud][1] handle = self.node_map._index2hndl[index][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)
@ -822,13 +817,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel):
Sets iter to the next node at this level of the tree Sets iter to the next node at this level of the tree
See Gtk.TreeModel See Gtk.TreeModel
""" """
#print 'do_iter_next', iter, iter.user_data return self.node_map.iter_next(iter)
handle = self.node_map.find_next_handle(iter)
if handle:
iter.user_data = self.node_map._hndl2index[handle[1]]
return True
else:
return False
def do_iter_children(self, iterparent): def do_iter_children(self, iterparent):
""" """