Fixed to try to stay in the current expanded group.

This commit is contained in:
Charles Haley 2011-09-18 10:12:34 +02:00
parent 257db2ffad
commit cbc681ddca

View File

@ -1034,10 +1034,19 @@ class TagsModel(QAbstractItemModel): # {{{
def index_for_path(self, path): def index_for_path(self, path):
parent = QModelIndex() parent = QModelIndex()
for i in path: for idx,v in enumerate(path):
parent = self.index(i, 0, parent) tparent = self.index(v, 0, parent)
if not parent.isValid(): if not tparent.isValid():
return QModelIndex() if v > 0 and idx == len(path) - 1:
# Probably the last item went away. Use the one before it
tparent = self.index(v-1, 0, parent)
if not tparent.isValid():
# Not valid. Use the last valid index
break
else:
# There isn't one before it. Use the last valid index
break
parent = tparent
return parent return parent
def index(self, row, column, parent): def index(self, row, column, parent):