From 40714d02c57457fef5138a2368cc8a5a4c0545fe Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Jan 2015 06:19:25 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/tag_browser/view.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 3eb3aa3373..21186b6226 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -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 == '*':