Changeset 4992ff2 in sasview for src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
- Timestamp:
- Nov 9, 2017 8:43:07 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:
- 7969b9c
- Parents:
- 7fb471d
- git-author:
- Piotr Rozyczko <rozyczko@…> (10/30/17 07:50:09)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:43:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r02f1d12 r4992ff2 1 from PyQt4 import QtGui 2 from PyQt4 import QtCore 1 from PyQt5 import QtCore 2 from PyQt5 import QtGui 3 from PyQt5 import QtWidgets 3 4 4 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 5 6 6 class ModelViewDelegate(Qt Gui.QStyledItemDelegate):7 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): 7 8 """ 8 9 Custom delegate for appearance and behavior control of the model view … … 12 13 Overwrite generic constructor to allow for some globals 13 14 """ 14 super(Qt Gui.QStyledItemDelegate, self).__init__()15 super(QtWidgets.QStyledItemDelegate, self).__init__() 15 16 16 17 # Main parameter table view columns … … 43 44 if index.column() in self.fancyColumns(): 44 45 # Units - present in nice HTML 45 options = QtGui.QStyleOptionViewItemV4(option) 46 #options = QtWidgets.QStyleOptionViewItemV4(option) 47 options = QtWidgets.QStyleOptionViewItem(option) 46 48 self.initStyleOption(options,index) 47 49 … … 57 59 # delete the original content 58 60 options.text = "" 59 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);61 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 60 62 61 63 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 62 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)64 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 63 65 64 66 painter.save() … … 70 72 else: 71 73 # Just the default paint 72 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)74 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 73 75 74 76 def createEditor(self, widget, option, index): … … 79 81 return 0 80 82 if index.column() == self.param_value: #only in the value column 81 editor = Qt Gui.QLineEdit(widget)83 editor = QtWidgets.QLineEdit(widget) 82 84 validator = QtGui.QDoubleValidator() 83 85 editor.setValidator(validator) … … 100 102 # balloon popup? tooltip? cell background colour flash? 101 103 return 102 Qt Gui.QStyledItemDelegate.setModelData(self, editor, model, index)103 104 105 class PolyViewDelegate(Qt Gui.QStyledItemDelegate):104 QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 105 106 107 class PolyViewDelegate(QtWidgets.QStyledItemDelegate): 106 108 """ 107 109 Custom delegate for appearance and behavior control of the polydispersity view … … 116 118 Overwrite generic constructor to allow for some globals 117 119 """ 118 super(Qt Gui.QStyledItemDelegate, self).__init__()120 super(QtWidgets.QStyledItemDelegate, self).__init__() 119 121 120 122 self.poly_parameter = 0 … … 160 162 return None 161 163 elif index.column() in self.editableParameters(): 162 self.editor = Qt Gui.QLineEdit(widget)164 self.editor = QtWidgets.QLineEdit(widget) 163 165 validator = QtGui.QDoubleValidator() 164 166 self.editor.setValidator(validator) 165 167 return self.editor 166 168 else: 167 Qt Gui.QStyledItemDelegate.createEditor(self, widget, option, index)169 QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 168 170 169 171 def paint(self, painter, option, index): … … 173 175 if index.column() in (self.poly_min, self.poly_max): 174 176 # Units - present in nice HTML 175 options = Qt Gui.QStyleOptionViewItemV4(option)177 options = QtWidgets.QStyleOptionViewItem(option) 176 178 self.initStyleOption(options,index) 177 179 … … 187 189 # delete the original content 188 190 options.text = "" 189 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);191 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 190 192 191 193 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 192 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)194 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 193 195 194 196 painter.save() … … 200 202 else: 201 203 # Just the default paint 202 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)203 204 class MagnetismViewDelegate(Qt Gui.QStyledItemDelegate):204 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 205 206 class MagnetismViewDelegate(QtWidgets.QStyledItemDelegate): 205 207 """ 206 208 Custom delegate for appearance and behavior control of the magnetism view … … 210 212 Overwrite generic constructor to allow for some globals 211 213 """ 212 super(Qt Gui.QStyledItemDelegate, self).__init__()214 super(QtWidgets.QStyledItemDelegate, self).__init__() 213 215 214 216 self.mag_parameter = 0 … … 238 240 return 0 239 241 if index.column() in self.editableParameters(): 240 editor = Qt Gui.QLineEdit(widget)242 editor = QtWidgets.QLineEdit(widget) 241 243 validator = QtGui.QDoubleValidator() 242 244 editor.setValidator(validator) 243 245 return editor 244 246 else: 245 Qt Gui.QStyledItemDelegate.createEditor(self, widget, option, index)247 QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 246 248 247 249 def paint(self, painter, option, index): … … 251 253 if index.column() in (self.mag_min, self.mag_max, self.mag_unit): 252 254 # Units - present in nice HTML 253 options = Qt Gui.QStyleOptionViewItemV4(option)255 options = QtWidgets.QStyleOptionViewItem(option) 254 256 self.initStyleOption(options,index) 255 257 … … 265 267 # delete the original content 266 268 options.text = "" 267 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);269 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 268 270 269 271 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 270 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)272 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 271 273 272 274 painter.save() … … 278 280 else: 279 281 # Just the default paint 280 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)282 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
Note: See TracChangeset
for help on using the changeset viewer.