' + - self.search_restriction_tooltip + - _(' or the search ') + "'" + search + "'
") - self._apply_search_restriction(search) + self._apply_search_restriction(search, s) def apply_search_restriction(self, i): if i == 1: @@ -66,18 +335,20 @@ class SearchRestrictionMixin(object): restriction = 'search:"%s"'%(r) else: restriction = '' - self._apply_search_restriction(restriction) + self._apply_search_restriction(restriction, r) - def _apply_search_restriction(self, restriction): + def _apply_search_restriction(self, restriction, name): self.saved_search.clear() # The order below is important. Set the restriction, force a '' search # to apply it, reset the tag browser to take it into account, then set # the book count. self.library_view.model().db.data.set_search_restriction(restriction) + self.library_view.model().db.data.set_search_restriction_name(name) self.search.clear(emit_search=True) - self.tags_view.set_search_restriction(restriction) + self.tags_view.recount() self.set_number_of_books_shown() self.current_view().setFocus(Qt.OtherFocusReason) + self.set_window_title() def set_number_of_books_shown(self): db = self.library_view.model().db diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index 742f2b2776..d6d40ca4f7 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -264,13 +264,8 @@ class TagsModel(QAbstractItemModel): # {{{ if rebuild: self.rebuild_node_tree(state_map) - def set_search_restriction(self, s): - self.search_restriction = s - self.rebuild_node_tree() - def set_database(self, db): self.beginResetModel() - self.search_restriction = None hidden_cats = db.prefs.get('tag_browser_hidden_categories', None) # migrate from config to db prefs if hidden_cats is None: @@ -848,7 +843,7 @@ class TagsModel(QAbstractItemModel): # {{{ self.categories = {} # Get the categories - if self.search_restriction: + if self.db.data.get_base_restriction or self.db.data.get_search_restriction: try: data = self.db.get_categories(sort=sort, icon_map=self.category_icon_map, diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 7070eaaa04..cefa0f8975 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -232,10 +232,6 @@ class TagsView(QTreeView): # {{{ except: pass - def set_search_restriction(self, s): - s = s if s else None - self._model.set_search_restriction(s) - def mouseMoveEvent(self, event): dex = self.indexAt(event.pos()) if self.in_drag_drop or not dex.isValid(): diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 65993ff31c..54384df0cd 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -279,6 +279,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ UpdateMixin.__init__(self, opts) ####################### Search boxes ######################## + SearchRestrictionMixin.__init__(self) SavedSearchBoxMixin.__init__(self) SearchBoxMixin.__init__(self) @@ -313,9 +314,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ TagBrowserMixin.__init__(self, db) ######################### Search Restriction ########################## - SearchRestrictionMixin.__init__(self) - if db.prefs['gui_restriction']: - self.apply_named_search_restriction(db.prefs['gui_restriction']) + if db.prefs['virtual_lib_on_startup']: + self.apply_virtual_library(db.prefs['virtual_lib_on_startup']) ########################### Cover Flow ################################ @@ -598,7 +598,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ def set_window_title(self): - self.setWindowTitle(__appname__ + u' - || %s ||'%self.iactions['Choose Library'].library_name()) + title = u'{0} - || {1} :: {2} :: {3} ||'.format( + __appname__, + self.iactions['Choose Library'].library_name(), + self.library_view.model().db.data.get_base_restriction_name(), + self.library_view.model().db.data.get_search_restriction_name()) + self.setWindowTitle(title) def location_selected(self, location): ''' @@ -613,10 +618,10 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ for action in self.iactions.values(): action.location_selected(location) if location == 'library': - self.search_restriction.setEnabled(True) + self.virtual_library_menu.setEnabled(True) self.highlight_only_button.setEnabled(True) else: - self.search_restriction.setEnabled(False) + self.virtual_library_menu.setEnabled(False) self.highlight_only_button.setEnabled(False) # Reset the view in case something changed while it was invisible self.current_view().reset() diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index b453c654df..048288ef71 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -209,7 +209,8 @@ class ResultCache(SearchQueryParser): # {{{ self._data = [] self._map = self._map_filtered = [] self.first_sort = True - self.search_restriction = '' + self.search_restriction = self.base_restriction = '' + self.base_restriction_name = self.search_restriction_name = '' self.search_restriction_book_count = 0 self.marked_ids_dict = {} self.field_metadata = field_metadata @@ -825,8 +826,19 @@ class ResultCache(SearchQueryParser): # {{{ return ans self._map_filtered = ans + def _build_restriction_string(self, restriction): + if self.base_restriction: + if restriction: + return u'(%s) and (%s)' % (self.base_restriction, restriction) + else: + return self.base_restriction + else: + return restriction + def search_getting_ids(self, query, search_restriction, - set_restriction_count=False): + set_restriction_count=False, use_virtual_library=True): + if use_virtual_library: + search_restriction = self._build_restriction_string(search_restriction) q = '' if not query or not query.strip(): q = search_restriction @@ -847,11 +859,32 @@ class ResultCache(SearchQueryParser): # {{{ self.search_restriction_book_count = len(rv) return rv + def get_search_restriction(self): + return self.search_restriction + def set_search_restriction(self, s): self.search_restriction = s + def get_base_restriction(self): + return self.base_restriction + + def set_base_restriction(self, s): + self.base_restriction = s + + def get_base_restriction_name(self): + return self.base_restriction_name + + def set_base_restriction_name(self, s): + self.base_restriction_name = s + + def get_search_restriction_name(self): + return self.search_restriction_name + + def set_search_restriction_name(self, s): + self.search_restriction_name = s + def search_restriction_applied(self): - return bool(self.search_restriction) + return bool(self.search_restriction) or bool((self.base_restriction)) def get_search_restriction_book_count(self): return self.search_restriction_book_count @@ -1002,7 +1035,7 @@ class ResultCache(SearchQueryParser): # {{{ if field is not None: self.sort(field, ascending) self._map_filtered = list(self._map) - if self.search_restriction: + if self.search_restriction or self.base_restriction: self.search('', return_matches=False) # Sorting functions {{{ diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 376eb52c3c..14c71d5918 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -229,6 +229,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): ('uuid', False), ('comments', True), ('id', False), ('pubdate', False), ('last_modified', False), ('size', False), ('languages', False), ] + defs['virtual_libraries'] = {} + defs['virtual_lib_on_startup'] = defs['cs_virtual_lib_on_startup'] = '' # Migrate the bool tristate tweak defs['bools_are_tristate'] = \ @@ -279,6 +281,24 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): except: pass + # migrate the gui_restriction preference to a virtual library + gr_pref = self.prefs.get('gui_restriction', None) + if gr_pref: + virt_libs = self.prefs.get('virtual_libraries', {}) + virt_libs[gr_pref] = 'search:'+gr_pref + self.prefs['virtual_libraries'] = virt_libs + self.prefs['gui_restriction'] = '' + self.prefs['virtual_lib_on_startup'] = gr_pref + + # migrate the cs_restriction preference to a virtual library + gr_pref = self.prefs.get('cs_restriction', None) + if gr_pref: + virt_libs = self.prefs.get('virtual_libraries', {}) + virt_libs[gr_pref] = 'search:'+gr_pref + self.prefs['virtual_libraries'] = virt_libs + self.prefs['cs_restriction'] = '' + self.prefs['cs_virtual_lib_on_startup'] = gr_pref + # Rename any user categories with names that differ only in case user_cats = self.prefs.get('user_categories', []) catmap = {} diff --git a/src/calibre/library/server/base.py b/src/calibre/library/server/base.py index 9c14f128dd..bbd5239b42 100644 --- a/src/calibre/library/server/base.py +++ b/src/calibre/library/server/base.py @@ -205,26 +205,32 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache, def set_database(self, db): self.db = db + virt_libs = db.prefs.get('virtual_libraries', {}) sr = getattr(self.opts, 'restriction', None) - sr = db.prefs.get('cs_restriction', '') if sr is None else sr - self.set_search_restriction(sr) + if sr: + if sr in virt_libs: + sr = virt_libs[sr] + elif sr not in saved_searches().names(): + prints('WARNING: Content server: search restriction ', + sr, ' does not exist') + sr = '' + else: + sr = 'search:"%s"'%sr + else: + sr = db.prefs.get('cs_virtual_lib_on_startup', '') + if sr: + if sr not in virt_libs: + prints('WARNING: Content server: virtual library ', + sr, ' does not exist') + sr = '' + else: + sr = virt_libs[sr] + self.search_restriction = sr + self.reset_caches() def graceful(self): cherrypy.engine.graceful() - def set_search_restriction(self, restriction): - self.search_restriction_name = restriction - if restriction: - if restriction not in saved_searches().names(): - prints('WARNING: Content server: search restriction ', - restriction, ' does not exist') - self.search_restriction = '' - else: - self.search_restriction = 'search:"%s"'%restriction - else: - self.search_restriction = '' - self.reset_caches() - def setup_loggers(self): access_file = log_access_file error_file = log_error_file diff --git a/src/calibre/library/server/browse.py b/src/calibre/library/server/browse.py index c520e42f34..d25c34d52b 100644 --- a/src/calibre/library/server/browse.py +++ b/src/calibre/library/server/browse.py @@ -145,10 +145,7 @@ def render_rating(rating, url_prefix, container='span', prefix=None): # {{{ # }}} -def get_category_items(category, items, restriction, datatype, prefix): # {{{ - - if category == 'search': - items = [x for x in items if x.name != restriction] +def get_category_items(category, items, datatype, prefix): # {{{ def item(i): templ = (u'Using virtual libraries you can restrict calibre to only show + you books that match a search. When a virtual library is in effect, calibre + behaves as though the library contains only the matched books. The Tag Browser + display only the tags/authors/series/etc. that belong to the matched books and any searches + you do will only search within the books in the virtual library. This + is a good way to partition your large library into smaller and easier to work with subsets.
+ +For example you can use a Virtual Library to only show you books with the Tag "Unread" + or only books by "My Favorite Author" or only books in a particular series.
+ ''')) + hl.setWordWrap(True) + hl.setFrameStyle(hl.StyledPanel) + gl.addWidget(hl, 0, 3, 3, 1) + + bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject) + gl.addWidget(bb, 3, 0, 1, 0) + + self.resize(self.sizeHint()+QSize(150, 25)) + + def build_full_search_string(self): + search_templates = ( '', '{cl}', '{cr}', @@ -46,11 +76,10 @@ class CreateVirtualLibrary(QDialog): '(({cl}) and ({sb}))', '(({cr}) and ({sb}))', '(({cl}) and ({cr}) and ({sb}))' - ] + ) - def build_full_search_string(self): sb = self.gui.search.current_text - db = self.gui.library_view.model().db + db = self.gui.current_db cr = db.data.get_search_restriction() cl = db.data.get_base_restriction() dex = 0 @@ -60,10 +89,10 @@ class CreateVirtualLibrary(QDialog): dex += 2 if cl: dex += 1 - template = self.search_templates[dex] + template = search_templates[dex] return template.format(cl=cl, cr=cr, sb=sb) - def accepted(self): + def accept(self): n = unicode(self.vl_name.text()) if not n: error_dialog(self.gui, _('No name'), @@ -94,42 +123,17 @@ class CreateVirtualLibrary(QDialog): det_msg=e.msg, show=True) return - if not recs: - if question_dialog(self.gui, _('Search found no books'), - _('The search found no books, so the virtual library ' - 'will be empty. Do you really want to use that search?'), - default_yes=False) == self.Rejected: + if not recs and not question_dialog( + self.gui, _('Search found no books'), + _('The search found no books, so the virtual library ' + 'will be empty. Do you really want to use that search?'), + default_yes=False): return self.library_name = n self.library_search = v - self.accept() - - def rejected(self): - self.reject() - -class VirtLibMenu(QMenu): - - def __init__(self): - QMenu.__init__(self) - self.show_tt_for = [] - - def event(self, e): - QMenu.event(self, e) - if e.type() == QEvent.ToolTip: - a = self.activeAction() - if a and a in self.show_tt_for: - tt = a.toolTip() - if tt: - QToolTip.showText(e.globalPos(), tt) - return True - - def clear(self): - self.show_tt_for = [] - QMenu.clear(self) - - def show_tooltip_for_action(self, a): - self.show_tt_for.append(a) + QDialog.accept(self) +# }}} class SearchRestrictionMixin(object): @@ -139,7 +143,7 @@ class SearchRestrictionMixin(object): self.checked = QIcon(I('ok.png')) self.empty = QIcon() - self.virtual_library_menu = VirtLibMenu() + self.virtual_library_menu = QMenu() self.virtual_library.clicked.connect(self.virtual_library_clicked) @@ -161,8 +165,7 @@ class SearchRestrictionMixin(object): db = self.library_view.model().db virt_libs = db.prefs.get('virtual_libraries', {}) cd = CreateVirtualLibrary(self, virt_libs.keys()) - ret = cd.exec_() - if ret == cd.Accepted: + if cd.exec_() == cd.Accepted: self.add_virtual_library(db, cd.library_name, cd.library_search) self.apply_virtual_library(cd.library_name) @@ -180,9 +183,8 @@ class SearchRestrictionMixin(object): a = m.addAction(_('Create Virtual Library')) a.triggered.connect(self.do_create) a.setToolTip(_('Create a new virtual library from the results of a search')) - m.show_tooltip_for_action(a) - self.rm_menu = a = VirtLibMenu() + self.rm_menu = a = QMenu() a.setTitle(_('Remove Virtual Library')) a.aboutToShow.connect(self.build_virtual_library_list) m.addMenu(a) @@ -212,7 +214,6 @@ class SearchRestrictionMixin(object): a = m.addAction(self.checked if vl == current_lib else self.empty, vl) a.setToolTip(virt_libs[vl]) a.triggered.connect(partial(self.apply_virtual_library, library=vl)) - m.show_tooltip_for_action(a) p = QPoint(0, self.virtual_library.height()) self.virtual_library_menu.popup(self.virtual_library.mapToGlobal(p)) @@ -238,7 +239,6 @@ class SearchRestrictionMixin(object): def add_action(name, search): a = m.addAction(name) a.setToolTip(search) - m.show_tooltip_for_action(a) a.triggered.connect(partial(self.remove_vl_triggered, name=name)) for n in sorted(virt_libs.keys(), key=sort_key): @@ -368,3 +368,14 @@ class SearchRestrictionMixin(object): self.search_count.setStyleSheet( 'QLabel { background-color: transparent; }') self.search_count.setText(t) + +if __name__ == '__main__': + from calibre.gui2 import Application + from calibre.gui2.preferences import init_gui + app = Application([]) + app + gui = init_gui() + d = CreateVirtualLibrary(gui, []) + d.exec_() + + From f13ccc6d9723ad5a34526b75240abec336dc165a Mon Sep 17 00:00:00 2001 From: Kovid Goyal'+_('Create a virtual library based on: ')+ + ('{0}, ' + '{1}, ' + '{2}, ' + '{3}.').format(_('Authors'), _('Tags'), _('Publishers'), _('Series'))) + sl.setWordWrap(True) + sl.setTextInteractionFlags(Qt.LinksAccessibleByMouse) + sl.linkActivated.connect(self.link_activated) + gl.addWidget(sl, 2, 0, 1, 2) + self.hl = hl = QLabel(_('''
'+_('Create a virtual library based on: ')+
('{0}, '
@@ -102,6 +137,11 @@ class CreateVirtualLibrary(QDialog): # {{{
bb.rejected.connect(self.reject)
gl.addWidget(bb, 4, 0, 1, 0)
+ if editing:
+ db = self.gui.current_db
+ virt_libs = db.prefs.get('virtual_libraries', {})
+ self.vl_text.setText(virt_libs.get(editing, ''))
+
self.resize(self.sizeHint()+QSize(150, 25))
def link_activated(self, url):
@@ -116,48 +156,28 @@ class CreateVirtualLibrary(QDialog): # {{{
self.vl_name.setText(d.names.next())
self.vl_text.setText(' or '.join(search))
- def build_full_search_string(self):
- search_templates = (
- '',
- '{cl}',
- '{cr}',
- '(({cl}) and ({cr}))',
- '{sb}',
- '(({cl}) and ({sb}))',
- '(({cr}) and ({sb}))',
- '(({cl}) and ({cr}) and ({sb}))'
- )
-
- sb = self.gui.search.current_text
- db = self.gui.current_db
- cr = db.data.get_search_restriction()
- cl = db.data.get_base_restriction()
- dex = 0
- if sb:
- dex += 4
- if cr:
- dex += 2
- if cl:
- dex += 1
- template = search_templates[dex]
- return template.format(cl=cl, cr=cr, sb=sb)
-
def accept(self):
- n = unicode(self.vl_name.text())
+ n = unicode(self.vl_name.text()).strip()
if not n:
error_dialog(self.gui, _('No name'),
_('You must provide a name for the new virtual library'),
show=True)
return
- if n in self.existing_names:
+ if n.startswith('*'):
+ error_dialog(self.gui, _('Invalid name'),
+ _('A virtual library name cannot begin with "*"'),
+ show=True)
+ return
+
+ if n in self.existing_names and n != self.editing:
if question_dialog(self.gui, _('Name already in use'),
_('That name is already in use. Do you want to replace it '
'with the new search?'),
default_yes=False) == self.Rejected:
return
- v = unicode(self.vl_text.text())
+ v = unicode(self.vl_text.text()).strip()
if not v:
error_dialog(self.gui, _('No search string'),
_('You must provide a search to define the new virtual library'),
@@ -192,6 +212,8 @@ class SearchRestrictionMixin(object):
def __init__(self):
self.checked = QIcon(I('ok.png'))
self.empty = QIcon()
+ self.search_based_vl_name = None
+ self.search_based_vl = None
self.virtual_library_menu = QMenu()
@@ -211,32 +233,31 @@ class SearchRestrictionMixin(object):
virt_libs[name] = search
db.prefs.set('virtual_libraries', virt_libs)
- def do_create(self):
+ def do_create_edit(self, editing=None):
db = self.library_view.model().db
virt_libs = db.prefs.get('virtual_libraries', {})
- cd = CreateVirtualLibrary(self, virt_libs.keys())
+ cd = CreateVirtualLibrary(self, virt_libs.keys(), editing=editing)
if cd.exec_() == cd.Accepted:
+ if editing:
+ self._remove_vl(editing, reapply=False)
self.add_virtual_library(db, cd.library_name, cd.library_search)
self.apply_virtual_library(cd.library_name)
- def do_remove(self):
- db = self.library_view.model().db
- db.data.set_base_restriction("")
- db.data.set_base_restriction_name("")
- self._apply_search_restriction(db.data.get_search_restriction(),
- db.data.get_search_restriction_name())
-
def virtual_library_clicked(self):
m = self.virtual_library_menu
m.clear()
a = m.addAction(_('Create Virtual Library'))
- a.triggered.connect(self.do_create)
- a.setToolTip(_('Create a new virtual library from the results of a search'))
+ a.triggered.connect(partial(self.do_create_edit, editing=None))
+
+ self.edit_menu = a = QMenu()
+ a.setTitle(_('Edit Virtual Library'))
+ a.aboutToShow.connect(partial(self.build_virtual_library_list, remove=False))
+ m.addMenu(a)
self.rm_menu = a = QMenu()
a.setTitle(_('Remove Virtual Library'))
- a.aboutToShow.connect(self.build_virtual_library_list)
+ a.aboutToShow.connect(partial(self.build_virtual_library_list, remove=True))
m.addMenu(a)
m.addSeparator()
@@ -259,10 +280,20 @@ class SearchRestrictionMixin(object):
a = m.addAction(self.empty, self.no_restriction)
a.triggered.connect(partial(self.apply_virtual_library, library=''))
+ a = m.addAction(self.empty, _('*current search'))
+ a.triggered.connect(partial(self.apply_virtual_library, library='*'))
+
+ if self.search_based_vl_name:
+ a = m.addAction(
+ self.checked if db.data.get_base_restriction_name().startswith('*')
+ else self.empty,
+ self.search_based_vl_name)
+ a.triggered.connect(partial(self.apply_virtual_library,
+ library=self.search_based_vl_name))
+
virt_libs = db.prefs.get('virtual_libraries', {})
for vl in sorted(virt_libs.keys(), key=sort_key):
a = m.addAction(self.checked if vl == current_lib else self.empty, vl)
- a.setToolTip(virt_libs[vl])
a.triggered.connect(partial(self.apply_virtual_library, library=vl))
p = QPoint(0, self.virtual_library.height())
@@ -274,22 +305,41 @@ class SearchRestrictionMixin(object):
if not library:
db.data.set_base_restriction('')
db.data.set_base_restriction_name('')
+ elif library == '*':
+ if not _build_full_search_string(self):
+ error_dialog(self, _('No search'),
+ _('There is no current search to use'), show=True)
+ return
+
+ self.search_based_vl = _build_full_search_string(self)
+ db.data.set_base_restriction(self.search_based_vl)
+ self.search_based_vl_name = self._trim_restriction_name(
+ '*' + self.search_based_vl)
+ db.data.set_base_restriction_name(self.search_based_vl_name)
+ elif library == self.search_based_vl_name:
+ db.data.set_base_restriction(self.search_based_vl)
+ db.data.set_base_restriction_name(self.search_based_vl_name)
elif library in virt_libs:
db.data.set_base_restriction(virt_libs[library])
db.data.set_base_restriction_name(library)
self._apply_search_restriction(db.data.get_search_restriction(),
db.data.get_search_restriction_name())
- def build_virtual_library_list(self):
+ def build_virtual_library_list(self, remove=False):
db = self.library_view.model().db
virt_libs = db.prefs.get('virtual_libraries', {})
- m = self.rm_menu
+ if remove:
+ m = self.rm_menu
+ else:
+ m = self.edit_menu
m.clear()
def add_action(name, search):
a = m.addAction(name)
- a.setToolTip(search)
- a.triggered.connect(partial(self.remove_vl_triggered, name=name))
+ if remove:
+ a.triggered.connect(partial(self.remove_vl_triggered, name=name))
+ else:
+ a.triggered.connect(partial(self.do_create_edit, editing=name))
for n in sorted(virt_libs.keys(), key=sort_key):
add_action(n, virt_libs[n])
@@ -300,13 +350,19 @@ class SearchRestrictionMixin(object):
'the virtual library {0}').format(name),
default_yes=False):
return
+ self._remove_vl(name, reapply=True)
+
+ def _remove_vl(self, name, reapply=True):
db = self.library_view.model().db
virt_libs = db.prefs.get('virtual_libraries', {})
virt_libs.pop(name, None)
db.prefs.set('virtual_libraries', virt_libs)
- if db.data.get_base_restriction_name() == name:
+ if reapply and db.data.get_base_restriction_name() == name:
self.apply_virtual_library('')
+ def _trim_restriction_name(self, name):
+ return name[0:MAX_VIRTUAL_LIBRARY_NAME_LENGTH].strip()
+
def build_search_restriction_list(self):
m = self.ar_menu
m.clear()
@@ -324,6 +380,7 @@ class SearchRestrictionMixin(object):
def add_action(txt, index):
self.search_restriction.addItem(txt)
+ txt = self._trim_restriction_name(txt)
if txt == current_restriction:
a = m.addAction(self.checked, txt if txt else self.no_restriction)
else:
@@ -332,7 +389,7 @@ class SearchRestrictionMixin(object):
action=a, index=index))
add_action('', 0)
- add_action('*current search', 1)
+ add_action(_('*current search'), 1)
dex = 2
if current_restriction_text:
add_action(current_restriction_text, 2)
@@ -372,7 +429,7 @@ class SearchRestrictionMixin(object):
else:
self.search_restriction.insertItem(2, s)
self.search_restriction.setCurrentIndex(2)
- self._apply_search_restriction(search, s)
+ self._apply_search_restriction(search, self._trim_restriction_name(s))
def apply_search_restriction(self, i):
if i == 1:
From 311d2cc8944c9925d1eeb03c4f7582f33e4b35b3 Mon Sep 17 00:00:00 2001
From: Kovid Goyal