00001 ############################################################################## 00002 # 00003 # Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. 00004 # Fabien Pinckaers <fp@tiny.Be> 00005 # Copyright (c) 2007-2008 Albert Cervera i Areny <albert@nan-tic.com> 00006 # 00007 # WARNING: This program as such is intended to be used by professional 00008 # programmers who take the whole responsability of assessing all potential 00009 # consequences resulting from its eventual inadequacies and bugs 00010 # End users who are looking for a ready-to-use solution with commercial 00011 # garantees and support are strongly adviced to contract a Free Software 00012 # Service Company 00013 # 00014 # This program is Free Software; you can redistribute it and/or 00015 # modify it under the terms of the GNU General Public License 00016 # as published by the Free Software Foundation; either version 2 00017 # of the License, or (at your option) any later version. 00018 # 00019 # This program is distributed in the hope that it will be useful, 00020 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 # GNU General Public License for more details. 00023 # 00024 # You should have received a copy of the GNU General Public License 00025 # along with this program; if not, write to the Free Software 00026 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 # 00028 ############################################################################## 00029 00030 from Koo.Search.AbstractSearchWidget import * 00031 from PyQt4.QtGui import * 00032 00033 class CharSearchWidget(AbstractSearchWidget): 00034 def __init__(self, name, parent, attrs={}): 00035 AbstractSearchWidget.__init__(self, name, parent, attrs) 00036 self.layout = QHBoxLayout( self ) 00037 self.layout.setSpacing( 0 ) 00038 self.layout.setContentsMargins( 0, 0, 0, 0 ) 00039 self.uiText = QLineEdit( self ) 00040 self.layout.addWidget( self.uiText ) 00041 self.focusWidget = self.uiText 00042 # Catch keyDownPressed 00043 self.focusWidget.installEventFilter( self ) 00044 00045 def value(self): 00046 s = unicode(self.uiText.text()) 00047 if s: 00048 return [(self.name,self.attrs.get('comparator','ilike'),s)] 00049 else: 00050 return [] 00051 00052 def clear(self): 00053 self.uiText.clear() 00054 00055 def setValue(self, value): 00056 self.uiText.setText( value )