Wireshark 4.7.3
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:
33 explicit ProtoTreeModel(QObject *parent = 0);
34
39
46 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
47
54 QModelIndex index(int row, int, const QModelIndex &parent = QModelIndex()) const override;
55
61 virtual QModelIndex parent(const QModelIndex &index) const override;
62
68 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
69
74 virtual int columnCount(const QModelIndex &) const override{ return 1; }
75
82 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
83
92 void setRootNode(proto_node *root_node);
93
99 ProtoNode *protoNodeFromIndex(const QModelIndex &index) const;
100
106 QModelIndex indexFromProtoNode(ProtoNode *index_node) const;
107
113 QModelIndex findFirstHfid(int hf_id);
114
120 QModelIndex findFieldInformation(FieldInformation *finfo);
121
122private:
123 ProtoNode *root_node_;
124
132 static bool foreachFindHfid(ProtoNode *node, void *find_hfid_ptr);
133
141 static bool foreachFindField(ProtoNode *node, void *find_finfo_ptr);
142};
143
144#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
void setRootNode(proto_node *root_node)
Sets the root node of the proto_node tree exposed by this model.
Definition proto_tree_model.cpp:183
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent.
Definition proto_tree_model.cpp:77
QModelIndex findFirstHfid(int hf_id)
Searches the tree for the first node whose header-field ID matches hf_id.
Definition proto_tree_model.cpp:239
~ProtoTreeModel()
Destroys the model. Does not free the underlying proto_node tree.
Definition proto_tree_model.cpp:33
ProtoTreeModel(QObject *parent=0)
Constructs an empty ProtoTreeModel with no root node.
Definition proto_tree_model.cpp:27
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:91
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition proto_tree_model.cpp:38
virtual int columnCount(const QModelIndex &) const override
Returns the number of columns (always 1).
Definition proto_tree_model.h:74
QModelIndex indexFromProtoNode(ProtoNode *index_node) const
Returns the model index corresponding to the given ProtoNode.
Definition proto_tree_model.cpp:202
ProtoNode * protoNodeFromIndex(const QModelIndex &index) const
Returns the ProtoNode wrapper for the item at the given model index.
Definition proto_tree_model.cpp:197
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:48
QModelIndex findFieldInformation(FieldInformation *finfo)
Searches the tree for the node that corresponds to the given FieldInformation.
Definition proto_tree_model.cpp:274
virtual QModelIndex parent(const QModelIndex &index) const override
Returns the parent index of the item at index.
Definition proto_tree_model.cpp:68
struct _proto_node proto_node