Ignore:
Timestamp:
Nov 9, 2017 6:43:07 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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 05:50:09)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 06:43:07)
Message:

Initial, in-progress version. Not really working atm. SASVIEW-787

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 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    34 
    45import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    56 
    6 class ModelViewDelegate(QtGui.QStyledItemDelegate): 
     7class ModelViewDelegate(QtWidgets.QStyledItemDelegate): 
    78    """ 
    89    Custom delegate for appearance and behavior control of the model view 
     
    1213        Overwrite generic constructor to allow for some globals 
    1314        """ 
    14         super(QtGui.QStyledItemDelegate, self).__init__() 
     15        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    1516 
    1617        # Main parameter table view columns 
     
    4344        if index.column() in self.fancyColumns(): 
    4445            # Units - present in nice HTML 
    45             options = QtGui.QStyleOptionViewItemV4(option) 
     46            #options = QtWidgets.QStyleOptionViewItemV4(option) 
     47            options = QtWidgets.QStyleOptionViewItem(option) 
    4648            self.initStyleOption(options,index) 
    4749 
     
    5759            # delete the original content 
    5860            options.text = "" 
    59             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     61            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    6062 
    6163            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    62             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     64            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    6365 
    6466            painter.save() 
     
    7072        else: 
    7173            # Just the default paint 
    72             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
     74            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
    7375 
    7476    def createEditor(self, widget, option, index): 
     
    7981            return 0 
    8082        if index.column() == self.param_value: #only in the value column 
    81             editor = QtGui.QLineEdit(widget) 
     83            editor = QtWidgets.QLineEdit(widget) 
    8284            validator = QtGui.QDoubleValidator() 
    8385            editor.setValidator(validator) 
     
    100102                # balloon popup? tooltip? cell background colour flash? 
    101103                return 
    102         QtGui.QStyledItemDelegate.setModelData(self, editor, model, index) 
    103  
    104  
    105 class PolyViewDelegate(QtGui.QStyledItemDelegate): 
     104        QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 
     105 
     106 
     107class PolyViewDelegate(QtWidgets.QStyledItemDelegate): 
    106108    """ 
    107109    Custom delegate for appearance and behavior control of the polydispersity view 
     
    116118        Overwrite generic constructor to allow for some globals 
    117119        """ 
    118         super(QtGui.QStyledItemDelegate, self).__init__() 
     120        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    119121 
    120122        self.poly_parameter = 0 
     
    160162            return None 
    161163        elif index.column() in self.editableParameters(): 
    162             self.editor = QtGui.QLineEdit(widget) 
     164            self.editor = QtWidgets.QLineEdit(widget) 
    163165            validator = QtGui.QDoubleValidator() 
    164166            self.editor.setValidator(validator) 
    165167            return self.editor 
    166168        else: 
    167             QtGui.QStyledItemDelegate.createEditor(self, widget, option, index) 
     169            QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 
    168170 
    169171    def paint(self, painter, option, index): 
     
    173175        if index.column() in (self.poly_min, self.poly_max): 
    174176            # Units - present in nice HTML 
    175             options = QtGui.QStyleOptionViewItemV4(option) 
     177            options = QtWidgets.QStyleOptionViewItem(option) 
    176178            self.initStyleOption(options,index) 
    177179 
     
    187189            # delete the original content 
    188190            options.text = "" 
    189             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     191            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    190192 
    191193            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    192             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     194            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    193195 
    194196            painter.save() 
     
    200202        else: 
    201203            # Just the default paint 
    202             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
    203  
    204 class MagnetismViewDelegate(QtGui.QStyledItemDelegate): 
     204            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
     205 
     206class MagnetismViewDelegate(QtWidgets.QStyledItemDelegate): 
    205207    """ 
    206208    Custom delegate for appearance and behavior control of the magnetism view 
     
    210212        Overwrite generic constructor to allow for some globals 
    211213        """ 
    212         super(QtGui.QStyledItemDelegate, self).__init__() 
     214        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    213215 
    214216        self.mag_parameter = 0 
     
    238240            return 0 
    239241        if index.column() in self.editableParameters(): 
    240             editor = QtGui.QLineEdit(widget) 
     242            editor = QtWidgets.QLineEdit(widget) 
    241243            validator = QtGui.QDoubleValidator() 
    242244            editor.setValidator(validator) 
    243245            return editor 
    244246        else: 
    245             QtGui.QStyledItemDelegate.createEditor(self, widget, option, index) 
     247            QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 
    246248 
    247249    def paint(self, painter, option, index): 
     
    251253        if index.column() in (self.mag_min, self.mag_max, self.mag_unit): 
    252254            # Units - present in nice HTML 
    253             options = QtGui.QStyleOptionViewItemV4(option) 
     255            options = QtWidgets.QStyleOptionViewItem(option) 
    254256            self.initStyleOption(options,index) 
    255257 
     
    265267            # delete the original content 
    266268            options.text = "" 
    267             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     269            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    268270 
    269271            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    270             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     272            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    271273 
    272274            painter.save() 
     
    278280        else: 
    279281            # Just the default paint 
    280             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
     282            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
Note: See TracChangeset for help on using the changeset viewer.