Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
proto_tree_model.h
Go to the documentation of this file.
1
9
10#ifndef PROTO_TREE_MODEL_H
11#define PROTO_TREE_MODEL_H
12
15
16#include <QAbstractItemModel>
17#include <QModelIndex>
18
24class ProtoTreeModel : public QAbstractItemModel
25{
26 Q_OBJECT
27
28public:
32 enum {
35 ColoringRuleEntryRole = Qt::UserRole,
36 };
37
42 explicit ProtoTreeModel(QObject *parent = 0);
43
48
55 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
56
63 QModelIndex index(int row, int, const QModelIndex &parent = QModelIndex()) const override;
64
70 virtual QModelIndex parent(const QModelIndex &index) const override;
71
77 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
78
83 virtual int columnCount(const QModelIndex &) const override{ return 1; }
84
91 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
92
101 void setRootNode(proto_node *root_node);
102
108 ProtoNode *protoNodeFromIndex(const QModelIndex &index) const;
109
115 QModelIndex indexFromProtoNode(ProtoNode *index_node) const;
116
122 QModelIndex findFirstHfid(int hf_id);
123
129 QModelIndex findFieldInformation(FieldInformation *finfo);
130
131private:
132 ProtoNode *root_node_;
133
141 static bool foreachFindHfid(ProtoNode *node, void *find_hfid_ptr);
142
150 static bool foreachFindField(ProtoNode *node, void *find_finfo_ptr);
151};
152
153#endif // PROTO_TREE_MODEL_H
Represents information about a dissected packet field.
Definition field_information.h:26
A wrapper class for the core proto_node structure, providing tree traversal and data access.
Definition proto_node.h:24
@ ColoringRuleEntryRole
Definition proto_tree_model.h:35
void setRootNode(proto_node *root_node)
Sets the root node of the proto_node tree exposed by this model.
Definition proto_tree_model.cpp:201
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent.
Definition proto_tree_model.cpp:78
QModelIndex findFirstHfid(int hf_id)
Searches the tree for the first node whose header-field ID matches hf_id.
Definition proto_tree_model.cpp:257
~ProtoTreeModel()
Destroys the model. Does not free the underlying proto_node tree.
Definition proto_tree_model.cpp:34
ProtoTreeModel(QObject *parent=0)
Constructs an empty ProtoTreeModel with no root node.
Definition proto_tree_model.cpp:28
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
Definition proto_tree_model.cpp:92
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition proto_tree_model.cpp:39
virtual int columnCount(const QModelIndex &) const override
Returns the number of columns (always 1).
Definition proto_tree_model.h:83
QModelIndex indexFromProtoNode(ProtoNode *index_node) const
Returns the model index corresponding to the given ProtoNode.
Definition proto_tree_model.cpp:220
ProtoNode * protoNodeFromIndex(const QModelIndex &index) const
Returns the ProtoNode wrapper for the item at the given model index.
Definition proto_tree_model.cpp:215
QModelIndex index(int row, int, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the child at row under parent.
Definition proto_tree_model.cpp:49
QModelIndex findFieldInformation(FieldInformation *finfo)
Searches the tree for the node that corresponds to the given FieldInformation.
Definition proto_tree_model.cpp:292
virtual QModelIndex parent(const QModelIndex &index) const override
Returns the parent index of the item at index.
Definition proto_tree_model.cpp:69
struct _proto_node proto_node