diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py index 13172b73c7..5e27c37364 100644 --- a/src/calibre/gui2/dialogs/tag_categories.py +++ b/src/calibre/gui2/dialogs/tag_categories.py @@ -284,11 +284,19 @@ class TagCategories(QDialog, Ui_TagCategories): 'or after periods.')).exec() return False for c in sorted(self.user_categories.keys(), key=primary_sort_key): - if strcmp(c, cat_name) == 0 or \ - (icu_lower(cat_name).startswith(icu_lower(c) + '.') and - not cat_name.startswith(c + '.')): + if strcmp(c, cat_name) == 0: error_dialog(self, _('Name already used'), - _('That name is already used, perhaps with different case.')).exec() + _('The user category name is already used, perhaps with different case.'), + det_msg=_('Existing category: {existing}\nNew category: {new}').format(existing=c, new=cat_name), + show=True) + return False + if icu_lower(cat_name).startswith(icu_lower(c) + '.') and not cat_name.startswith(c + '.'): + error_dialog(self, _('Name already used'), + _('The hierarchical prefix of the new category is already used, ' + 'perhaps with different case.'), + det_msg=_('Existing prefix: {prefix}\n' + 'New category: {new}').format(prefix=c, new=cat_name), + show=True) return False if cat_name not in self.user_categories: self.user_categories[cat_name] = set() @@ -316,7 +324,10 @@ class TagCategories(QDialog, Ui_TagCategories): for c in self.user_categories: if strcmp(c, cat_name) == 0: error_dialog(self, _('Name already used'), - _('That name is already used, perhaps with different case.')).exec() + _('The user category name is already used, perhaps with different case.'), + det_msg=_('Existing category: {existing}\n' + 'New category: {new}').format(existing=c, new=cat_name), + show=True) return # The order below is important because of signals self.user_categories[cat_name] = self.user_categories[self.current_cat_name] diff --git a/src/calibre/gui2/dialogs/tag_list_editor.py b/src/calibre/gui2/dialogs/tag_list_editor.py index 0c78e25cab..e5d2fb5a17 100644 --- a/src/calibre/gui2/dialogs/tag_list_editor.py +++ b/src/calibre/gui2/dialogs/tag_list_editor.py @@ -647,16 +647,11 @@ class TagListEditor(QDialog, Ui_TagListEditor): self.table.blockSignals(False) def selection_changed(self): - col0 = tuple(item for item in self.table.selectedItems() if item.column() == 0) - col3 = tuple(item for item in self.table.selectedItems() if item.column() == 3) - if col0 and col3: - error_dialog(self, _('Cannot select in multiple columns'), - '

'+_('Selection of items in multiple columns is not supported. ' - 'The selection will be cleared')+'
', - show=True) - sm = self.table.selectionModel() + if self.table.currentIndex().isValid(): + col = self.table.currentIndex().column() self.table.blockSignals(True) - sm.clear() + for itm in (item for item in self.table.selectedItems() if item.column() != col): + itm.setSelected(False) self.table.blockSignals(False) def check_for_deleted_items(self, show_error=False): diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 7e21e755f3..dad222f99a 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -722,7 +722,16 @@ class TagsView(QTreeView): # {{{ added_show_hidden_categories = True m = self.context_menu.addMenu(_('Show category')) m.setIcon(QIcon.ic('plus.png')) - for col in sorted(self.hidden_categories, + # The search category can disappear from field_metadata. Perhaps + # other dynamic categories can as well. The implication is that + # dynamic categories are being removed, but how that would + # happen is a mystery. I suspect a plugin is operating on the + # "real" field_metadata instead of a copy, thereby changing the + # dict used by the rest of calibre. + # + # As it can happen, to avoid key errors check that a category + # exists before offering to unhide it. + for col in sorted((c for c in self.hidden_categories if c in self.db.field_metadata), key=lambda x: sort_key(self.db.field_metadata[x]['name'])): ac = m.addAction(self.db.field_metadata[col]['name'], partial(self.context_menu_handler, action='show', category=col))