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

A proxy model exposing the packets of a PacketListModel that pass the display filter, in the currently selected sort order. More...

#include <packet_list_proxy_model.h>

Inheritance diagram for PacketListProxyModel:

Public Types

enum class  HiddenReason { Shown , FilteredOut , Aggregated }

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 ()
 Inserts any packets appended to the source model since the last update, and the visible ones among them into this model.
void dissectIdle (bool reset=false)
 Performs dissection work during application idle time.

Signals

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

 PacketListProxyModel (QObject *parent=nullptr)
 Constructs a new PacketListProxyModel.
 ~PacketListProxyModel ()
 Destroys the PacketListProxyModel.
PacketListModel * packetListModel () const
 The source model, if it is a PacketListModel.
int packetNumberToRow (int packet_num) const
 Converts a packet number to a row index.
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.
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.
frame_data * getRowFdata (QModelIndex idx) const
 Retrieves the frame data for a given model index.
frame_data * getRowFdata (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.
int rowOfPacket (const frame_data *fdata) const
 Returns the row showing the given packet itself.
HiddenReason hiddenReason (const frame_data *fdata) const
 Returns why the given packet has no row of its own, if it doesn't.
void setDisplayedFrameMark (bool set)
 Sets the mark state for all currently displayed frames.
void setDisplayedFrameIgnore (bool set)
 Sets the ignore state for all currently displayed frames.
void setSourceModel (QAbstractItemModel *source_model) override
QModelIndex mapToSource (const QModelIndex &proxy_index) const override
QModelIndex mapFromSource (const QModelIndex &source_index) const override
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent (const QModelIndex &child) const override
int rowCount (const QModelIndex &parent=QModelIndex()) const override
int columnCount (const QModelIndex &parent=QModelIndex()) const override
bool hasChildren (const QModelIndex &parent=QModelIndex()) const override
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns the source model's header data.

Detailed Description

A proxy model exposing the packets of a PacketListModel that pass the display filter, in the currently selected sort order.

The source PacketListModel has one row per packet ever appended, in frame-number order; this model maps a subset of them (those that passed the display filter or are time references, possibly collapsed by the aggregation view) into its own rows, and reorders them when sorted.

Like the source model, each index's internal pointer is the row's PacketListRecord, so delegates and views can read the record directly off an index from either model.

Member Enumeration Documentation

◆ HiddenReason

Why a packet has no row of its own in this model.

Enumerator
Shown 

The packet has a row of its own.

FilteredOut 

The display filter excludes the packet.

Aggregated 

The aggregation view folded it into another packet's row.

Constructor & Destructor Documentation

◆ PacketListProxyModel()

PacketListProxyModel::PacketListProxyModel ( QObject * parent = nullptr)
explicit

Constructs a new PacketListProxyModel.

Parameters
parentThe parent QObject, defaults to nullptr.

Member Function Documentation

◆ bgColorizationProgress

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

Signal emitted to report background colorization progress.

Parameters
firstThe first row processed.
lastThe last row processed.

◆ dissectIdle

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

Performs dissection work during application idle time.

Parameters
resetTrue to reset the idle dissection state.

◆ ensureRowColorized()

void PacketListProxyModel::ensureRowColorized ( int row)

Ensures that a specific row has been colorized.

Parameters
rowThe row index to colorize.

◆ getRowFdata() [1/2]

frame_data * PacketListProxyModel::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 * PacketListProxyModel::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 PacketListProxyModel::goToPacket ( int packet_num)
signal

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

Parameters
packet_numThe target packet number.

◆ headerData()

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

Returns the source model's header data.

Overridden because QAbstractProxyModel's default maps the section through a row-0 index, which doesn't exist when no packets are visible (and columns are never reordered here anyway).

◆ hiddenReason()

PacketListProxyModel::HiddenReason PacketListProxyModel::hiddenReason ( const frame_data * fdata) const

Returns why the given packet has no row of its own, if it doesn't.

Parameters
fdataPointer to the frame data.
Returns
HiddenReason::Shown if rowOfPacket() would be non-negative.

◆ packetListModel()

PacketListModel * PacketListProxyModel::packetListModel ( ) const
inline

The source model, if it is a PacketListModel.

Returns
The source PacketListModel, or nullptr.

◆ packetNumberToRow()

int PacketListProxyModel::packetNumberToRow ( int packet_num) const

Converts a packet number to a row index.

Parameters
packet_numThe packet number.
Returns
The corresponding row index, or -1 if the packet isn't visible.

◆ pinnedRecordLessThan()

bool PacketListProxyModel::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 PacketListProxyModel::recreateVisibleRows ( )

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

Returns
The number of visible rows.

◆ rowOfPacket()

int PacketListProxyModel::rowOfPacket ( const frame_data * fdata) const

Returns the row showing the given packet itself.

Parameters
fdataPointer to the frame data.
Returns
The row, or -1 if the packet isn't visible, including if the aggregation view has aggregated it into another packet's row.

◆ setDisplayedFrameIgnore()

void PacketListProxyModel::setDisplayedFrameIgnore ( bool set)

Sets the ignore state for all currently displayed frames.

Parameters
setTrue to ignore, false to un-ignore.

◆ setDisplayedFrameMark()

void PacketListProxyModel::setDisplayedFrameMark ( bool set)

Sets the mark state for all currently displayed frames.

Parameters
setTrue to mark, false to unmark.

◆ sort

void PacketListProxyModel::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).

◆ visibleIndexOf()

int PacketListProxyModel::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. In the aggregation view, this is the row the packet was aggregated into, which may show another packet.

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