Commit b9f5256e authored by Maxime Perrotin's avatar Maxime Perrotin
parents 16c39e1e 46e62889
......@@ -86,21 +86,25 @@ reads the value from the editor and place it back in the model '''
def __init__(self, oParent=None):
super(TreeDelegate, self).__init__(oParent)
@Slot(QWidget, int)
def update_model(self, editor, index):
#def update_model(editor, index, event):
''' Trigger an immediate update of the model and therefore of the
visible elements of the gui, when user changes a value in the
editor. For example when the CHOICE index changes, this makes sure
that the relevant choice data is updated without gaving to wait
for the user to click outside from the widget '''
# Do not call setModelData directly, it would segfault
# self.setModelData(editor, index.model(), index)
pass
#self.commitData.emit(editor)
def createEditor(self, parent, option, index):
''' Define the delegate (editor) to use for a given cell. This function
is called when the user clicks on a cell.
index.data() returns the actual value, and index.data(role) points
to some user data when role >= 32. 32 is Qt.UserRole. '''
def update_model(editor, index, event):
''' Trigger an immediate update of the model and therefore of the
visible elements of the gui, when user changes a value in the
editor. For example when the CHOICE index changes, this makes sure
that the relevant choice data is updated without gaving to wait
for the user to click outside from the widget '''
# Do not call setModelData directly, it would segfault
# self.setModelData(editor, index.model(), index)
self.commitData.emit(editor)
# Check the (user-defined) type associated with the cell
asnType = index.data(ASN1TYPE)
if asnType == 'INTEGER':
......@@ -119,10 +123,11 @@ reads the value from the editor and place it back in the model '''
minVal = index.data(MIN_RANGE)
maxVal = index.data(MAX_RANGE)
editor.setRange(minVal, maxVal)
editor.valueChanged.connect(partial(update_model, editor, index))
#editor.valueChanged.connect(partial(update_model, editor, index))
elif asnType in ('ENUMERATED', 'CHOICE'):
editor = QComboBox(parent)
editor.activated.connect(partial(update_model, editor, index))
#editor.activated.connect(partial(update_model, editor, index))
editor.activated.connect(partial(self.update_model, editor))
enumVal = index.data(CHOICE_LIST)
for val in enumVal:
editor.addItem(val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment