Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
InterfaceTreeModel Class Reference

A table model representing the system's available capture interfaces. More...

#include <interface_tree_model.h>

Inheritance diagram for InterfaceTreeModel:

Public Slots

void interfaceListChanged ()
 Slot triggered when the global list of available interfaces changes.

Public Member Functions

 InterfaceTreeModel (QObject *parent)
 Constructs a new InterfaceTreeModel.
 ~InterfaceTreeModel ()
 Destroys the InterfaceTreeModel.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows (interfaces) under a given parent.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns in the table model.
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Retrieves data from the model for a given index and role.
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Retrieves the header data for a specific section and role.
void setStatistics (InterfaceStatistics *statistics)
 Sets the statistics provider supplying sparkline/activity data.
QString interfaceError ()
 Retrieves any current interface-related error messages.
QItemSelection selectedDevices ()
 Retrieves the currently selected devices as an item selection.
bool updateSelectedDevices (QItemSelection sourceSelection)
 Updates the internal state of selected devices based on a UI selection.
QVariant getColumnContent (int idx, int col, int role=Qt::DisplayRole)
 Gets the content for a specific column and row directly.

Static Public Attributes

static const QString DefaultNumericValue = QObject::tr("default")

Detailed Description

A table model representing the system's available capture interfaces.

Constructor & Destructor Documentation

◆ InterfaceTreeModel()

InterfaceTreeModel::InterfaceTreeModel ( QObject * parent)

Constructs a new InterfaceTreeModel.

Parameters
parentThe parent QObject.

This is the data model for interface trees. It implies, that the index within global_capture_opts.all_ifaces is identical to the row. This is always the case, even when interfaces are hidden by the proxy model. But for this to work, every access to the index from within the view, has to be filtered through the proxy model.

Member Function Documentation

◆ columnCount()

int InterfaceTreeModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Returns the number of columns in the table model.

Parameters
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
The number of columns.

◆ data()

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

Retrieves data from the model for a given index and role.

Parameters
indexThe model index.
roleThe data role requested (defaults to Qt::DisplayRole).
Returns
The data associated with the index and role.

◆ getColumnContent()

QVariant InterfaceTreeModel::getColumnContent ( int idx,
int col,
int role = Qt::DisplayRole )

Gets the content for a specific column and row directly.

Parameters
idxThe row index.
colThe column index.
roleThe data role (defaults to Qt::DisplayRole).
Returns
The requested data variant.

◆ headerData()

QVariant InterfaceTreeModel::headerData ( int section,
Qt::Orientation orientation,
int role ) const
override

Retrieves the header data for a specific section and role.

Parameters
sectionThe column or row section.
orientationThe orientation of the header.
roleThe data role requested.
Returns
The header data.

◆ interfaceError()

QString InterfaceTreeModel::interfaceError ( )

Retrieves any current interface-related error messages.

Returns
The error message string.

◆ interfaceListChanged

void InterfaceTreeModel::interfaceListChanged ( )
slot

Slot triggered when the global list of available interfaces changes.

The interface list has changed. global_capture_opts.all_ifaces may have been reloaded or changed with current data. beginResetModel() and endResetModel() will signalize the proxy model and the view, that the data has changed and the view has to reload

◆ rowCount()

int InterfaceTreeModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Returns the number of rows (interfaces) under a given parent.

Parameters
parentThe parent model index (defaults to an invalid QModelIndex).
Returns
The number of rows.

◆ selectedDevices()

QItemSelection InterfaceTreeModel::selectedDevices ( )

Retrieves the currently selected devices as an item selection.

Returns
A QItemSelection representing the selected interfaces.

◆ setStatistics()

void InterfaceTreeModel::setStatistics ( InterfaceStatistics * statistics)

Sets the statistics provider supplying sparkline/activity data.

The model does not own it; it reads pointsFor()/isActive() in data() and connects to its update signals to repaint the stats column and re-sort on activity changes. Pass nullptr to detach.

Parameters
statisticsThe interface statistics, or nullptr.

◆ updateSelectedDevices()

bool InterfaceTreeModel::updateSelectedDevices ( QItemSelection sourceSelection)

Updates the internal state of selected devices based on a UI selection.

Parameters
sourceSelectionThe selection from the view.
Returns
True if the selection state changed successfully, false otherwise.

Member Data Documentation

◆ DefaultNumericValue

const QString InterfaceTreeModel::DefaultNumericValue = QObject::tr("default")
static

A default placeholder string for unavailable numeric values.


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