mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
tag browser visibility: changed name and added operations
This commit is contained in:
parent
467b6cb70b
commit
c757fdcd40
@ -435,10 +435,14 @@ class TagBrowserMixin(object): # {{{
|
|||||||
def drag_drop_finished(self, ids):
|
def drag_drop_finished(self, ids):
|
||||||
self.library_view.model().refresh_ids(ids)
|
self.library_view.model().refresh_ids(ids)
|
||||||
|
|
||||||
def change_tb_category_visibility(self, category, operation):
|
def tb_category_visibility(self, category, operation):
|
||||||
'''
|
'''
|
||||||
Hide or show categories in the tag browser. 'category' is the lookup key
|
Hide or show categories in the tag browser. 'category' is the lookup key.
|
||||||
to show or hide. Set operation == 'show' or 'hide' as needed.
|
Operation can be:
|
||||||
|
- 'show' to show the category in the tag browser
|
||||||
|
- 'hide' to hide the category
|
||||||
|
- 'toggle' to invert its visibility
|
||||||
|
- 'is_visible' returns 'True' if the category is currently visible, False otherwise
|
||||||
'''
|
'''
|
||||||
if category not in self.tags_view.model().categories:
|
if category not in self.tags_view.model().categories:
|
||||||
raise ValueError(_('change_tb_category_visibility: category %s does not exist') % category)
|
raise ValueError(_('change_tb_category_visibility: category %s does not exist') % category)
|
||||||
@ -447,6 +451,13 @@ class TagBrowserMixin(object): # {{{
|
|||||||
cats.add(category)
|
cats.add(category)
|
||||||
elif operation == 'show':
|
elif operation == 'show':
|
||||||
cats.discard(category)
|
cats.discard(category)
|
||||||
|
elif operation == 'toggle':
|
||||||
|
if category in cats:
|
||||||
|
cats.remove(category)
|
||||||
|
else:
|
||||||
|
cats.add(category)
|
||||||
|
elif operation == 'is_visible':
|
||||||
|
return category not in cats
|
||||||
else:
|
else:
|
||||||
raise ValueError(_('change_tb_category_visibility: invalid operation %s') % operation)
|
raise ValueError(_('change_tb_category_visibility: invalid operation %s') % operation)
|
||||||
self.library_view.model().db.new_api.set_pref('tag_browser_hidden_categories', list(cats))
|
self.library_view.model().db.new_api.set_pref('tag_browser_hidden_categories', list(cats))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user