home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1372 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.9 KB  |  64 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4.  
  5. class SearchRestrictionMixin(object):
  6.     
  7.     def __init__(self):
  8.         self.search_restriction.initialize(help_text = _('Restrict to'))
  9.         self.search_restriction.activated[int].connect(self.apply_search_restriction)
  10.         self.library_view.model().count_changed_signal.connect(self.restriction_count_changed)
  11.         self.search_restriction.setSizeAdjustPolicy(self.search_restriction.AdjustToMinimumContentsLengthWithIcon)
  12.         self.search_restriction.setMinimumContentsLength(10)
  13.         self.search_restriction.setStatusTip(self.search_restriction.toolTip())
  14.         self.search_count.setText(_('(all books)'))
  15.  
  16.     
  17.     def restriction_count_changed(self, c):
  18.         self.restriction_count_of_books_in_view += c - self.restriction_count_of_books_in_library
  19.         self.restriction_count_of_books_in_library = c
  20.         if self.restriction_in_effect:
  21.             self.set_number_of_books_shown()
  22.         
  23.  
  24.     
  25.     def apply_named_search_restriction(self, name):
  26.         if not name:
  27.             r = 0
  28.         else:
  29.             r = self.search_restriction.findText(name)
  30.             if r < 0:
  31.                 r = 0
  32.             
  33.         self.search_restriction.setCurrentIndex(r)
  34.         self.apply_search_restriction(r)
  35.  
  36.     
  37.     def apply_search_restriction(self, i):
  38.         r = unicode(self.search_restriction.currentText())
  39.         if r is not None and r != '':
  40.             self.restriction_in_effect = True
  41.             restriction = 'search:"%s"' % r
  42.         else:
  43.             self.restriction_in_effect = False
  44.             restriction = ''
  45.         self.restriction_count_of_books_in_view = self.library_view.model().set_search_restriction(restriction)
  46.         self.search.clear_to_help()
  47.         self.saved_search.clear_to_help()
  48.         self.tags_view.set_search_restriction(restriction)
  49.         self.set_number_of_books_shown()
  50.  
  51.     
  52.     def set_number_of_books_shown(self):
  53.         if self.current_view() == self.library_view and self.restriction_in_effect:
  54.             t = _('({0} of {1})').format(self.current_view().row_count(), self.restriction_count_of_books_in_view)
  55.             self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
  56.         elif not self.search.in_a_search():
  57.             t = _('(all books)')
  58.         else:
  59.             t = _('({0} of all)').format(self.current_view().row_count())
  60.         self.search_count.setStyleSheet('QLabel { background-color: transparent; }')
  61.         self.search_count.setText(t)
  62.  
  63.  
  64.