mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fixed to try to stay in the current expanded group.
This commit is contained in:
parent
257db2ffad
commit
cbc681ddca
@ -1034,10 +1034,19 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
|
||||
def index_for_path(self, path):
|
||||
parent = QModelIndex()
|
||||
for i in path:
|
||||
parent = self.index(i, 0, parent)
|
||||
if not parent.isValid():
|
||||
return QModelIndex()
|
||||
for idx,v in enumerate(path):
|
||||
tparent = self.index(v, 0, parent)
|
||||
if not tparent.isValid():
|
||||
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
|
||||
|
||||
def index(self, row, column, parent):
|
||||
|
Loading…
x
Reference in New Issue
Block a user