Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Public Attributes | List of all members
TrafficTypesModel Class Reference

List model that exposes all registered traffic-tap protocols with checkable rows, backed by a recent-protocol GList for persistence. More...

#include <traffic_types_list.h>

Inheritance diagram for TrafficTypesModel:

Public Types

enum  { TRAFFIC_PROTOCOL = Qt::UserRole , TRAFFIC_IS_CHECKED }
 Custom Qt::UserRole values for retrieving protocol data from the model. More...
 
enum  { COL_CHECKED , COL_NAME , COL_NUM , COL_PROTOCOL }
 Column indices for the traffic-types table view. More...
 

Public Slots

void selectProtocols (QList< int > protocols)
 Replaces the current selection with the given protocol IDs and emits protocolsChanged().
 

Signals

void protocolsChanged (QList< int > protocols)
 Emitted whenever the set of checked protocols changes.
 

Public Member Functions

 TrafficTypesModel (GList **recentList, QObject *parent=nullptr)
 Constructs the model from the full set of registered tap protocols.
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of protocol rows in the model.
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns in the model.
 
virtual QVariant data (const QModelIndex &idx, int role=Qt::DisplayRole) const override
 Returns data for the given index and role.
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns header labels for the traffic-types columns.
 
virtual bool setData (const QModelIndex &idx, const QVariant &value, int role) override
 Sets data for the given index and role, updating the checked state and emitting protocolsChanged() when the selection changes.
 
virtual Qt::ItemFlags flags (const QModelIndex &idx) const override
 Returns the item flags for the given index.
 
QList< int > protocols () const
 Returns the list of currently checked (selected) protocol IDs.
 

Public Attributes

enum TrafficTypesModel:: { ... }  eTrafficUserData
 Custom Qt::UserRole values for retrieving protocol data from the model.
 
enum TrafficTypesModel:: { ... }  eTrafficColumnNames
 Column indices for the traffic-types table view.
 

Detailed Description

List model that exposes all registered traffic-tap protocols with checkable rows, backed by a recent-protocol GList for persistence.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Custom Qt::UserRole values for retrieving protocol data from the model.

Enumerator
TRAFFIC_PROTOCOL 

Returns the numeric protocol ID.

TRAFFIC_IS_CHECKED 

Returns the checked state as a bool.

◆ anonymous enum

anonymous enum

Column indices for the traffic-types table view.

Enumerator
COL_CHECKED 

Checkbox column indicating whether the protocol is selected.

COL_NAME 

Protocol display name column.

COL_NUM 

Total number of data columns.

COL_PROTOCOL 

Numeric protocol ID column (hidden/internal).

Constructor & Destructor Documentation

◆ TrafficTypesModel()

TrafficTypesModel::TrafficTypesModel ( GList **  recentList,
QObject *  parent = nullptr 
)

Constructs the model from the full set of registered tap protocols.

Parameters
recentListPointer to the recent-protocols GList used to initialise checked states and updated when selections change.
parentOptional parent QObject.

Member Function Documentation

◆ columnCount()

int TrafficTypesModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

Returns the number of columns in the model.

Parameters
parentUnused; must be an invalid index for list models.
Returns
Number of columns (COL_NUM).

◆ data()

QVariant TrafficTypesModel::data ( const QModelIndex &  idx,
int  role = Qt::DisplayRole 
) const
overridevirtual

Returns data for the given index and role.

Parameters
idxModel index of the cell to query.
roleQt item data role (Qt::DisplayRole, Qt::CheckStateRole, UserRole, etc.).
Returns
The requested data, or an invalid QVariant if not applicable.

◆ flags()

Qt::ItemFlags TrafficTypesModel::flags ( const QModelIndex &  idx) const
overridevirtual

Returns the item flags for the given index.

Parameters
idxModel index to query.
Returns
Flags including Qt::ItemIsUserCheckable for checkable rows.

◆ headerData()

QVariant TrafficTypesModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
overridevirtual

Returns header labels for the traffic-types columns.

Parameters
sectionColumn or row index.
orientationQt::Horizontal for column headers; Qt::Vertical for row headers.
roleQt item data role.
Returns
Header label string, or an invalid QVariant if not applicable.

◆ protocols()

QList< int > TrafficTypesModel::protocols ( ) const

Returns the list of currently checked (selected) protocol IDs.

Returns
List of selected protocol IDs.

◆ protocolsChanged

void TrafficTypesModel::protocolsChanged ( QList< int >  protocols)
signal

Emitted whenever the set of checked protocols changes.

Parameters
protocolsUpdated list of selected protocol IDs.

◆ rowCount()

int TrafficTypesModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

Returns the number of protocol rows in the model.

Parameters
parentUnused; must be an invalid index for list models.
Returns
Number of rows.

◆ selectProtocols

void TrafficTypesModel::selectProtocols ( QList< int >  protocols)
slot

Replaces the current selection with the given protocol IDs and emits protocolsChanged().

Parameters
protocolsList of protocol IDs to select.

◆ setData()

bool TrafficTypesModel::setData ( const QModelIndex &  idx,
const QVariant &  value,
int  role 
)
overridevirtual

Sets data for the given index and role, updating the checked state and emitting protocolsChanged() when the selection changes.

Parameters
idxModel index of the cell to modify.
valueNew value to apply.
roleQt item data role; only Qt::CheckStateRole is handled.
Returns
true if the data was successfully set.

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