home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1245 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.0 KB  |  41 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8. from PyQt4.Qt import QComboBox, QStringList, Qt
  9. from calibre.gui2 import config as gui_conf
  10.  
  11. class HistoryBox(QComboBox):
  12.     
  13.     def __init__(self, parent = None):
  14.         QComboBox.__init__(self, parent)
  15.         self.setEditable(True)
  16.  
  17.     
  18.     def initialize(self, opt_name, default, help = None):
  19.         history = gui_conf[opt_name]
  20.         if default not in history:
  21.             history.append(default)
  22.         
  23.         self.addItems(QStringList(history))
  24.         self.setCurrentIndex(self.findText(default, Qt.MatchFixedString))
  25.         if help is not None:
  26.             self.setToolTip(help)
  27.             self.setWhatsThis(help)
  28.         
  29.  
  30.     
  31.     def save_history(self, opt_name):
  32.         history = [ unicode(self.itemText(i)) for i in range(self.count()) ]
  33.         ct = self.text()
  34.         gui_conf[opt_name] = history[:10]
  35.  
  36.     
  37.     def text(self):
  38.         return unicode(self.currentText()).strip()
  39.  
  40.  
  41.