Changeset 6a3e1fe in sasview for src/sas/qtgui/Utilities/GuiUtils.py


Ignore:
Timestamp:
Nov 17, 2017 8:59:52 AM (7 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:
0261bc1
Parents:
84df556
Message:

Implemented hash method for certain QStandardItem objects, allowing them to be used as dict keys. SASVIEW-806
Minor inversion perspective fixes. SASVIEW-338

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/GuiUtils.py

    rd4881f6a r6a3e1fe  
    265265    item.appendRow(checkbox_item) 
    266266 
     267class HashableStandardItem(QtGui.QStandardItem): 
     268    """ 
     269    Subclassed standard item with reimplemented __hash__ 
     270    to allow for use as an index. 
     271    """ 
     272    def __init__(self, parent=None): 
     273        super(QtGui.QStandardItem, self).__init__() 
     274 
     275    def __hash__(self): 
     276        ''' just a random hash value ''' 
     277        #return hash(self.__init__) 
     278        return 0 
     279 
     280 
    267281def createModelItemWithPlot(update_data, name=""): 
    268282    """ 
     
    272286    py_update_data = update_data 
    273287 
    274     checkbox_item = QtGui.QStandardItem() 
     288    checkbox_item = HashableStandardItem() 
    275289    checkbox_item.setCheckable(True) 
    276290    checkbox_item.setCheckState(QtCore.Qt.Checked) 
Note: See TracChangeset for help on using the changeset viewer.