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

A proxy model exposing only a chosen set of "pinned" packets from a PacketListModel, packed together with no gaps, ordered to match the packet list's current sort order (see setSortModel()). More...

#include <pinned_rows_model.h>

Inheritance diagram for PinnedRowsModel:

Public Member Functions

 PinnedRowsModel (QObject *parent=nullptr)
void setSortModel (PacketListProxyModel *sort_model)
 Sets the model whose sort order the pinned rows follow.
void setBaseFont (const QFont &font)
 Sets the font the pinned rows are drawn in, from which the italic font for pinned packets without a row in the packet list is derived.
bool pinFrame (int frame_num)
 Pins a packet, if not already pinned and under the kMaxPinnedRows cap.
void unpinFrame (int frame_num)
 Unpins a packet.
void clear ()
bool restoreSavedPins ()
 Re-pins the frames that were pinned when the source model was last reset (e.g., by redissection), in the order they were pinned, skipping any that no longer exist. Frame numbers are stable across redissection, so the same packets are pinned afterward.
void discardSavedPins ()
bool isPinned (int frame_num) const
int pinnedCount () const
int rowForFrameNum (int frame_num) const
 The row of the given pinned frame in this model.
void refresh ()
 Re-sorts the pinned frames to match the sort model's current order (whatever column/order the user last sorted by), emitting layoutChanged(). A pinned frame that's been filtered out of the packet list stays pinned, in its sorted position.
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
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override

Static Public Attributes

static const int kMaxPinnedRows = 10

Detailed Description

A proxy model exposing only a chosen set of "pinned" packets from a PacketListModel, packed together with no gaps, ordered to match the packet list's current sort order (see setSortModel()).

Used to render the pinned-row overlay in the packet list: rather than hiding thousands of individual rows in a real QTreeView on the full model (which QTreeView has no way to do efficiently for an arbitrary, scattered row set), this proxy simply reports N rows, one per pinned frame number.

The source PacketListModel has a row for every packet regardless of the display filter, so every pinned packet always maps to a valid source row, even when it is filtered out of the packet list.

Member Function Documentation

◆ data()

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

Styles a pinned packet that has no row of its own in the packet list (greyed out and italic) and explains why in its tooltip: the display filter excludes it, or the aggregation view folded it into another packet's row.

◆ pinFrame()

bool PinnedRowsModel::pinFrame ( int frame_num)

Pins a packet, if not already pinned and under the kMaxPinnedRows cap.

Parameters
frame_numThe frame number to pin.
Returns
False if the cap was already reached.

◆ restoreSavedPins()

bool PinnedRowsModel::restoreSavedPins ( )

Re-pins the frames that were pinned when the source model was last reset (e.g., by redissection), in the order they were pinned, skipping any that no longer exist. Frame numbers are stable across redissection, so the same packets are pinned afterward.

Returns
True if any frames were restored.

◆ rowForFrameNum()

int PinnedRowsModel::rowForFrameNum ( int frame_num) const
inline

The row of the given pinned frame in this model.

Parameters
frame_numThe frame number.
Returns
The row, or -1 if the frame isn't pinned.

◆ setBaseFont()

void PinnedRowsModel::setBaseFont ( const QFont & font)

Sets the font the pinned rows are drawn in, from which the italic font for pinned packets without a row in the packet list is derived.

Parameters
fontThe packet list's font.

◆ setSortModel()

void PinnedRowsModel::setSortModel ( PacketListProxyModel * sort_model)

Sets the model whose sort order the pinned rows follow.

Parameters
sort_modelThe packet list's proxy model, or nullptr to order the pinned rows by frame number.

◆ unpinFrame()

void PinnedRowsModel::unpinFrame ( int frame_num)

Unpins a packet.

Parameters
frame_numThe frame number to unpin.

Member Data Documentation

◆ kMaxPinnedRows

const int PinnedRowsModel::kMaxPinnedRows = 10
static

Maximum number of packets that can be pinned simultaneously.


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