From 1982507fba406470f3ca6e08fc91ed3599db07b4 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 27 Mar 2011 12:18:00 -0400 Subject: [PATCH] Fix bug 743645: Match any/all combo reverts on restart --- src/calibre/gui2/__init__.py | 2 ++ src/calibre/gui2/tag_view.py | 7 +++++++ src/calibre/library/database2.py | 1 + 3 files changed, 10 insertions(+) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index ade4b496fe..96cb901b27 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -81,6 +81,8 @@ def _config(): help=_('Use Roman numerals for series number')) c.add_opt('sort_tags_by', default='name', help=_('Sort tags list by name, popularity, or rating')) + c.add_opt('match_tags_type', default='any', + help=_('Match tags by any or all.')) c.add_opt('cover_flow_queue_length', default=6, help=_('Number of covers to show in the cover browsing mode')) c.add_opt('LRF_conversion_defaults', default=[], diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 6b1ce2f851..20d2b80b4e 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -158,11 +158,14 @@ class TagsView(QTreeView): # {{{ self.setContextMenuPolicy(Qt.CustomContextMenu) pop = config['sort_tags_by'] self.sort_by.setCurrentIndex(self.db.CATEGORY_SORTS.index(pop)) + match_pop = config['match_tags_type'] + self.tag_match.setCurrentIndex(self.db.MATCH_TYPE.index(match_pop)) if not self.made_connections: self.clicked.connect(self.toggle) self.customContextMenuRequested.connect(self.show_context_menu) self.refresh_required.connect(self.recount, type=Qt.QueuedConnection) self.sort_by.currentIndexChanged.connect(self.sort_changed) + self.tag_match.currentIndexChanged.connect(self.match_changed) self.made_connections = True self.refresh_signal_processed = True db.add_listener(self.database_changed) @@ -179,6 +182,9 @@ class TagsView(QTreeView): # {{{ def sort_changed(self, pop): config.set('sort_tags_by', self.db.CATEGORY_SORTS[pop]) self.recount() + + def match_changed(self, pop): + config.set('match_tags_type', self.db.MATCH_TYPE[pop]) def set_search_restriction(self, s): if s: @@ -2114,6 +2120,7 @@ class TagBrowserWidget(QWidget): # {{{ parent.sort_by.setCurrentIndex(0) self._layout.addWidget(parent.sort_by) + # Must be in the same order as db2.MATCH_TYPE parent.tag_match = QComboBox(parent) for x in (_('Match any'), _('Match all')): parent.tag_match.addItem(x) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 0cae7be2f8..042899adbe 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1228,6 +1228,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): ########## data structures for get_categories CATEGORY_SORTS = ('name', 'popularity', 'rating') + MATCH_TYPE = ('any', 'all') class TCat_Tag(object):