A proxy model exposing only a chosen set of "pinned" packets from a PacketListModel, packed together with no gaps, ordered to match the source model's own current row order (i.e. whatever sort/filter is currently active there).
More...
#include <pinned_rows_model.h>
|
|
| PinnedRowsModel (QObject *parent=nullptr) |
| 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 | isPinned (int frame_num) const |
|
int | pinnedCount () const |
|
void | refresh () |
| | Re-sorts the pinned frames to match the source model's current row order (i.e. whatever sort is currently applied there), and re-resolves each against the current source model state (e.g. after a display filter change), emitting layoutChanged(). A pinned frame that's been filtered out of the source model resolves to an invalid row (see sourceRowForPinnedIndex()) but stays pinned – it reappears automatically, in its sorted position, once the filter allows it again.
|
|
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 |
| QVariant | data (const QModelIndex &proxy_index, int role) const override |
| | Returns a pinned row's data regardless of whether it currently passes the display filter.
|
| Qt::ItemFlags | flags (const QModelIndex &proxy_index) const override |
| | Returns a pinned row's flags regardless of whether it currently passes the display filter, for the same reason data() is overridden – QAbstractProxyModel's default flags() calls sourceModel()->flags(mapToSource(index)), which is an invalid index whenever the row is filtered out, silently diverging from what data() already reports for that same row.
|
A proxy model exposing only a chosen set of "pinned" packets from a PacketListModel, packed together with no gaps, ordered to match the source model's own current row order (i.e. whatever sort/filter is currently active there).
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, and maps each to that packet's current row in the source model on demand.
◆ data()
| QVariant PinnedRowsModel::data |
( |
const QModelIndex & | proxy_index, |
|
|
int | role ) const |
|
override |
Returns a pinned row's data regardless of whether it currently passes the display filter.
Overridden (rather than relying on QAbstractProxyModel's default, which calls sourceModel()->data(mapToSource(index), role)) because mapToSource() only ever resolves to a row among the source model's currently visible (filtered-in) rows – a pinned packet that's been filtered out has no such row, so the default would return an empty QVariant for it. This instead always reads the packet's data from PacketListModel::dataForFrameNum(), which looks the packet up directly regardless of the display filter, so pinned rows keep showing their data even after being filtered out.
- Parameters
-
| proxy_index | The index within this proxy model. |
| role | The display role. |
◆ flags()
| Qt::ItemFlags PinnedRowsModel::flags |
( |
const QModelIndex & | proxy_index | ) |
const |
|
override |
Returns a pinned row's flags regardless of whether it currently passes the display filter, for the same reason data() is overridden – QAbstractProxyModel's default flags() calls sourceModel()->flags(mapToSource(index)), which is an invalid index whenever the row is filtered out, silently diverging from what data() already reports for that same row.
- Parameters
-
| proxy_index | The index within this proxy model. |
◆ pinFrame()
| bool PinnedRowsModel::pinFrame |
( |
int | frame_num | ) |
|
Pins a packet, if not already pinned and under the kMaxPinnedRows cap.
- Parameters
-
| frame_num | The frame number to pin. |
- Returns
- False if the cap was already reached.
◆ unpinFrame()
| void PinnedRowsModel::unpinFrame |
( |
int | frame_num | ) |
|
Unpins a packet.
- Parameters
-
| frame_num | The frame number to unpin. |
◆ 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:
- /builds/wireshark/wireshark/ui/qt/models/pinned_rows_model.h
- /builds/wireshark/wireshark/ui/qt/models/pinned_rows_model.cpp