diff --git a/README.md b/README.md index 3ea0b7a38063a820eb85fb7fe5ad86b2fdfa2999..31d9efbacd25604111d6bff540a51c9e84704ac8 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file CHANGELOG: +1.7.1 - Enable support for optional fields 1.7.0 - Optional fields and fix segfaults when updating CHOICE fields 1.6.9 - Add basic support for optional fields 1.6.7 - Fix CPU usage of polling thread diff --git a/asn1_value_editor/asn1_value_editor.py b/asn1_value_editor/asn1_value_editor.py index 1bb2043eeac057781a482e8a7da63ea0beadb32b..f059a84eddde7d4523566172c200607469187e67 100755 --- a/asn1_value_editor/asn1_value_editor.py +++ b/asn1_value_editor/asn1_value_editor.py @@ -16,7 +16,7 @@ __author__ = "Maxime Perrotin" __license__ = "LGPLv3" -__version__ = "1.7.0" +__version__ = "1.7.1" __url__ = "https://taste.tools" import sys @@ -420,7 +420,7 @@ class asn1Editor(QTreeView): dest.Reset(stateBefore) # Check if field is optional and set the .exist.field # accordingly - field_root = root.child(i) + #field_root = root.child(i) field_name = \ root.child(i, 0).text().replace('-', '_') field_optionality = root.child(i, 4) @@ -428,10 +428,10 @@ class asn1Editor(QTreeView): and field_optionality.isCheckable(): present = field_optionality.checkState() == Qt.Checked print field_name, "SET" if present else "UNSET" - # Uncomment the following when Stubs.py supports it: - #ptr = getattr(dest, "exist") - #ptr = getattr(ptr, field_name) - #ptr.Set (1 if present else 0) + # Set the "exist" value for optional fields + ptr = getattr(dest, "exist") + ptr = getattr(ptr, field_name) + ptr.Set (1 if present else 0) dest.Reset(stateBefore) @@ -574,6 +574,22 @@ class asn1Editor(QTreeView): fillRow(root, i, ptr, seqOf=seqOf) ptr.Reset(stateBefore) + # check if field is optional and set checkbox from value + field_name = \ + root.child(i, 0).text().replace('-', '_') + field_optionality = root.child(i, 4) + if field_optionality.data(OPTIONAL) \ + and field_optionality.isCheckable(): + # Set the "exist" value for optional fields + ptr = getattr(ptr, "exist") + ptr = getattr(ptr, field_name) + present = ptr.Get() + print field_name, field_optionality.data(OPTIONAL), present + field_optionality.setCheckState (Qt.Checked if present + else Qt.Unchecked) + ptr.Reset(stateBefore) + + def updateVariable(self, root=None, asn1Var=None): ''' Update the variable value (when loading a TC or receiving a TM) ''' root = root or self.treeItem