Changeset 06b0138 in sasview for src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
- Timestamp:
- Jun 8, 2017 3:12:46 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 70080a0
- Parents:
- aca8418
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
raca8418 r06b0138 4 4 import sas.qtgui.Utilities.GuiUtils as GuiUtils 5 5 6 # Main parameter table view columns7 PARAM_PROPERTY=08 PARAM_VALUE=19 PARAM_MIN=210 PARAM_MAX=311 PARAM_UNIT=412 13 # polydispersity functions14 POLYDISPERSE_FUNCTIONS=['rectangle', 'array', 'lognormal', 'gaussian', 'schulz']15 # polydispersity columns16 POLY_PARAMETER=017 POLY_PD=118 POLY_MIN=219 POLY_MAX=320 POLY_NPTS=421 POLY_NSIGS=522 POLY_FUNCTION=623 POLY_EDITABLE_PARAMS = [POLY_MIN, POLY_MAX, POLY_NPTS, POLY_NSIGS]24 25 26 6 class ModelViewDelegate(QtGui.QStyledItemDelegate): 27 7 """ 28 8 Custom delegate for appearance and behavior control of the model view 29 9 """ 10 # Main parameter table view columns 11 PARAM_PROPERTY=0 12 PARAM_VALUE=1 13 PARAM_MIN=2 14 PARAM_MAX=3 15 PARAM_UNIT=4 16 30 17 def paint(self, painter, option, index): 31 18 """ 32 19 Overwrite generic painter for certain columns 33 20 """ 34 if index.column() in ( PARAM_UNIT, PARAM_MIN,PARAM_MAX):21 if index.column() in (self.PARAM_UNIT, self.PARAM_MIN, self.PARAM_MAX): 35 22 # Units - present in nice HTML 36 23 options = QtGui.QStyleOptionViewItemV4(option) … … 69 56 if not index.isValid(): 70 57 return 0 71 if index.column() == PARAM_VALUE: #only in the value column58 if index.column() == self.PARAM_VALUE: #only in the value column 72 59 editor = QtGui.QLineEdit(widget) 73 60 validator = QtGui.QDoubleValidator() … … 81 68 Overwrite generic model update method for certain columns 82 69 """ 83 if index.column() in ( PARAM_MIN,PARAM_MAX):70 if index.column() in (self.PARAM_MIN, self.PARAM_MAX): 84 71 try: 85 72 value_float = float(editor.text()) … … 95 82 Custom delegate for appearance and behavior control of the polydispersity view 96 83 """ 84 # polydispersity functions 85 POLYDISPERSE_FUNCTIONS=['rectangle', 'array', 'lognormal', 'gaussian', 'schulz'] 86 # polydispersity columns 87 POLY_PARAMETER=0 88 POLY_PD=1 89 POLY_MIN=2 90 POLY_MAX=3 91 POLY_NPTS=4 92 POLY_NSIGS=5 93 POLY_FUNCTION=6 94 POLY_EDITABLE_PARAMS = [POLY_MIN, POLY_MAX, POLY_NPTS, POLY_NSIGS] 95 97 96 combo_updated = QtCore.pyqtSignal(str, int) 97 98 98 def createEditor(self, widget, option, index): 99 99 # Remember the current choice … … 101 101 if not index.isValid(): 102 102 return 0 103 if index.column() == POLY_FUNCTION:103 if index.column() == self.POLY_FUNCTION: 104 104 editor = QtGui.QComboBox(widget) 105 for function in POLYDISPERSE_FUNCTIONS:105 for function in self.POLYDISPERSE_FUNCTIONS: 106 106 editor.addItem(function) 107 107 current_index = editor.findText(current_text) … … 109 109 editor.currentIndexChanged.connect(lambda: self.combo_updated.emit(str(editor.currentText()), index.row())) 110 110 return editor 111 elif index.column() in POLY_EDITABLE_PARAMS:111 elif index.column() in self.POLY_EDITABLE_PARAMS: 112 112 editor = QtGui.QLineEdit(widget) 113 113 validator = QtGui.QDoubleValidator() … … 121 121 Overwrite generic painter for certain columns 122 122 """ 123 if index.column() in ( POLY_MIN,POLY_MAX):123 if index.column() in (self.POLY_MIN, self.POLY_MAX): 124 124 # Units - present in nice HTML 125 125 options = QtGui.QStyleOptionViewItemV4(option)
Note: See TracChangeset
for help on using the changeset viewer.