DBC Framework
DBC parsing and CAN signal decoding framework
Loading...
Searching...
No Matches
dbc_tree_model.h
1// SPDX-License-Identifier: MIT
2#ifndef DBC_TREE_MODEL_H
3#define DBC_TREE_MODEL_H
4
5#include "tree_node.h"
6#include <QAbstractItemModel>
7
11class DbcTreeModel : public QAbstractItemModel {
12public:
13 enum Column { Name,
14 CanId,
15 PayloadLength,
16 StartBit,
17 BitLength,
19 Signed,
20 Unit,
21 Comment,
22 ColumnCount };
23 // Metadata roles apply on every column; inapplicable roles return invalid QVariant.
24 enum Role { NodeTypeRole = Qt::UserRole + 1,
25 CanIdRole,
26 PayloadLengthRole,
27 StartBitRole,
28 BitLengthRole,
29 LittleEndianRole,
30 SignedRole,
31 UnitRole,
32 CommentRole,
33 ValueDescriptionsRole,
34 ExtendedRole };
35
36 explicit DbcTreeModel(QObject *parent = nullptr);
37 void SetTree(std::unique_ptr<TreeNode> root);
38 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
39 QModelIndex parent(const QModelIndex &child) const override;
40 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
41 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
42 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
43 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
44 Qt::ItemFlags flags(const QModelIndex &index) const override;
45
46private:
47 const TreeNode *Node(const QModelIndex &index) const;
48 std::unique_ptr<TreeNode> m_root;
49};
50#endif
Tree node for later use in model/view or other hierarchy consumers.
Definition tree_node.h:35
ByteOrder
Signal byte order used for runtime decoding.
Created: 2026-03-13 Author: Deeaitch (Dim. Himro)