diff --git a/src/calibre/devices/folder_device/driver.py b/src/calibre/devices/folder_device/driver.py index b852715b97..d75697a6cb 100644 --- a/src/calibre/devices/folder_device/driver.py +++ b/src/calibre/devices/folder_device/driver.py @@ -22,7 +22,7 @@ class FOLDER_DEVICE_FOR_CONFIG(USBMS): PRODUCT_ID = [0xffff] BCD = [0xffff] DEVICE_PLUGBOARD_NAME = 'FOLDER_DEVICE' - + SUPPORTS_SUB_DIRS = True class FOLDER_DEVICE(USBMS): type = _('Device Interface') diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 8b574948ff..5a57395530 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -98,6 +98,7 @@ class TagsView(QTreeView): # {{{ self.collapse_model = 'disable' else: self.collapse_model = gprefs['tags_browser_partition_method'] + self.search_icon = QIcon(I('search.png')) def set_pane_is_visible(self, to_what): pv = self.pane_is_visible @@ -199,6 +200,10 @@ class TagsView(QTreeView): # {{{ if action == 'manage_categories': self.user_category_edit.emit(category) return + if action == 'search': + self.tags_marked.emit(('not ' if negate else '') + + category + ':"=' + key + '"') + return if action == 'search_category': self.tags_marked.emit(category + ':' + str(not negate)) return @@ -208,6 +213,7 @@ class TagsView(QTreeView): # {{{ if action == 'edit_author_sort': self.author_sort_edit.emit(self, index) return + if action == 'hide': self.hidden_categories.add(category) elif action == 'show': @@ -248,19 +254,36 @@ class TagsView(QTreeView): # {{{ if key not in self.db.field_metadata: return True - # If the user right-clicked on an editable item, then offer - # the possibility of renaming that item - if tag_name and \ - (key in ['authors', 'tags', 'series', 'publisher', 'search'] or \ - self.db.field_metadata[key]['is_custom'] and \ - self.db.field_metadata[key]['datatype'] != 'rating'): - self.context_menu.addAction(_('Rename \'%s\'')%tag_name, - partial(self.context_menu_handler, action='edit_item', - category=tag_item, index=index)) - if key == 'authors': - self.context_menu.addAction(_('Edit sort for \'%s\'')%tag_name, - partial(self.context_menu_handler, - action='edit_author_sort', index=tag_id)) + # Did the user click on a leaf node? + if tag_name: + # If the user right-clicked on an editable item, then offer + # the possibility of renaming that item. + if key in ['authors', 'tags', 'series', 'publisher', 'search'] or \ + (self.db.field_metadata[key]['is_custom'] and \ + self.db.field_metadata[key]['datatype'] != 'rating'): + # Add the 'rename' items + self.context_menu.addAction(_('Rename %s')%tag_name, + partial(self.context_menu_handler, action='edit_item', + category=tag_item, index=index)) + if key == 'authors': + 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() # Hide/Show/Restore categories self.context_menu.addAction(_('Hide category %s') % category, @@ -272,14 +295,15 @@ class TagsView(QTreeView): # {{{ partial(self.context_menu_handler, action='show', category=col)) # search by category - self.context_menu.addAction( - _('Search for books in category %s')%category, - partial(self.context_menu_handler, action='search_category', - category=key, negate=False)) - self.context_menu.addAction( - _('Search for books not in category %s')%category, - partial(self.context_menu_handler, action='search_category', - category=key, negate=True)) + if key != 'search': + self.context_menu.addAction(self.search_icon, + _('Search for books in category %s')%category, + partial(self.context_menu_handler, action='search_category', + category=key, negate=False)) + self.context_menu.addAction(self.search_icon, + _('Search for books not in category %s')%category, + partial(self.context_menu_handler, action='search_category', + category=key, negate=True)) # Offer specific editors for tags/series/publishers/saved searches self.context_menu.addSeparator() if key in ['tags', 'publisher', 'series'] or \