Commit f7f7af90 authored by Maxime Perrotin's avatar Maxime Perrotin

Ensure compatibility with old versions of DMT

parent 4fc5fb50
......@@ -908,11 +908,13 @@ class asn1Editor(QTreeView):
constraint = QStandardItem('(%d..%d)' % (elem["minR"], elem["maxR"]))
constraint.setData(QBrush(QColor("gray")), Qt.ForegroundRole)
present = QStandardItem()
present.setData (elem.get('isOptional', False), OPTIONAL)
present.setData (elem.get('alwaysPresent', True), ALWAYS_PRESENT)
present.setData (elem.get('alwaysAbsent', False), ALWAYS_ABSENT)
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
if isOptional and not alwaysPresent and not alwaysAbsent:
# add a checkbox for optionals which presence is not forced
present.setCheckState(Qt.Checked)
present.setCheckable(True)
......@@ -936,8 +938,10 @@ class asn1Editor(QTreeView):
constraint = QStandardItem('(%.2f..%.2f)' % (elem["minR"], elem["maxR"]))
constraint.setData(QBrush(QColor("gray")), Qt.ForegroundRole)
present = QStandardItem()
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
present.setData (elem['isOptional'], OPTIONAL)
......@@ -988,13 +992,15 @@ class asn1Editor(QTreeView):
constraint = QStandardItem(constraintStr)
constraint.setData(QBrush(QColor("gray")), Qt.ForegroundRole)
present = QStandardItem()
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
present.setData (elem['isOptional'], OPTIONAL)
present.setData (elem['alwaysPresent'], ALWAYS_PRESENT)
present.setData (elem['alwaysAbsent'], ALWAYS_ABSENT)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
return {"value": val, "constraint": constraint, "present": present}
def addBool(self, elem):
......@@ -1005,13 +1011,15 @@ class asn1Editor(QTreeView):
val.setData(['True', 'False'], CHOICE_LIST) # enum values
constraint = QStandardItem()
present = QStandardItem()
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
present.setData (elem['isOptional'], OPTIONAL)
present.setData (elem['alwaysPresent'], ALWAYS_PRESENT)
present.setData (elem['alwaysAbsent'], ALWAYS_ABSENT)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
return {"value": val, "constraint": constraint, "present": present}
def addSequence(self, elem, parent):
......@@ -1036,13 +1044,15 @@ class asn1Editor(QTreeView):
constraint = QStandardItem()
val = QStandardItem()
present = QStandardItem()
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
present.setData (elem['isOptional'], OPTIONAL)
present.setData (elem['alwaysPresent'], ALWAYS_PRESENT)
present.setData (elem['alwaysAbsent'], ALWAYS_ABSENT)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
return {"value": val, "constraint": constraint, "present": present}
def addSeqOf(self, elem, parent):
......@@ -1075,11 +1085,13 @@ class asn1Editor(QTreeView):
val.setData(elem["minSize"], MIN_RANGE) # min number of elements
val.setData(elem["maxSize"], MAX_RANGE) # max number of elements
present = QStandardItem()
present.setData (elem['isOptional'], OPTIONAL)
present.setData (elem['alwaysPresent'], ALWAYS_PRESENT)
present.setData (elem['alwaysAbsent'], ALWAYS_ABSENT)
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
return {"value": val, "constraint": constraint, "present": present}
......@@ -1112,13 +1124,15 @@ class asn1Editor(QTreeView):
val.setData(elem["choiceIdx"], INTMAP) # mapping name - DV value
constraint = QStandardItem()
present = QStandardItem()
if elem['isOptional'] and not elem['alwaysPresent'] \
and not elem['alwaysAbsent']:
isOptional = elem.get('isOptional', False)
alwaysPresent = elem.get('alwaysPresent', True)
alwaysAbsent = elem.get('alwaysAbsent', False)
if isOptional and not alwaysPresent and not alwaysAbsent:
present.setCheckState (Qt.Checked)
present.setCheckable(True)
present.setData (elem['isOptional'], OPTIONAL)
present.setData (elem['alwaysPresent'], ALWAYS_PRESENT)
present.setData (elem['alwaysAbsent'], ALWAYS_ABSENT)
present.setData (isOptional, OPTIONAL)
present.setData (alwaysPresent, ALWAYS_PRESENT)
present.setData (alwaysAbsent, ALWAYS_ABSENT)
return {"value": val, "constraint": constraint, "present": present}
def addItem(self, elem):
......
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