Wireshark 4.7.4
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 }
 Custom roles used for header data. More...

Public Slots

void sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override
 Sorts the model based on the specified column.
void stopSorting ()
 Stops an ongoing sorting operation.
void flushVisibleRows ()
 Flushes the newly visible rows into the main visible rows view.
void dissectIdle (bool reset=false)
 Performs dissection work during application idle time.

Signals

void packetAppended (capture_file *cap_file, frame_data *fdata, qsizetype row)
 Signal emitted when a packet is successfully appended.
void goToPacket (int packet_num)
 Signal emitted to navigate the view to a specific packet number.
void bgColorizationProgress (int first, int last)
 Signal emitted to report background colorization progress.

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.
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.
int packetNumberToRow (int packet_num) const
 Converts a packet number to a row index.
PacketListRecordphysicalRecordForFrameNum (int frame_num) const
 Retrieves the PacketListRecord for a given frame/packet number regardless of whether it currently passes the display filter. Unlike packetNumberToRow()/index(), which only ever resolve to a row among visible_rows_ (i.e. filtered-in packets), this looks the record up directly among physical_rows_ – every packet ever appended, retained permanently in frame-number order – 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.
unsigned recreateVisibleRows ()
 Recreates the list of visible rows based on filters and state.
void needRecreateVisibleRows ()
 Flags the model as needing to recreate its visible rows.
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 dataForFrameNum (int frame_num, int column, int role) const
 Returns the same data data() would for a real, currently visible row, but for any frame/packet number that was ever appended, regardless of the current display filter – see physicalRecordForFrameNum(). Used by PinnedRowsModel so pinned packets keep showing their data even after being filtered out.
bool pinnedRecordLessThan (int frame_num_a, int frame_num_b) const
 Orders two frame/packet numbers the same way the primary view's current sort would, regardless of whether either currently passes the display filter.
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.
frame_datagetRowFdata (QModelIndex idx) const
 Retrieves the frame data for a given model index.
frame_datagetRowFdata (int row) const
 Retrieves the frame data for a given row.
void ensureRowColorized (int row)
 Ensures that a specific row has been colorized.
int visibleIndexOf (const frame_data *fdata) const
 Returns the visible index of the given frame data.
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 &indeces)
 Toggles the mark state for the specified frames.
void setDisplayedFrameMark (bool set)
 Sets the mark state for all currently displayed frames.
void toggleFrameIgnore (const QModelIndexList &indeces)
 Toggles the ignore state for the specified frames.
void setDisplayedFrameIgnore (bool set)
 Sets the ignore state for all currently displayed frames.
void toggleFrameRefTime (const QModelIndex &rt_index)
 Toggles the reference time state for a specified frame.
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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Custom roles used for header data.

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.

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.

Parameters
fdataPointer to the frame data.
Returns
The row index where the packet was appended.

◆ bgColorizationProgress

void PacketListModel::bgColorizationProgress ( int first,
int last )
signal

Signal emitted to report background colorization progress.

Parameters
firstThe first row processed.
lastThe last row processed.

◆ 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.

◆ dataForFrameNum()

QVariant PacketListModel::dataForFrameNum ( int frame_num,
int column,
int role ) const

Returns the same data data() would for a real, currently visible row, but for any frame/packet number that was ever appended, regardless of the current display filter – see physicalRecordForFrameNum(). Used by PinnedRowsModel so pinned packets keep showing their data even after being filtered out.

Parameters
frame_numThe frame/packet number.
columnThe column index.
roleThe display role.
Returns
The requested data as a QVariant, or an invalid QVariant if frame_num is unknown.

◆ deleteFrameComments()

void PacketListModel::deleteFrameComments ( const QModelIndexList & indices)

Deletes comments from the specified frames.

Parameters
indicesList of model indices to remove comments from.

◆ dissectIdle

void PacketListModel::dissectIdle ( bool reset = false)
slot

Performs dissection work during application idle time.

Parameters
resetTrue to reset the idle dissection state.

◆ ensureRowColorized()

void PacketListModel::ensureRowColorized ( int row)

Ensures that a specific row has been colorized.

Parameters
rowThe row index to colorize.

◆ 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.

◆ getRowFdata() [1/2]

frame_data * PacketListModel::getRowFdata ( int row) const

Retrieves the frame data for a given row.

Parameters
rowThe row index.
Returns
Pointer to the frame data.

◆ getRowFdata() [2/2]

frame_data * PacketListModel::getRowFdata ( QModelIndex idx) const

Retrieves the frame data for a given model index.

Parameters
idxThe model index.
Returns
Pointer to the frame data.

◆ goToPacket

void PacketListModel::goToPacket ( int packet_num)
signal

Signal emitted to navigate the view to a specific packet number.

Parameters
packet_numThe target packet number.

◆ 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.

◆ packetNumberToRow()

int PacketListModel::packetNumberToRow ( int packet_num) const

Converts a packet number to a row index.

Parameters
packet_numThe packet number.
Returns
The corresponding row index.

◆ parent()

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

Returns the parent of the model item.

Returns
The parent model index.

◆ 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. Unlike packetNumberToRow()/index(), which only ever resolve to a row among visible_rows_ (i.e. filtered-in packets), this looks the record up directly among physical_rows_ – every packet ever appended, retained permanently in frame-number order – 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.

◆ pinnedRecordLessThan()

bool PacketListModel::pinnedRecordLessThan ( int frame_num_a,
int frame_num_b ) const

Orders two frame/packet numbers the same way the primary view's current sort would, regardless of whether either currently passes the display filter.

Used by PinnedRowsModel::refresh() so pinned packets that have been filtered out still sort into their natural position relative to the visible ones (by frame number if unsorted, or by whatever column/order the user last sorted by) instead of always landing after every visible pinned packet – packetNumberToRow() (the previous approach) returns -1 for a filtered-out packet, which can't express a real ordering relative to visible ones.

Deliberately does not reuse the private, static recordLessThan() used by sort(): that comparator's side effects (progress bar updates, a busy-timeout check, throwing SortAbort) only make sense for a full bulk sort, not a handful of comparisons here. It also assumes an active sort has already set sort_cap_file_ etc., which isn't true until the user has explicitly sorted at least once, so this falls back to plain frame-number order in that case (which happens to match the model's own natural, unsorted order anyway).

Parameters
frame_num_aFirst frame/packet number.
frame_num_bSecond frame/packet number.
Returns
True if frame_num_a sorts before frame_num_b.

◆ recreateVisibleRows()

unsigned PacketListModel::recreateVisibleRows ( )

Recreates the list of visible rows based on filters and state.

Returns
The number of visible rows.

◆ 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.

◆ setDisplayedFrameIgnore()

void PacketListModel::setDisplayedFrameIgnore ( bool set)

Sets the ignore state for all currently displayed frames.

Parameters
setTrue to ignore, false to un-ignore.

◆ setDisplayedFrameMark()

void PacketListModel::setDisplayedFrameMark ( bool set)

Sets the mark state for all currently displayed frames.

Parameters
setTrue to mark, false to unmark.

◆ 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.

◆ sort

void PacketListModel::sort ( int column,
Qt::SortOrder order = Qt::AscendingOrder )
overrideslot

Sorts the model based on the specified column.

Parameters
columnThe column index to sort by.
orderThe sort order (ascending or descending).

◆ toggleFrameIgnore()

void PacketListModel::toggleFrameIgnore ( const QModelIndexList & indeces)

Toggles the ignore state for the specified frames.

Parameters
indecesList of model indices to toggle.

◆ toggleFrameMark()

void PacketListModel::toggleFrameMark ( const QModelIndexList & indeces)

Toggles the mark state for the specified frames.

Parameters
indecesList of model indices to toggle.

◆ toggleFrameRefTime()

void PacketListModel::toggleFrameRefTime ( const QModelIndex & rt_index)

Toggles the reference time state for a specified frame.

Parameters
rt_indexThe model index of the frame.

◆ visibleIndexOf()

int PacketListModel::visibleIndexOf ( const frame_data * fdata) const

Returns the visible index of the given frame data.

Parameters
fdataPointer to the frame data.
Returns
The visible index.

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