Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ProtoTreeModel Class Reference

Item model that exposes a libwireshark proto_node tree to Qt views, enabling the packet-details tree to be driven by standard Qt model/view architecture. More...

#include <proto_tree_model.h>

Inheritance diagram for ProtoTreeModel:

Public Member Functions

 ProtoTreeModel (QObject *parent=0)
 Constructs an empty ProtoTreeModel with no root node.
 
 ~ProtoTreeModel ()
 Destroys the model. Does not free the underlying proto_node tree.
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for the given index.
 
QModelIndex index (int row, int, const QModelIndex &parent=QModelIndex()) const
 Returns the model index for the child at row under parent.
 
virtual QModelIndex parent (const QModelIndex &index) const
 Returns the parent index of the item at index.
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of child rows under parent.
 
virtual int columnCount (const QModelIndex &) const
 Returns the number of columns (always 1).
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Returns data for the given index and role.
 
void setRootNode (proto_node *root_node)
 Sets the root node of the proto_node tree exposed by this model.
 
ProtoNodeprotoNodeFromIndex (const QModelIndex &index) const
 Returns the ProtoNode wrapper for the item at the given model index.
 
QModelIndex indexFromProtoNode (ProtoNode *index_node) const
 Returns the model index corresponding to the given ProtoNode.
 
QModelIndex findFirstHfid (int hf_id)
 Searches the tree for the first node whose header-field ID matches hf_id.
 
QModelIndex findFieldInformation (FieldInformation *finfo)
 Searches the tree for the node that corresponds to the given FieldInformation.
 

Detailed Description

Item model that exposes a libwireshark proto_node tree to Qt views, enabling the packet-details tree to be driven by standard Qt model/view architecture.

Constructor & Destructor Documentation

◆ ProtoTreeModel()

ProtoTreeModel::ProtoTreeModel ( QObject *  parent = 0)
explicit

Constructs an empty ProtoTreeModel with no root node.

Parameters
parentOptional parent QObject.

Member Function Documentation

◆ columnCount()

virtual int ProtoTreeModel::columnCount ( const QModelIndex &  ) const
inlinevirtual

Returns the number of columns (always 1).

Returns
1.

◆ data()

QVariant ProtoTreeModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Returns data for the given index and role.

Parameters
indexModel index of the requested item.
roleQt item data role (e.g. Qt::DisplayRole).
Returns
QVariant with the requested data, or an invalid QVariant if unavailable.

◆ findFieldInformation()

QModelIndex ProtoTreeModel::findFieldInformation ( FieldInformation finfo)

Searches the tree for the node that corresponds to the given FieldInformation.

Parameters
finfoFieldInformation instance to locate.
Returns
Model index of the matching node, or an invalid index if not found.

◆ findFirstHfid()

QModelIndex ProtoTreeModel::findFirstHfid ( int  hf_id)

Searches the tree for the first node whose header-field ID matches hf_id.

Parameters
hf_idWireshark header-field ID (hf_register_info index) to find.
Returns
Model index of the first matching node, or an invalid index if not found.

◆ flags()

Qt::ItemFlags ProtoTreeModel::flags ( const QModelIndex &  index) const
virtual

Returns the item flags for the given index.

Parameters
indexModel index to query.
Returns
Qt::ItemIsEnabled | Qt::ItemIsSelectable for valid indices; Qt::NoItemFlags otherwise.

◆ index()

QModelIndex ProtoTreeModel::index ( int  row,
int  ,
const QModelIndex &  parent = QModelIndex() 
) const

Returns the model index for the child at row under parent.

Parameters
rowZero-based child row.
parentParent index; an invalid index refers to the root.
Returns
Model index for the requested child, or an invalid index if out of range.

◆ indexFromProtoNode()

QModelIndex ProtoTreeModel::indexFromProtoNode ( ProtoNode index_node) const

Returns the model index corresponding to the given ProtoNode.

Parameters
index_nodeProtoNode to locate within the tree.
Returns
Valid model index if found; an invalid index otherwise.

◆ parent()

QModelIndex ProtoTreeModel::parent ( const QModelIndex &  index) const
virtual

Returns the parent index of the item at index.

Parameters
indexModel index whose parent is requested.
Returns
Parent model index, or an invalid index if index is a top-level item.

◆ protoNodeFromIndex()

ProtoNode * ProtoTreeModel::protoNodeFromIndex ( const QModelIndex &  index) const

Returns the ProtoNode wrapper for the item at the given model index.

Parameters
indexModel index to resolve.
Returns
Pointer to the corresponding ProtoNode, or nullptr for invalid indices.

◆ rowCount()

int ProtoTreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Returns the number of child rows under parent.

Parameters
parentParent index; an invalid index refers to the root.
Returns
Number of direct children, or 0 if parent has no children.

◆ setRootNode()

void ProtoTreeModel::setRootNode ( proto_node root_node)

Sets the root node of the proto_node tree exposed by this model.

Resets the model and notifies all attached views. Passing nullptr clears the model.

Parameters
root_nodePointer to the root proto_node, or nullptr to clear.

The documentation for this class was generated from the following files: