Fix #3276 (Tag search GUI broken)

This commit is contained in:
Kovid Goyal 2009-08-25 14:22:34 -06:00
parent ab77e05d30
commit 3e2ca84f09
2 changed files with 6 additions and 4 deletions

View File

@ -1503,6 +1503,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.search.clear_to_help() self.search.clear_to_help()
self.status_bar.reset_info() self.status_bar.reset_info()
self.library_view.sortByColumn(3, Qt.DescendingOrder) self.library_view.sortByColumn(3, Qt.DescendingOrder)
self.library_view.model().count_changed()
############################################################################ ############################################################################

View File

@ -93,7 +93,7 @@ class TagsModel(QStandardItemModel):
QIcon(':/images/minus.svg')] QIcon(':/images/minus.svg')]
QStandardItemModel.__init__(self) QStandardItemModel.__init__(self)
self.db = db self.db = db
self.ignore_next_search = False self.ignore_next_search = 0
self._data = {} self._data = {}
self.bold_font = QFont() self.bold_font = QFont()
self.bold_font.setBold(True) self.bold_font.setBold(True)
@ -129,19 +129,20 @@ class TagsModel(QStandardItemModel):
self.refresh() self.refresh()
def reinit(self, *args, **kwargs): def reinit(self, *args, **kwargs):
if not self.ignore_next_search: if self.ignore_next_search == 0:
for category in self._data.values(): for category in self._data.values():
for tag in category: for tag in category:
tag.state = 0 tag.state = 0
self.reset() self.reset()
self.ignore_next_search = False else:
self.ignore_next_search -= 1
def toggle(self, index): def toggle(self, index):
if index.parent().isValid(): if index.parent().isValid():
category = self.row_map[index.parent().row()] category = self.row_map[index.parent().row()]
tag = self._data[category][index.row()] tag = self._data[category][index.row()]
self.invisibleRootItem().child(index.parent().row()).child(index.row()).toggle() self.invisibleRootItem().child(index.parent().row()).child(index.row()).toggle()
self.ignore_next_search = True self.ignore_next_search = 2
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'), index, index) self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'), index, index)
return True return True
return False return False