diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 1f7fd2aafa..8b6774f303 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -685,8 +685,7 @@ class Boss(QObject): self.gui.preview.current_name = newname self.apply_container_update_to_gui() if from_filelist: - if from_filelist in name_map: - self.gui.file_list.select_name(name_map[from_filelist], set_as_current_index=True) + self.gui.file_list.select_names(frozenset(name_map.itervalues()), current_name=name_map.get(from_filelist)) self.gui.file_list.file_list.setFocus(Qt.PopupFocusReason) # }}} diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 5e18fbc914..dc258a5997 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -250,6 +250,16 @@ class FileList(QTreeWidget): if set_as_current_index: self.setCurrentItem(c) + def select_names(self, names, current_name=None): + for parent in self.categories.itervalues(): + for c in (parent.child(i) for i in xrange(parent.childCount())): + q = unicode(c.data(0, NAME_ROLE) or '') + c.setSelected(q in names) + if q == current_name: + self.scrollToItem(c) + s = self.selectionModel() + s.setCurrentIndex(self.indexFromItem(c), s.NoUpdate) + def mark_name_as_current(self, name): current = self.item_from_name(name) if current is not None: @@ -900,7 +910,7 @@ class FileListWidget(QWidget): self.layout().addWidget(self.file_list) self.layout().setContentsMargins(0, 0, 0, 0) self.forwarded_signals = {k for k, o in vars(self.file_list.__class__).iteritems() if isinstance(o, pyqtSignal) and '_' in k and not hasattr(self, k)} - for x in ('delete_done', 'select_name', 'request_edit', 'mark_name_as_current', 'clear_currently_edited_name'): + for x in ('delete_done', 'select_name', 'select_names', 'request_edit', 'mark_name_as_current', 'clear_currently_edited_name'): setattr(self, x, getattr(self.file_list, x)) self.setFocusProxy(self.file_list)