| Wireshark 4.7.3 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 override
| Returns the item flags for the given index.
QModelIndex | index (int row, int, const QModelIndex &parent=QModelIndex()) const override
| Returns the model index for the child at `row` under `parent`.
virtual QModelIndex | parent (const QModelIndex &index) const override
| Returns the parent index of the item at `index`.
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override
| Returns the number of child rows under `parent`.
virtual int | columnCount (const QModelIndex &) const override
| Returns the number of columns (always 1).
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override
| 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.
ProtoNode * | protoNodeFromIndex (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

  parent | Optional parent QObject.

## Member Function Documentation

## ◆ columnCount()

virtual int ProtoTreeModel::columnCount | ( | const QModelIndex & |  | ) | const
| inline override virtual

Returns the number of columns (always 1).

Returns
  1.

## ◆ data()

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

Returns data for the given index and role.

Parameters

  index | Model index of the requested item.
  role | Qt 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

  finfo | FieldInformation 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_id | Wireshark 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
| override virtual

Returns the item flags for the given index.

Parameters

  index | Model 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
| override

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

Parameters

  row | Zero-based child row.
  parent | Parent 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_node | ProtoNode to locate within the tree.

Returns
  Valid model index if found; an invalid index otherwise.

## ◆ parent()

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

Returns the parent index of the item at `index`.

Parameters

  index | Model 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

  index | Model index to resolve.

Returns
  Pointer to the corresponding ProtoNode, or `nullptr` for invalid indices.

## ◆ rowCount()

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

Returns the number of child rows under `parent`.

Parameters

  parent | Parent 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_node | Pointer to the root proto_node, or `nullptr` to clear.

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

- /builds/wireshark/wireshark/ui/qt/models/proto_tree_model.h
- /builds/wireshark/wireshark/ui/qt/models/proto_tree_model.cpp