13#ifndef PINNED_ROWS_MODEL_H
14#define PINNED_ROWS_MODEL_H
16#include <QAbstractProxyModel>
38class PinnedRowsModel :
public QAbstractProxyModel
45 explicit PinnedRowsModel(QObject *parent =
nullptr);
90 void discardSavedPins() { saved_frame_nums_.clear(); }
93 bool isPinned(
int frame_num)
const;
96 int pinnedCount()
const {
return static_cast<int>(pinned_frame_nums_.count()); }
103 int rowForFrameNum(
int frame_num)
const {
return static_cast<int>(pinned_frame_nums_.indexOf(frame_num)); }
114 void setSourceModel(QAbstractItemModel *source_model)
override;
115 QModelIndex mapToSource(
const QModelIndex &proxy_index)
const override;
116 QModelIndex mapFromSource(
const QModelIndex &source_index)
const override;
117 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
118 QModelIndex parent(
const QModelIndex &child)
const override;
119 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
120 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
121 bool hasChildren(
const QModelIndex &parent = QModelIndex())
const override;
122 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
129 QVariant
data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
144 void sourceDataChanged(
const QModelIndex &source_top_left,
const QModelIndex &source_bottom_right,
145 const QList<int> &roles);
147 void sourceModelAboutToBeReset();
148 void sourceModelReset();
151 QList<int> pinned_frame_nums_;
153 QList<int> saved_frame_nums_;
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
A proxy model exposing the packets of a PacketListModel that pass the display filter,...
Definition packet_list_proxy_model.h:42
void refresh()
Re-sorts the pinned frames to match the sort model's current order (whatever column/order the user la...
Definition pinned_rows_model.cpp:137
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition pinned_rows_model.cpp:284
void setSortModel(PacketListProxyModel *sort_model)
Sets the model whose sort order the pinned rows follow.
Definition pinned_rows_model.cpp:64
int rowForFrameNum(int frame_num) const
The row of the given pinned frame in this model.
Definition pinned_rows_model.h:103
void setBaseFont(const QFont &font)
Sets the font the pinned rows are drawn in, from which the italic font for pinned packets without a r...
Definition pinned_rows_model.cpp:70
bool restoreSavedPins()
Re-pins the frames that were pinned when the source model was last reset (e.g., by redissection),...
Definition pinned_rows_model.cpp:119
static const int kMaxPinnedRows
Definition pinned_rows_model.h:43
void unpinFrame(int frame_num)
Unpins a packet.
Definition pinned_rows_model.cpp:96
bool pinFrame(int frame_num)
Pins a packet, if not already pinned and under the kMaxPinnedRows cap.
Definition pinned_rows_model.cpp:75