Wireshark 4.7.4
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
pinned_rows_model.h
Go to the documentation of this file.
1
12
13#ifndef PINNED_ROWS_MODEL_H
14#define PINNED_ROWS_MODEL_H
15
16#include <QAbstractProxyModel>
17#include <QList>
18
19class PacketListModel;
20
34class PinnedRowsModel : public QAbstractProxyModel
35{
36 Q_OBJECT
37public:
39 static const int kMaxPinnedRows = 10;
40
41 explicit PinnedRowsModel(QObject *parent = nullptr);
42
49 bool pinFrame(int frame_num);
50
55 void unpinFrame(int frame_num);
56
57 // Unpins every currently pinned packet.
58 void clear();
59
60 // Whether the given frame number is currently pinned.
61 bool isPinned(int frame_num) const;
62
63 // The number of currently pinned frames.
64 int pinnedCount() const { return static_cast<int>(pinned_frame_nums_.count()); }
65
76 void refresh();
77
78 // QAbstractProxyModel
79 void setSourceModel(QAbstractItemModel *source_model) override;
80 QModelIndex mapToSource(const QModelIndex &proxy_index) const override;
81 QModelIndex mapFromSource(const QModelIndex &source_index) const override;
82 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
83 QModelIndex parent(const QModelIndex &child) const override;
84 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
85 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
86
103 QVariant data(const QModelIndex &proxy_index, int role) const override;
104
114 Qt::ItemFlags flags(const QModelIndex &proxy_index) const override;
115
116private slots:
129 void sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right,
130 const QList<int> &roles);
131
132private:
133 QList<int> pinned_frame_nums_;
134 PacketListModel *packet_list_model_;
135
140 int sourceRowForPinnedIndex(int proxy_row) const;
141};
142
143#endif // PINNED_ROWS_MODEL_H
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
Qt::ItemFlags flags(const QModelIndex &proxy_index) const override
Returns a pinned row's flags regardless of whether it currently passes the display filter,...
Definition pinned_rows_model.cpp:145
void refresh()
Re-sorts the pinned frames to match the source model's current row order (i.e. whatever sort is curre...
Definition pinned_rows_model.cpp:81
static const int kMaxPinnedRows
Definition pinned_rows_model.h:39
void unpinFrame(int frame_num)
Unpins a packet.
Definition pinned_rows_model.cpp:53
bool pinFrame(int frame_num)
Pins a packet, if not already pinned and under the kMaxPinnedRows cap.
Definition pinned_rows_model.cpp:35
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.
Definition pinned_rows_model.cpp:134