You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DataItem.choices attribute contains a list of tuple containing key value pairs (list[tuple[str, str]] in most cases). When we need a value, we parse this list to find the corresponding key. However, there are some instances where we parse the list and check the values to get the corresponding keys. This is a problem when several keys point to duplicate values (e.g. two projects of the same name) as we never check for duplicate value. This behavior also prevents the addition of new color that would have the same first letter.
The root of the issue is located in the DataItem.from_text, DataItem.to_text and DataItem.from_display.
Proposed improvements/solutions could be:
Replace the list of tuples by a dictionnary which would improve readability, ergonomy and (maybe) speed
Decoralate the displayed values from the actual values, by example by removing/modifying DataItem.from_display
Decorelate the displayed values from the xml values. For example, for a MULTIPLE_CHOICE data item, the method DataItem.to_text is called both to set the display value and the value to write in the XML. This method returns the choices values instead of the keys which forces us to match the values to get back the keys when reopening the XML file.
The text was updated successfully, but these errors were encountered:
Fix : change type to dict, that are more suitable for CHOICE/MULTIPLE_CHOICE structure and allows duplicates values.
Choices made by user stays as unique key lists, as communication with Qt controls via existing properties and cast functions.
The
DataItem.choices
attribute contains a list of tuple containing key value pairs (list[tuple[str, str]]
in most cases). When we need a value, we parse this list to find the corresponding key. However, there are some instances where we parse the list and check the values to get the corresponding keys. This is a problem when several keys point to duplicate values (e.g. two projects of the same name) as we never check for duplicate value. This behavior also prevents the addition of new color that would have the same first letter.The root of the issue is located in the
DataItem.from_text
,DataItem.to_text
andDataItem.from_display
.Proposed improvements/solutions could be:
DataItem.from_display
DataItem.to_text
is called both to set the display value and the value to write in the XML. This method returns the choices values instead of the keys which forces us to match the values to get back the keys when reopening the XML file.The text was updated successfully, but these errors were encountered: