Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
PacketListModel Class Reference

A Qt item model representing the list of packets in a capture file. More...

#include <packet_list_model.h>

Inheritance diagram for PacketListModel:

Public Types

enum  { HEADER_CAN_DISPLAY_STRINGS = Qt::UserRole , HEADER_CAN_DISPLAY_DETAILS , COLORING_RULE_COLORS }
 Custom roles. More...

Public Slots

void flushNewRows ()
 Inserts the rows for any packets appended since the last flush.

Signals

void packetAppended (capture_file *cap_file, frame_data *fdata, qsizetype row)
 Signal emitted when a packet is successfully appended.

Public Member Functions

 PacketListModel (QObject *parent=0, capture_file *cf=NULL)
 Constructs a new PacketListModel.
 ~PacketListModel ()
 Destroys the PacketListModel.
void setCaptureFile (capture_file *cf)
 Sets the capture file for the model.
capture_file * captureFile () const
 Returns the capture file associated with the model.
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 Returns the index of the item in the model.
QModelIndex parent (const QModelIndex &) const override
 Returns the parent of the model item.
PacketListRecord * physicalRecordForFrameNum (int frame_num) const
 Retrieves the PacketListRecord for a given frame/packet number regardless of whether it currently passes the display filter. This looks the record up directly among physical_rows_ – every packet ever appended, retained permanently in frame-number order, including any not yet inserted as rows (see flushNewRows()) – so callers that need a packet's data independent of the current display filter (e.g. rendering a pinned row that's been filtered out) can still get at it.
PacketListRecord * physicalRecordAt (int row) const
 Retrieves the PacketListRecord at the given row.
bool isEmpty () const
 Returns true if no packets have been appended.
void clear ()
 Clears the model data.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows under the given parent.
int columnCount (const QModelIndex &=QModelIndex()) const override
 Returns the number of columns.
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns the item flags for the given index.
QVariant data (const QModelIndex &d_index, int role) const override
 Returns the data stored under the given role for the specified index.
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns the data for the given role and section in the header.
int appendPacket (frame_data *fdata)
 Appends a packet to the model. The row is inserted the next time flushNewRows() runs, which is scheduled automatically.
void invalidateAllColumnStrings ()
 Invalidate any cached column strings.
void resetColumns ()
 Rebuild columns from settings.
void resetColorized ()
 Resets the colorized state for all rows.
void toggleFrameMark (const QModelIndexList &indices)
 Toggles the mark state for the specified frames.
void setFrameMark (const QVector< PacketListRecord * > &records, bool set)
 Sets the mark state for the given frames.
void toggleFrameIgnore (const QModelIndexList &indices)
 Toggles the ignore state for the specified frames.
void setFrameIgnore (const QVector< PacketListRecord * > &records, bool set)
 Sets the ignore state for the given frames.
void toggleFrameRefTime (const QModelIndexList &indices)
 Toggles the reference time state for the specified frames.
void unsetAllFrameRefTime ()
 Unsets the reference time state for all frames.
void addFrameComment (const QModelIndexList &indices, const QByteArray &comment)
 Adds a comment to the specified frames.
void setFrameComment (const QModelIndex &index, const QByteArray &comment, unsigned c_number)
 Sets a specific comment on a frame.
void deleteFrameComments (const QModelIndexList &indices)
 Deletes comments from the specified frames.
void deleteAllFrameComments ()
 Deletes all frame comments from all frames.

Detailed Description

A Qt item model representing the list of packets in a capture file.

There is one row for every packet appended, in frame number order (so frame N is row N - 1), regardless of the display filter. Filtering and sorting are done by a proxy model such as PacketListProxyModel.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Custom roles.

Enumerator
HEADER_CAN_DISPLAY_STRINGS 

Role indicating if the header can display strings.

HEADER_CAN_DISPLAY_DETAILS 

Role indicating if the header can display details.

COLORING_RULE_COLORS 

Item data: QList<ColoringRuleColors>, the colors the packet is drawn with (ColoringRuleUtils::matchColors()).

Constructor & Destructor Documentation

◆ PacketListModel()

PacketListModel::PacketListModel ( QObject * parent = 0,
capture_file * cf = NULL )
explicit

Constructs a new PacketListModel.

Parameters
parentThe parent QObject, defaults to 0.
cfThe capture file associated with the model, defaults to NULL.

Member Function Documentation

◆ addFrameComment()

void PacketListModel::addFrameComment ( const QModelIndexList & indices,
const QByteArray & comment )

Adds a comment to the specified frames.

Parameters
indicesList of model indices to comment on.
commentThe comment text as a byte array.

◆ appendPacket()

int PacketListModel::appendPacket ( frame_data * fdata)

Appends a packet to the model. The row is inserted the next time flushNewRows() runs, which is scheduled automatically.

Parameters
fdataPointer to the frame data.
Returns
The row index where the packet will be inserted.

◆ captureFile()

capture_file * PacketListModel::captureFile ( ) const
inline

Returns the capture file associated with the model.

Returns
Pointer to the capture file.

◆ columnCount()

int PacketListModel::columnCount ( const QModelIndex & = QModelIndex()) const
override

Returns the number of columns.

Returns
The number of columns.

◆ data()

QVariant PacketListModel::data ( const QModelIndex & d_index,
int role ) const
override

Returns the data stored under the given role for the specified index.

Parameters
d_indexThe model index.
roleThe display role.
Returns
The requested data as a QVariant.

◆ deleteFrameComments()

void PacketListModel::deleteFrameComments ( const QModelIndexList & indices)

Deletes comments from the specified frames.

Parameters
indicesList of model indices to remove comments from.

◆ flags()

Qt::ItemFlags PacketListModel::flags ( const QModelIndex & index) const
override

Returns the item flags for the given index.

Parameters
indexThe model index.
Returns
The item flags.

◆ headerData()

QVariant PacketListModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Returns the data for the given role and section in the header.

Parameters
sectionThe header section.
orientationThe header orientation.
roleThe display role.
Returns
The header data as a QVariant.

◆ index()

QModelIndex PacketListModel::index ( int row,
int column,
const QModelIndex & parent = QModelIndex() ) const
override

Returns the index of the item in the model.

Parameters
rowThe row of the item.
columnThe column of the item.
parentThe parent index, defaults to QModelIndex().
Returns
The model index of the specified item.

◆ packetAppended

void PacketListModel::packetAppended ( capture_file * cap_file,
frame_data * fdata,
qsizetype row )
signal

Signal emitted when a packet is successfully appended.

Parameters
cap_filePointer to the capture file.
fdataPointer to the frame data.
rowThe row index where the packet was added.

◆ parent()

QModelIndex PacketListModel::parent ( const QModelIndex & ) const
override

Returns the parent of the model item.

Returns
The parent model index.

◆ physicalRecordAt()

PacketListRecord * PacketListModel::physicalRecordAt ( int row) const

Retrieves the PacketListRecord at the given row.

Parameters
rowThe row index (the frame number - 1).
Returns
The record, or nullptr if out of range.

◆ physicalRecordForFrameNum()

PacketListRecord * PacketListModel::physicalRecordForFrameNum ( int frame_num) const

Retrieves the PacketListRecord for a given frame/packet number regardless of whether it currently passes the display filter. This looks the record up directly among physical_rows_ – every packet ever appended, retained permanently in frame-number order, including any not yet inserted as rows (see flushNewRows()) – so callers that need a packet's data independent of the current display filter (e.g. rendering a pinned row that's been filtered out) can still get at it.

Parameters
frame_numThe frame/packet number.
Returns
The record, or nullptr if out of range.

◆ rowCount()

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

Returns the number of rows under the given parent.

Parameters
parentThe parent model index.
Returns
The number of rows.

◆ setCaptureFile()

void PacketListModel::setCaptureFile ( capture_file * cf)

Sets the capture file for the model.

Parameters
cfPointer to the capture file.

◆ setFrameComment()

void PacketListModel::setFrameComment ( const QModelIndex & index,
const QByteArray & comment,
unsigned c_number )

Sets a specific comment on a frame.

Parameters
indexThe model index of the frame.
commentThe comment text.
c_numberThe comment number index.

◆ setFrameIgnore()

void PacketListModel::setFrameIgnore ( const QVector< PacketListRecord * > & records,
bool set )

Sets the ignore state for the given frames.

Parameters
recordsThe records of the frames to change.
setTrue to ignore, false to un-ignore.

◆ setFrameMark()

void PacketListModel::setFrameMark ( const QVector< PacketListRecord * > & records,
bool set )

Sets the mark state for the given frames.

Parameters
recordsThe records of the frames to change.
setTrue to mark, false to unmark.

◆ toggleFrameIgnore()

void PacketListModel::toggleFrameIgnore ( const QModelIndexList & indices)

Toggles the ignore state for the specified frames.

Parameters
indicesList of model indices to toggle.

◆ toggleFrameMark()

void PacketListModel::toggleFrameMark ( const QModelIndexList & indices)

Toggles the mark state for the specified frames.

Parameters
indicesList of model indices to toggle.

◆ toggleFrameRefTime()

void PacketListModel::toggleFrameRefTime ( const QModelIndexList & indices)

Toggles the reference time state for the specified frames.

Parameters
indicesList of model indices to toggle

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