Package Camelot :: Package camelot :: Package view :: Package controls :: Module filterlist
[frames] | no frames]

Source Code for Module Camelot.camelot.view.controls.filterlist

 1  #  ============================================================================ 
 2  # 
 3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 
 4  #  www.conceptive.be / project-camelot@conceptive.be 
 5  # 
 6  #  This file is part of the Camelot Library. 
 7  # 
 8  #  This file may be used under the terms of the GNU General Public 
 9  #  License version 2.0 as published by the Free Software Foundation 
10  #  and appearing in the file LICENSE.GPL included in the packaging of 
11  #  this file.  Please review the following information to ensure GNU 
12  #  General Public Licensing requirements will be met: 
13  #  http://www.trolltech.com/products/qt/opensource.html 
14  # 
15  #  If you are unsure which license is appropriate for your use, please 
16  #  review the following information: 
17  #  http://www.trolltech.com/products/qt/licensing.html or contact 
18  #  project-camelot@conceptive.be. 
19  # 
20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 
21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
22  # 
23  #  For use of this library in commercial applications, please contact 
24  #  project-camelot@conceptive.be 
25  # 
26  #  ============================================================================ 
27   
28  """Controls to filter data""" 
29   
30  import logging 
31  logger = logging.getLogger('camelot.view.controls.filter') 
32   
33  from PyQt4 import QtGui, QtCore 
34   
35  _ = lambda x:x 
36   
37  filter_changed_signal = QtCore.SIGNAL('filter_changed') 
38   
39 -class FilterList(QtGui.QScrollArea):
40 """A list with filters that can be applied on a query in the tableview""" 41
42 - def __init__(self, items, parent):
43 """ 44 :param items: list of tubles (name, choices) for constructing the different filterboxes 45 """ 46 QtGui.QScrollArea.__init__(self, parent) 47 widget = QtGui.QWidget(self) 48 self.setFrameStyle(QtGui.QFrame.NoFrame) 49 layout = QtGui.QVBoxLayout() 50 51 for filter,(name,options) in items: 52 filter_widget = filter.render(widget, name, options) 53 layout.addWidget(filter_widget) 54 self.connect(filter_widget, 55 filter_changed_signal, 56 self.emit_filters_changed) 57 58 widget.setLayout(layout) 59 self.setWidget(widget) 60 if len(items) == 0: 61 self.setMaximumWidth(0) 62 else: 63 self.setSizePolicy( QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding )
64
65 - def decorate_query(self, query):
66 for i in range(self.widget().layout().count()): 67 if self.widget().layout().itemAt(i).widget(): 68 query = self.widget().layout().itemAt(i).widget().decorate_query(query) 69 return query
70
71 - def emit_filters_changed(self):
72 logger.debug('filters changed') 73 self.emit(QtCore.SIGNAL('filters_changed'))
74