Tag Browser: Allow user to restore hidden categories by a right click even is all categories have been hidden

This commit is contained in:
Kovid Goyal 2010-11-25 11:30:08 -07:00
parent 344b72e74b
commit be1bd730e2

View File

@ -174,15 +174,18 @@ class TagsView(QTreeView): # {{{
def show_context_menu(self, point):
index = self.indexAt(point)
if not index.isValid():
return False
self.context_menu = QMenu(self)
if index.isValid():
item = index.internalPointer()
tag_name = ''
if item.type == TagTreeItem.TAG:
tag_item = item
tag_name = item.tag.name
tag_id = item.tag.id
item = item.parent
if item.type == TagTreeItem.CATEGORY:
category = unicode(item.name.toString())
key = item.category_key
@ -190,7 +193,6 @@ class TagsView(QTreeView): # {{{
if key not in self.db.field_metadata:
return True
self.context_menu = QMenu(self)
# If the user right-clicked on an editable item, then offer
# the possibility of renaming that item
if tag_name and \
@ -213,8 +215,6 @@ class TagsView(QTreeView): # {{{
for col in sorted(self.hidden_categories, cmp=lambda x,y: cmp(x.lower(), y.lower())):
m.addAction(col,
partial(self.context_menu_handler, action='show', category=col))
self.context_menu.addAction(_('Show all categories'),
partial(self.context_menu_handler, action='defaults'))
# Offer specific editors for tags/series/publishers/saved searches
self.context_menu.addSeparator()
@ -242,6 +242,13 @@ class TagsView(QTreeView): # {{{
partial(self.context_menu_handler, action='manage_categories',
category=None))
if self.hidden_categories:
if not self.context_menu.isEmpty():
self.context_menu.addSeparator()
self.context_menu.addAction(_('Show all categories'),
partial(self.context_menu_handler, action='defaults'))
if not self.context_menu.isEmpty():
self.context_menu.popup(self.mapToGlobal(point))
return True