Changeset 6052c02 in sasview for src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
- Timestamp:
- Jul 9, 2018 10:13:03 AM (6 years ago)
- Branches:
- ESS_GUI_iss959
- Children:
- 085e3c9d
- Parents:
- 515c23df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
rfde5bcd r6052c02 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 7 import logging 8 logger = logging.getLogger(__name__) 6 9 7 10 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): … … 102 105 return 103 106 QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 104 105 107 106 108 class PolyViewDelegate(QtWidgets.QStyledItemDelegate): … … 280 282 # Just the default paint 281 283 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 284 285 class StructureViewDelegate(QtWidgets.QStyledItemDelegate): 286 """ 287 Custom delegate for appearance and behaviour control of the structure 288 factor options view 289 """ 290 def __init__(self, parent=None): 291 """ 292 Override parent constructor 293 """ 294 295 super(StructureViewDelegate, self).__init__() 296 297 self.fittingWidget = parent 298 299 def paint(self, painter, option, index): 300 """ 301 Override generic painter 302 """ 303 # TODO override this with something useful ... ? 304 super(StructureViewDelegate, self).paint( 305 painter, option, index 306 ) 307 308 def createEditor(self, parent, option, index): 309 """ 310 Override generic createEditor -- certain elements have 311 combo boxes 312 """ 313 314 model = self.fittingWidget.structureView.model() 315 316 if not index.parent(): 317 # we only care about child items since we don't edit top-level 318 # items in this view anyway 319 return super(QtWidgets.QStyledItemDelegate, self).createEditor( 320 parent, option, index 321 ) 322 323 # navigate to the parameter name through the parent item (it'll be 324 # on the same row, but col. 0) 325 parent_item = model.itemFromIndex(index.parent()) 326 param_item = parent_item.child(index.row(), 0) 327 328 #item = model.itemFromIndex(index) 329 #print("item (row) [param]: \"{}\" ({}) [{}]".format( 330 # item.text(), index.row(), param_item.text()) 331 #) 332 333 if param_item.text() in ["effective radius", "volume fraction"]: 334 # we want a combo box for these 335 return QtWidgets.QComboBox(parent) 336 337 # return default otherwise 338 return super(StructureViewDelegate, self).createEditor( 339 parent, option, index 340 )
Note: See TracChangeset
for help on using the changeset viewer.