Tag browser: Allow expanding all children of a node by right clicking and choosing Expand All. Fixes #1414315 [[Enhancement] Auto Expanding All Categories/Subcat Option](https://bugs.launchpad.net/calibre/+bug/1414315)

This commit is contained in:
Kovid Goyal 2015-01-25 06:19:25 +05:30
parent f0ca2c0cc3
commit 40714d02c5

View File

@ -616,10 +616,21 @@ class TagsView(QTreeView): # {{{
da.setToolTip('*')
pa.setToolTip('*')
if index.isValid() and self.model().rowCount(index) > 0:
self.context_menu.addSeparator()
self.context_menu.addAction(_('E&xpand all children'), partial(self.expand_node_and_descendants, index))
if not self.context_menu.isEmpty():
self.context_menu.popup(self.mapToGlobal(point))
return True
def expand_node_and_descendants(self, index):
if not index.isValid():
return
self.expand(index)
for r in xrange(self.model().rowCount(index)):
self.expand_node_and_descendants(index.child(r, 0))
def collapse_menu_hovered(self, action):
tip = action.toolTip()
if tip == '*':