home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1313 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.6 KB  |  52 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_search_restriction(self, i):
  26.         r = unicode(self.search_restriction.currentText())
  27.         if r is not None and r != '':
  28.             self.restriction_in_effect = True
  29.             restriction = 'search:"%s"' % r
  30.         else:
  31.             self.restriction_in_effect = False
  32.             restriction = ''
  33.         self.restriction_count_of_books_in_view = self.library_view.model().set_search_restriction(restriction)
  34.         self.search.clear_to_help()
  35.         self.saved_search.clear_to_help()
  36.         self.tags_view.set_search_restriction(restriction)
  37.         self.set_number_of_books_shown()
  38.  
  39.     
  40.     def set_number_of_books_shown(self):
  41.         if self.current_view() == self.library_view and self.restriction_in_effect:
  42.             t = _('({0} of {1})').format(self.current_view().row_count(), self.restriction_count_of_books_in_view)
  43.             self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
  44.         elif not self.search.in_a_search():
  45.             t = _('(all books)')
  46.         else:
  47.             t = _('({0} of all)').format(self.current_view().row_count())
  48.         self.search_count.setStyleSheet('QLabel { background-color: transparent; }')
  49.         self.search_count.setText(t)
  50.  
  51.  
  52.