Changeset 1184
- Timestamp:
- 03/11/10 22:37:04 (5 months ago)
- Location:
- trunk/camelot/view
- Files:
-
- 4 modified
-
controls/filterlist.py (modified) (1 diff)
-
controls/search.py (modified) (3 diffs)
-
controls/tableview.py (modified) (2 diffs)
-
filters.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/camelot/view/controls/filterlist.py
r1165 r1184 58 58 widget.setLayout(layout) 59 59 self.setWidget(widget) 60 #self.setMaximumWidth(self.fontMetrics().width( ' ' )*70)61 60 if len(items) == 0: 62 61 self.setMaximumWidth(0) -
trunk/camelot/view/controls/search.py
r1154 r1184 38 38 """ 39 39 40 expand_search_options_signal = QtCore.SIGNAL('expand_search_options()') 41 40 42 def __init__(self, parent): 41 43 QtGui.QWidget.__init__(self, parent) … … 52 54 self.connect(self.search_button, 53 55 QtCore.SIGNAL('clicked()'), 54 self.e mit_search)56 self.expand_search_options_signal) 55 57 56 58 # Search input … … 89 91 self.emit_search() 90 92 93 def emit_expand_search_options(self): 94 self.emit(self.expand_search_options_signal) 95 91 96 def emit_search(self): 92 97 text = unicode(self.search_input.user_input()) -
trunk/camelot/view/controls/tableview.py
r1183 r1184 113 113 def __init__( self, parent, admin ): 114 114 QtGui.QWidget.__init__( self, parent ) 115 layout = QtGui.QVBoxLayout() 115 116 widget_layout = QtGui.QHBoxLayout() 116 117 self.search = self.search_widget( self ) 118 self.connect(self.search, SimpleSearchControl.expand_search_options_signal, self.expand_search_options) 117 119 title = UserTranslatableLabel( admin.get_verbose_name_plural(), self ) 118 120 title.setFont( self._title_font ) … … 122 124 self.number_of_rows = self.rows_widget( self ) 123 125 widget_layout.addWidget( self.number_of_rows ) 124 125 126 else: 126 127 self.number_of_rows = None 127 self.setLayout( widget_layout ) 128 layout.addLayout( widget_layout ) 129 self._expanded_search = QtGui.QLabel('Expanded') 130 self._expanded_search.hide() 131 layout.addWidget(self._expanded_search) 132 self.setLayout( layout ) 128 133 self.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Fixed ) 129 134 self.setNumberOfRows( 0 ) 130 135 136 def expand_search_options(self): 137 if self._expanded_search.isHidden(): 138 self._expanded_search.show() 139 else: 140 self._expanded_search.hide() 141 131 142 @gui_function 132 143 def setNumberOfRows( self, rows ): -
trunk/camelot/view/filters.py
r1173 r1184 216 216 self._field_attributes['editable'] = True 217 217 layout = QtGui.QVBoxLayout() 218 group = QtGui.QButtonGroup(self) 219 self.all_button = QtGui.QRadioButton(ugettext('All'), self) 220 self.all_button.setChecked(True) 221 group.addButton(self.all_button) 222 layout.addWidget(self.all_button) 223 self.none_button = QtGui.QRadioButton(ugettext('None'), self) 224 group.addButton(self.none_button) 225 layout.addWidget(self.none_button) 226 self.connect(self.all_button, QtCore.SIGNAL('toggled(bool)'), self.all_toggled) 227 self.connect(self.none_button, QtCore.SIGNAL('toggled(bool)'), self.none_toggled) 228 self.setLayout(layout) 229 # if self._field_attributes.get('nullable', True)==False: 230 # self.none_button.hide() 218 self._choices = [(0, ugettext('All')), (1, ugettext('None')), (2, ugettext('='))] 219 combobox = QtGui.QComboBox(self) 220 layout.addWidget(combobox) 221 for i,name in self._choices: 222 combobox.insertItem(i, unicode(name)) 223 self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'), self.combobox_changed) 231 224 delegate = self._field_attributes['delegate'](**self._field_attributes) 232 225 option = QtGui.QStyleOptionViewItem() 233 226 option.version = 5 234 self. editor = delegate.createEditor( self, option, None )227 self._editor = delegate.createEditor( self, option, None ) 235 228 # explicitely set a value, otherways the current value remains ValueLoading 236 self.editor.set_value(None) 237 self.connect(self.editor, editors.editingFinished, self.editor_editing_finished) 238 layout.addWidget(self.editor) 239 self._filter = False 229 self._editor.set_value(None) 230 self.connect(self._editor, editors.editingFinished, self.editor_editing_finished) 231 layout.addWidget(self._editor) 232 self.setLayout(layout) 233 self._editor.setEnabled(False) 234 self._index = 0 240 235 self._value = None 241 236 242 def all_toggled(self, bool): 243 self.editor.set_value(None) 244 self._filter = False 245 self.emit(filter_changed_signal) 246 247 def none_toggled(self, bool): 248 self.editor.set_value(None) 249 self._filter = True 250 self._value = None 237 def combobox_changed(self, index): 238 self._index = index 239 if index==2: 240 self._editor.setEnabled(True) 241 else: 242 self._editor.setEnabled(False) 251 243 self.emit(filter_changed_signal) 252 244 253 245 def editor_editing_finished(self): 254 self.all_button.setChecked(False) 255 self.none_button.setChecked(False) 256 self._filter = True 257 self._value = self.editor.get_value() 246 self._value = self._editor.get_value() 258 247 self.emit(filter_changed_signal) 259 248 260 249 def decorate_query(self, query): 261 if not self._filter:250 if self._index==0: 262 251 return query 252 if self._index==1: 253 return query.filter(getattr(self._entity, self._field_name)==None) 263 254 return query.filter(getattr(self._entity, self._field_name)==self._value) 264 255
