[feat] Add support for optional field #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR split from #72
Originally created for issue #68


Here's before:
After:
This pull request enhances the handling of optional fields in the
TopicTableModelto properly support and display fields that are not present in the data. The changes ensure that optional fields are visually distinguished, cannot be edited when absent, and are handled consistently throughout the data model. Additionally, a new test message with optional fields was added for testing.The most important changes are:
Optional Field Handling and UI Behavior:
notPresentflag toDataRowinTopicTableModelto track if an optional field is absent, along with getter and setter methods (getNotPresent,setNotPresent) and proper initialization. (src/topic_table_model.h,src/topic_table_model.cpp) [1] [2] [3] [4]flagsandsetDatamethods to prevent editing of fields that are not present, ensuring the UI disables editing for such fields. (src/topic_table_model.cpp) [1] [2]datamethod, styled non-present fields in the value column to display "(not present)" in grey text, improving user feedback. (src/topic_table_model.cpp)Data Model Logic Improvements:
setDataRowto set thenotPresentflag for missing optional fields and clear it when a value is present, using a new helper lambda for consistency across types. (src/topic_table_model.cpp)notPresentflag when a value is set viasetValue, ensuring correct state after user edits. (src/topic_table_model.cpp)Testing and Type Support:
OptionalFieldsMessagestruct with optional fields totest/test.idlto enable testing of the new logic. (test/test.idl)Other:
thirdparty/OpenDDW)These changes collectively improve the robustness and user experience of the data table when dealing with optional fields in topic data.