diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index b04ad18c97..0910f85dac 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -340,6 +340,8 @@ class Main(MainWindow, Ui_MainWindow): self.connect(self.search, SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'), self.tags_view.model().reinit) self.connect(self.library_view.model(), SIGNAL('count_changed(int)'), self.location_view.count_changed) + self.connect(self.library_view.model(), SIGNAL('count_changed(int)'), + self.tags_view.recount) self.library_view.model().count_changed() ########################### Cover Flow ################################ self.cover_flow = None @@ -1129,6 +1131,7 @@ class Main(MainWindow, Ui_MainWindow): os.remove(f.name) except: pass + self.tags_view.recount() if self.current_view() is self.library_view: current = self.library_view.currentIndex() self.library_view.model().current_changed(current, QModelIndex()) diff --git a/src/calibre/gui2/tags.py b/src/calibre/gui2/tags.py index 167236c960..a6772a3b44 100644 --- a/src/calibre/gui2/tags.py +++ b/src/calibre/gui2/tags.py @@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en' Browsing book collection by tags. ''' from PyQt4.Qt import QAbstractItemModel, Qt, QVariant, QTreeView, QModelIndex, \ - QFont, SIGNAL, QSize, QColor, QIcon + QFont, SIGNAL, QSize, QColor, QIcon, QPoint from calibre.gui2 import config NONE = QVariant() @@ -36,6 +36,14 @@ class TagsView(QTreeView): if self._model.toggle(index): self.emit(SIGNAL('tags_marked(PyQt_PyObject, PyQt_PyObject)'), self._model.tokens(), self.match_all.isChecked()) + + def recount(self, *args): + ci = self.currentIndex() + if not ci.isValid(): + ci = self.indexAt(QPoint(10, 10)) + self.model().refresh() + if ci.isValid(): + self.scrollTo(ci, QTreeView.PositionAtTop) class TagsModel(QAbstractItemModel):