mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #8554 (Folder Device Plugin: to have option to disable subfolder) and add search to the context menu of the Tag Browser
This commit is contained in:
commit
6ca1aa93e4
@ -22,7 +22,7 @@ class FOLDER_DEVICE_FOR_CONFIG(USBMS):
|
|||||||
PRODUCT_ID = [0xffff]
|
PRODUCT_ID = [0xffff]
|
||||||
BCD = [0xffff]
|
BCD = [0xffff]
|
||||||
DEVICE_PLUGBOARD_NAME = 'FOLDER_DEVICE'
|
DEVICE_PLUGBOARD_NAME = 'FOLDER_DEVICE'
|
||||||
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
class FOLDER_DEVICE(USBMS):
|
class FOLDER_DEVICE(USBMS):
|
||||||
type = _('Device Interface')
|
type = _('Device Interface')
|
||||||
|
@ -98,6 +98,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
self.collapse_model = 'disable'
|
self.collapse_model = 'disable'
|
||||||
else:
|
else:
|
||||||
self.collapse_model = gprefs['tags_browser_partition_method']
|
self.collapse_model = gprefs['tags_browser_partition_method']
|
||||||
|
self.search_icon = QIcon(I('search.png'))
|
||||||
|
|
||||||
def set_pane_is_visible(self, to_what):
|
def set_pane_is_visible(self, to_what):
|
||||||
pv = self.pane_is_visible
|
pv = self.pane_is_visible
|
||||||
@ -199,6 +200,10 @@ class TagsView(QTreeView): # {{{
|
|||||||
if action == 'manage_categories':
|
if action == 'manage_categories':
|
||||||
self.user_category_edit.emit(category)
|
self.user_category_edit.emit(category)
|
||||||
return
|
return
|
||||||
|
if action == 'search':
|
||||||
|
self.tags_marked.emit(('not ' if negate else '') +
|
||||||
|
category + ':"=' + key + '"')
|
||||||
|
return
|
||||||
if action == 'search_category':
|
if action == 'search_category':
|
||||||
self.tags_marked.emit(category + ':' + str(not negate))
|
self.tags_marked.emit(category + ':' + str(not negate))
|
||||||
return
|
return
|
||||||
@ -208,6 +213,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
if action == 'edit_author_sort':
|
if action == 'edit_author_sort':
|
||||||
self.author_sort_edit.emit(self, index)
|
self.author_sort_edit.emit(self, index)
|
||||||
return
|
return
|
||||||
|
|
||||||
if action == 'hide':
|
if action == 'hide':
|
||||||
self.hidden_categories.add(category)
|
self.hidden_categories.add(category)
|
||||||
elif action == 'show':
|
elif action == 'show':
|
||||||
@ -248,19 +254,36 @@ class TagsView(QTreeView): # {{{
|
|||||||
if key not in self.db.field_metadata:
|
if key not in self.db.field_metadata:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# If the user right-clicked on an editable item, then offer
|
# Did the user click on a leaf node?
|
||||||
# the possibility of renaming that item
|
if tag_name:
|
||||||
if tag_name and \
|
# If the user right-clicked on an editable item, then offer
|
||||||
(key in ['authors', 'tags', 'series', 'publisher', 'search'] or \
|
# the possibility of renaming that item.
|
||||||
self.db.field_metadata[key]['is_custom'] and \
|
if key in ['authors', 'tags', 'series', 'publisher', 'search'] or \
|
||||||
self.db.field_metadata[key]['datatype'] != 'rating'):
|
(self.db.field_metadata[key]['is_custom'] and \
|
||||||
self.context_menu.addAction(_('Rename \'%s\'')%tag_name,
|
self.db.field_metadata[key]['datatype'] != 'rating'):
|
||||||
partial(self.context_menu_handler, action='edit_item',
|
# Add the 'rename' items
|
||||||
category=tag_item, index=index))
|
self.context_menu.addAction(_('Rename %s')%tag_name,
|
||||||
if key == 'authors':
|
partial(self.context_menu_handler, action='edit_item',
|
||||||
self.context_menu.addAction(_('Edit sort for \'%s\'')%tag_name,
|
category=tag_item, index=index))
|
||||||
partial(self.context_menu_handler,
|
if key == 'authors':
|
||||||
action='edit_author_sort', index=tag_id))
|
self.context_menu.addAction(_('Edit sort for %s')%tag_name,
|
||||||
|
partial(self.context_menu_handler,
|
||||||
|
action='edit_author_sort', index=tag_id))
|
||||||
|
# Add the search for value items
|
||||||
|
n = tag_name
|
||||||
|
c = category
|
||||||
|
if self.db.field_metadata[key]['datatype'] == 'rating':
|
||||||
|
n = str(len(tag_name))
|
||||||
|
elif self.db.field_metadata[key]['kind'] in ['user', 'search']:
|
||||||
|
c = tag_item.tag.category
|
||||||
|
self.context_menu.addAction(self.search_icon,
|
||||||
|
_('Search for %s')%tag_name,
|
||||||
|
partial(self.context_menu_handler, action='search',
|
||||||
|
category=c, key=n, negate=False))
|
||||||
|
self.context_menu.addAction(self.search_icon,
|
||||||
|
_('Search for everything but %s')%tag_name,
|
||||||
|
partial(self.context_menu_handler, action='search',
|
||||||
|
category=c, key=n, negate=True))
|
||||||
self.context_menu.addSeparator()
|
self.context_menu.addSeparator()
|
||||||
# Hide/Show/Restore categories
|
# Hide/Show/Restore categories
|
||||||
self.context_menu.addAction(_('Hide category %s') % category,
|
self.context_menu.addAction(_('Hide category %s') % category,
|
||||||
@ -272,14 +295,15 @@ class TagsView(QTreeView): # {{{
|
|||||||
partial(self.context_menu_handler, action='show', category=col))
|
partial(self.context_menu_handler, action='show', category=col))
|
||||||
|
|
||||||
# search by category
|
# search by category
|
||||||
self.context_menu.addAction(
|
if key != 'search':
|
||||||
_('Search for books in category %s')%category,
|
self.context_menu.addAction(self.search_icon,
|
||||||
partial(self.context_menu_handler, action='search_category',
|
_('Search for books in category %s')%category,
|
||||||
category=key, negate=False))
|
partial(self.context_menu_handler, action='search_category',
|
||||||
self.context_menu.addAction(
|
category=key, negate=False))
|
||||||
_('Search for books not in category %s')%category,
|
self.context_menu.addAction(self.search_icon,
|
||||||
partial(self.context_menu_handler, action='search_category',
|
_('Search for books not in category %s')%category,
|
||||||
category=key, negate=True))
|
partial(self.context_menu_handler, action='search_category',
|
||||||
|
category=key, negate=True))
|
||||||
# Offer specific editors for tags/series/publishers/saved searches
|
# Offer specific editors for tags/series/publishers/saved searches
|
||||||
self.context_menu.addSeparator()
|
self.context_menu.addSeparator()
|
||||||
if key in ['tags', 'publisher', 'series'] or \
|
if key in ['tags', 'publisher', 'series'] or \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user