diff --git a/asn1_value_editor/asn1_value_editor.py b/asn1_value_editor/asn1_value_editor.py index b6108caca370c0e0fb03a1cfdc1e336fa066d968..1bb2043eeac057781a482e8a7da63ea0beadb32b 100755 --- a/asn1_value_editor/asn1_value_editor.py +++ b/asn1_value_editor/asn1_value_editor.py @@ -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)