mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix three problems
1) user-defined tag categories broke when the custom column behind an item was removed 2) get_categories was called with an incorrect search restriction string. The 'search:' was missing. 3) changing from a restriction that matched nothing to one that matched some books incorrectly rebuilt the tags list (order of signals problem)
This commit is contained in:
parent
af1bb6b8bd
commit
4b6a1b9f9f
@ -71,12 +71,16 @@ class TagCategories(QDialog, Ui_TagCategories):
|
|||||||
for item,l in enumerate(self.categories[cat]):
|
for item,l in enumerate(self.categories[cat]):
|
||||||
key = ':'.join([l[1], l[0]])
|
key = ':'.join([l[1], l[0]])
|
||||||
t = self.all_items_dict.get(key, None)
|
t = self.all_items_dict.get(key, None)
|
||||||
|
if l[1] in self.category_labels:
|
||||||
if t is None:
|
if t is None:
|
||||||
t = Item(name=l[0], label=l[1], index=len(self.all_items),
|
t = Item(name=l[0], label=l[1], index=len(self.all_items),
|
||||||
icon=category_icons[self.category_labels.index(l[1])], exists=False)
|
icon=category_icons[self.category_labels.index(l[1])], exists=False)
|
||||||
self.all_items.append(t)
|
self.all_items.append(t)
|
||||||
self.all_items_dict[key] = t
|
self.all_items_dict[key] = t
|
||||||
l[2] = t.index
|
l[2] = t.index
|
||||||
|
else:
|
||||||
|
# remove any references to a category that no longer exists
|
||||||
|
del self.categories[cat][item]
|
||||||
|
|
||||||
self.all_items_sorted = sorted(self.all_items, cmp=lambda x,y: cmp(x.name.lower(), y.name.lower()))
|
self.all_items_sorted = sorted(self.all_items, cmp=lambda x,y: cmp(x.name.lower(), y.name.lower()))
|
||||||
self.display_filtered_categories(0)
|
self.display_filtered_categories(0)
|
||||||
|
@ -1077,7 +1077,7 @@ class BooksView(TableView):
|
|||||||
|
|
||||||
def connect_to_restriction_set(self, tv):
|
def connect_to_restriction_set(self, tv):
|
||||||
QObject.connect(tv, SIGNAL('restriction_set(PyQt_PyObject)'),
|
QObject.connect(tv, SIGNAL('restriction_set(PyQt_PyObject)'),
|
||||||
self._model.set_search_restriction)
|
self._model.set_search_restriction) # must be synchronous (not queued)
|
||||||
|
|
||||||
def connect_to_book_display(self, bd):
|
def connect_to_book_display(self, bd):
|
||||||
QObject.connect(self._model, SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
QObject.connect(self._model, SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
||||||
|
@ -64,10 +64,10 @@ class TagsView(QTreeView):
|
|||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
self.search_restriction = ''
|
self.search_restriction = ''
|
||||||
else:
|
else:
|
||||||
self.search_restriction = unicode(s)
|
self.search_restriction = 'search:"%s"' % unicode(s).strip()
|
||||||
self.model().set_search_restriction(self.search_restriction)
|
self.model().set_search_restriction(self.search_restriction)
|
||||||
self.recount()
|
|
||||||
self.emit(SIGNAL('restriction_set(PyQt_PyObject)'), self.search_restriction)
|
self.emit(SIGNAL('restriction_set(PyQt_PyObject)'), self.search_restriction)
|
||||||
|
self.recount() # Must happen after the emission of the restriction_set signal
|
||||||
self.emit(SIGNAL('tags_marked(PyQt_PyObject, PyQt_PyObject)'),
|
self.emit(SIGNAL('tags_marked(PyQt_PyObject, PyQt_PyObject)'),
|
||||||
self._model.tokens(), self.match_all)
|
self._model.tokens(), self.match_all)
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ class TagsModel(QAbstractItemModel):
|
|||||||
for c in self.user_categories:
|
for c in self.user_categories:
|
||||||
l = []
|
l = []
|
||||||
for (name,label,ign) in self.user_categories[c]:
|
for (name,label,ign) in self.user_categories[c]:
|
||||||
if name in taglist[label]: # use same node as the complete category
|
if label in taglist and name in taglist[label]: # use same node as the complete category
|
||||||
l.append(taglist[label][name])
|
l.append(taglist[label][name])
|
||||||
# else: do nothing, to eliminate nodes that have zero counts
|
# else: do nothing, to eliminate nodes that have zero counts
|
||||||
if config['sort_by_popularity']:
|
if config['sort_by_popularity']:
|
||||||
|
@ -543,4 +543,4 @@ class ResultCache(SearchQueryParser):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def set_search_restriction(self, s):
|
def set_search_restriction(self, s):
|
||||||
self.search_restriction = '' if not s else 'search:"%s"' % (s.strip())
|
self.search_restriction = s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user