Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet_list_proxy_model.h
Go to the documentation of this file.
1
11
12#ifndef PACKET_LIST_PROXY_MODEL_H
13#define PACKET_LIST_PROXY_MODEL_H
14
15#include <config.h>
16
17#include <QAbstractProxyModel>
18#include <QHash>
19#include <QVector>
20
21#include <epan/cfile.h>
22
23class QElapsedTimer;
24class PacketListModel;
26class ProgressFrame;
27
41class PacketListProxyModel : public QAbstractProxyModel
42{
43 Q_OBJECT
44public:
49 explicit PacketListProxyModel(QObject *parent = nullptr);
50
55
60 PacketListModel *packetListModel() const { return packet_list_model_; }
61
67 int packetNumberToRow(int packet_num) const;
68
73 unsigned recreateVisibleRows();
74
79
105 bool pinnedRecordLessThan(int frame_num_a, int frame_num_b) const;
106
112 frame_data *getRowFdata(QModelIndex idx) const;
113
119 frame_data *getRowFdata(int row) const;
120
125 void ensureRowColorized(int row);
126
133 int visibleIndexOf(const frame_data *fdata) const;
134
141 int rowOfPacket(const frame_data *fdata) const;
142
149
155 HiddenReason hiddenReason(const frame_data *fdata) const;
156
161 void setDisplayedFrameMark(bool set);
162
167 void setDisplayedFrameIgnore(bool set);
168
169 // QAbstractProxyModel
170 void setSourceModel(QAbstractItemModel *source_model) override;
171 QModelIndex mapToSource(const QModelIndex &proxy_index) const override;
172 QModelIndex mapFromSource(const QModelIndex &source_index) const override;
173 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
174 QModelIndex parent(const QModelIndex &child) const override;
175 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
176 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
177 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
178
186 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
187
188signals:
193 void goToPacket(int packet_num);
194
200 void bgColorizationProgress(int first, int last);
201
202public slots:
208 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
209
213 void stopSorting();
214
219 void flushVisibleRows();
220
225 void dissectIdle(bool reset = false);
226
227private slots:
228 void sourceRowsInserted(const QModelIndex &parent, int first, int last);
229 void sourceModelAboutToBeReset();
230 void sourceModelReset();
231 void sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right,
232 const QList<int> &roles);
233 void sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last);
234
235private:
237 PacketListModel *packet_list_model_;
238
240 QVector<PacketListRecord *> visible_rows_;
241
243 QVector<int> number_to_row_;
244
246 QHash<QString, int> aggregation_key_row_;
247
249 bool need_recreate_visible_rows_;
250
252 QElapsedTimer *idle_dissection_timer_;
253
255 int idle_dissection_row_;
256
258 capture_file *captureFile() const;
259
261 void clearVisibleRows();
262
264 static int sort_column_;
265
267 static int sort_column_is_numeric_;
268
270 static int text_sort_column_;
271
273 static Qt::SortOrder sort_order_;
274
276 static capture_file *sort_cap_file_;
277
284 static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
285
299 static bool compareRecords(PacketListRecord *r1, PacketListRecord *r2);
300
307 static double parseNumericColumn(const QString &val, bool *ok);
308
310 static bool stop_flag_;
311
313 static ProgressFrame *progress_frame_;
314
316 static double exp_comps_;
317
319 static double comps_;
320
326 bool isNumericColumn(int column);
327
332 void updateVisibleRows(PacketListRecord* record);
333
339 bool updateVisibleAggregationViewRows(PacketListRecord* record);
340};
341
342#endif // PACKET_LIST_PROXY_MODEL_H
struct _capture_file capture_file
Represents a capture file and its associated metadata.
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sorts the model based on the specified column.
Definition packet_list_proxy_model.cpp:356
unsigned recreateVisibleRows()
Recreates the list of visible rows based on filters and state.
Definition packet_list_proxy_model.cpp:210
frame_data * getRowFdata(QModelIndex idx) const
Retrieves the frame data for a given model index.
Definition packet_list_proxy_model.cpp:784
PacketListProxyModel(QObject *parent=nullptr)
Constructs a new PacketListProxyModel.
Definition packet_list_proxy_model.cpp:58
void stopSorting()
Stops an ongoing sorting operation.
Definition packet_list_proxy_model.cpp:506
~PacketListProxyModel()
Destroys the PacketListProxyModel.
Definition packet_list_proxy_model.cpp:74
void dissectIdle(bool reset=false)
Performs dissection work during application idle time.
Definition packet_list_proxy_model.cpp:747
int visibleIndexOf(const frame_data *fdata) const
Returns the visible index of the given frame data.
Definition packet_list_proxy_model.cpp:812
void flushVisibleRows()
Inserts any packets appended to the source model since the last update, and the visible ones among th...
Definition packet_list_proxy_model.cpp:736
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,...
Definition packet_list_proxy_model.cpp:716
PacketListModel * packetListModel() const
The source model, if it is a PacketListModel.
Definition packet_list_proxy_model.h:60
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the source model's header data.
Definition packet_list_proxy_model.cpp:190
void goToPacket(int packet_num)
Signal emitted to navigate the view to a specific packet number.
void ensureRowColorized(int row)
Ensures that a specific row has been colorized.
Definition packet_list_proxy_model.cpp:800
void setDisplayedFrameIgnore(bool set)
Sets the ignore state for all currently displayed frames.
Definition packet_list_proxy_model.cpp:337
int packetNumberToRow(int packet_num) const
Converts a packet number to a row index.
Definition packet_list_proxy_model.cpp:198
HiddenReason
Definition packet_list_proxy_model.h:144
@ Shown
The packet has a row of its own.
Definition packet_list_proxy_model.h:145
@ FilteredOut
The display filter excludes the packet.
Definition packet_list_proxy_model.h:146
@ Aggregated
The aggregation view folded it into another packet's row.
Definition packet_list_proxy_model.h:147
void needRecreateVisibleRows()
Flags the model as needing to recreate its visible rows.
Definition packet_list_proxy_model.cpp:205
int rowOfPacket(const frame_data *fdata) const
Returns the row showing the given packet itself.
Definition packet_list_proxy_model.cpp:820
void bgColorizationProgress(int first, int last)
Signal emitted to report background colorization progress.
void setDisplayedFrameMark(bool set)
Sets the mark state for all currently displayed frames.
Definition packet_list_proxy_model.cpp:330
HiddenReason hiddenReason(const frame_data *fdata) const
Returns why the given packet has no row of its own, if it doesn't.
Definition packet_list_proxy_model.cpp:826
Represents a single record within the packet list.
Definition packet_list_record.h:40
A frame for displaying progress indications and dialogs.
Definition progress_frame.h:40
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.