Add TreeNode parent navigation and a Qt model adapter #9

Closed
opened 2026-10-05 22:49:13 +00:00 by deeaitch · 0 comments
Owner

Add TreeNode parent navigation and a Qt model adapter

Description

Expose the existing DBC tree through Qt Model/View so FrameTap can browse frames and signals using standard Qt views. Add parent navigation to TreeNode and implement a separate Qt adapter while keeping the parser, metadata, tree builder, and decoder independent of Qt.

Scope

  • Add a non-owning parent pointer to TreeNode, with a null parent for the root.
  • Set the parent when a child is added; retain exclusive child ownership through std::unique_ptr.
  • Provide the child-position information needed to construct a Qt parent index reliably.
  • Implement a read-only QAbstractItemModel adapter for the root/frame/signal hierarchy.
  • Implement index(), parent(), rowCount(), columnCount(), data(), headerData(), and flags() with consistent handling of invalid indexes.
  • Treat the tree root as an invisible model root; top-level model rows represent frames and their children represent signals.
  • Display useful metadata such as name, CAN ID, payload length, signal bit layout, unit, and comments through documented columns and roles.
  • Expose VAL_ descriptions when available, using the shared signal metadata.
  • Define tree ownership and lifetime explicitly so indexes cannot reference destroyed nodes.
  • Support replacing the loaded tree using Qt model reset notifications.
  • Add optional Qt build integration without adding Qt dependencies to the existing core or standalone core tests.

Acceptance criteria

  • Root, frame, and signal nodes report correct parent relationships and sibling positions.
  • A Qt tree view can browse all frames and signals from a parsed DBC file.
  • index() and parent() remain consistent for all levels, columns, and invalid indexes.
  • Display columns and metadata roles are documented and return appropriate values for each node type.
  • Reloading or clearing the database resets the model safely.
  • Model behavior is verified with QAbstractItemModelTester and focused tests for parent navigation and tree replacement.
  • Existing core builds and parser/decoder tests continue to work without Qt.
  • README includes build instructions and a minimal adapter usage example.

Out of scope

Editing DBC files, live value updates, plotting, drag-and-drop subscriptions, selective decoding, and a complete FrameTap application UI.

Dependency

The VAL_ support issue provides value-description metadata. Basic tree browsing does not require it.

# Add TreeNode parent navigation and a Qt model adapter ## Description Expose the existing DBC tree through Qt Model/View so FrameTap can browse frames and signals using standard Qt views. Add parent navigation to `TreeNode` and implement a separate Qt adapter while keeping the parser, metadata, tree builder, and decoder independent of Qt. ## Scope - Add a non-owning parent pointer to `TreeNode`, with a null parent for the root. - Set the parent when a child is added; retain exclusive child ownership through `std::unique_ptr`. - Provide the child-position information needed to construct a Qt parent index reliably. - Implement a read-only `QAbstractItemModel` adapter for the root/frame/signal hierarchy. - Implement `index()`, `parent()`, `rowCount()`, `columnCount()`, `data()`, `headerData()`, and `flags()` with consistent handling of invalid indexes. - Treat the tree root as an invisible model root; top-level model rows represent frames and their children represent signals. - Display useful metadata such as name, CAN ID, payload length, signal bit layout, unit, and comments through documented columns and roles. - Expose `VAL_` descriptions when available, using the shared signal metadata. - Define tree ownership and lifetime explicitly so indexes cannot reference destroyed nodes. - Support replacing the loaded tree using Qt model reset notifications. - Add optional Qt build integration without adding Qt dependencies to the existing core or standalone core tests. ## Acceptance criteria - [ ] Root, frame, and signal nodes report correct parent relationships and sibling positions. - [ ] A Qt tree view can browse all frames and signals from a parsed DBC file. - [ ] `index()` and `parent()` remain consistent for all levels, columns, and invalid indexes. - [ ] Display columns and metadata roles are documented and return appropriate values for each node type. - [ ] Reloading or clearing the database resets the model safely. - [ ] Model behavior is verified with `QAbstractItemModelTester` and focused tests for parent navigation and tree replacement. - [ ] Existing core builds and parser/decoder tests continue to work without Qt. - [ ] README includes build instructions and a minimal adapter usage example. ## Out of scope Editing DBC files, live value updates, plotting, drag-and-drop subscriptions, selective decoding, and a complete FrameTap application UI. ## Dependency The `VAL_` support issue provides value-description metadata. Basic tree browsing does not require it.
deeaitch referenced this issue from a commit 2026-10-06 21:18:03 +00:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: automotive/dbc#9