Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet_list_model.h
Go to the documentation of this file.
1
10#ifndef PACKET_LIST_MODEL_H
11#define PACKET_LIST_MODEL_H
12
13#include <config.h>
14
15#include <stdio.h>
16
17#include <epan/packet.h>
18
19#include <QAbstractItemModel>
20#include <QColor>
21#include <QFont>
22#include <QVector>
23
25
26#include "packet_list_record.h"
27
28#include <epan/cfile.h>
29
30class QElapsedTimer;
31
35class PacketListModel : public QAbstractItemModel
36{
37 Q_OBJECT
38public:
39
43 enum {
48 };
49
55 explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
56
61
67
75 QModelIndex index(int row, int column,
76 const QModelIndex &parent = QModelIndex()) const override;
77
82 QModelIndex parent(const QModelIndex &) const override;
83
89 int packetNumberToRow(int packet_num) const;
90
95 unsigned recreateVisibleRows();
96
100 inline void needRecreateVisibleRows() { need_recreate_visible_rows_ = !physical_rows_.isEmpty(); }
101
105 void clear();
106
112 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
113
118 int columnCount(const QModelIndex & = QModelIndex()) const override;
119
125 Qt::ItemFlags flags(const QModelIndex &index) const override;
126
133 QVariant data(const QModelIndex &d_index, int role) const override;
134
142 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
143
149 int appendPacket(frame_data *fdata);
150
156 frame_data *getRowFdata(QModelIndex idx) const;
157
163 frame_data *getRowFdata(int row) const;
164
169 void ensureRowColorized(int row);
170
176 int visibleIndexOf(const frame_data *fdata) const;
177
182
186 void resetColumns();
187
191 void resetColorized();
192
197 void toggleFrameMark(const QModelIndexList &indeces);
198
203 void setDisplayedFrameMark(bool set);
204
209 void toggleFrameIgnore(const QModelIndexList &indeces);
210
215 void setDisplayedFrameIgnore(bool set);
216
221 void toggleFrameRefTime(const QModelIndex &rt_index);
222
227
233 void addFrameComment(const QModelIndexList &indices, const QByteArray &comment);
234
241 void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number);
242
247 void deleteFrameComments(const QModelIndexList &indices);
248
253
254signals:
261 void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row);
262
267 void goToPacket(int packet_num);
268
274 void bgColorizationProgress(int first, int last);
275
276public slots:
282 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
283
287 void stopSorting();
288
292 void flushVisibleRows();
293
298 void dissectIdle(bool reset = false);
299
300private slots:
303 void onThemeChanged();
304
305private:
307 QColor marked_fg_;
309 QColor marked_bg_;
311 QColor ignored_fg_;
313 QColor ignored_bg_;
314
320 void refreshThemeColors();
321
323 capture_file *cap_file_;
324
326 QList<QString> col_names_;
327
329 QVector<PacketListRecord *> physical_rows_;
330
332 QVector<PacketListRecord *> visible_rows_;
333
335 QVector<PacketListRecord *> new_visible_rows_;
336
338 QVector<int> number_to_row_;
339
341 QHash<QString, int> aggregation_key_row_;
342
344 bool need_recreate_visible_rows_;
345
347 static int sort_column_;
348
350 static int sort_column_is_numeric_;
351
353 static int text_sort_column_;
354
356 static Qt::SortOrder sort_order_;
357
359 static capture_file *sort_cap_file_;
360
367 static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
368
375 static double parseNumericColumn(const QString &val, bool *ok);
376
378 static bool stop_flag_;
379
381 static ProgressFrame *progress_frame_;
382
384 static double exp_comps_;
385
387 static double comps_;
388
390 QElapsedTimer *idle_dissection_timer_;
391
393 int idle_dissection_row_;
394
400 bool isNumericColumn(int column);
401
406 void updateVisibleRows(PacketListRecord* record);
407
413 bool updateVisibleAggregationViewRows(PacketListRecord* record);
414};
415
416#endif // PACKET_LIST_MODEL_H
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number)
Sets a specific comment on a frame.
Definition packet_list_model.cpp:443
void deleteFrameComments(const QModelIndexList &indices)
Deletes comments from the specified frames.
Definition packet_list_model.cpp:474
frame_data * getRowFdata(QModelIndex idx) const
Retrieves the frame data for a given model index.
Definition packet_list_model.cpp:1098
void unsetAllFrameRefTime()
Unsets the reference time state for all frames.
Definition packet_list_model.cpp:378
QModelIndex parent(const QModelIndex &) const override
Returns the parent of the model item.
Definition packet_list_model.cpp:133
void clear()
Clears the model data.
Definition packet_list_model.cpp:165
void toggleFrameIgnore(const QModelIndexList &indeces)
Toggles the ignore state for the specified frames.
Definition packet_list_model.cpp:301
void deleteAllFrameComments()
Deletes all frame comments from all frames.
Definition packet_list_model.cpp:507
void dissectIdle(bool reset=false)
Performs dissection work during application idle time.
Definition packet_list_model.cpp:1033
void resetColorized()
Resets the colorized state for all rows.
Definition packet_list_model.cpp:238
void setCaptureFile(capture_file *cf)
Sets the capture file for the model.
Definition packet_list_model.cpp:113
void bgColorizationProgress(int first, int last)
Signal emitted to report background colorization progress.
void flushVisibleRows()
Flushes the newly visible rows into the main visible rows view.
Definition packet_list_model.cpp:1016
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the data for the given role and section in the header.
Definition packet_list_model.cpp:991
int columnCount(const QModelIndex &=QModelIndex()) const override
Returns the number of columns.
Definition packet_list_model.cpp:888
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition packet_list_model.cpp:180
~PacketListModel()
Destroys the PacketListModel.
Definition packet_list_model.cpp:108
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition packet_list_model.cpp:880
unsigned recreateVisibleRows()
Recreates the list of visible rows based on filters and state.
Definition packet_list_model.cpp:145
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sorts the model based on the specified column.
Definition packet_list_model.cpp:551
void ensureRowColorized(int row)
Ensures that a specific row has been colorized.
Definition packet_list_model.cpp:1114
@ HEADER_CAN_DISPLAY_DETAILS
Definition packet_list_model.h:47
@ HEADER_CAN_DISPLAY_STRINGS
Definition packet_list_model.h:45
void setDisplayedFrameIgnore(bool set)
Sets the ignore state for all currently displayed frames.
Definition packet_list_model.cpp:330
void stopSorting()
Stops an ongoing sorting operation.
Definition packet_list_model.cpp:677
int packetNumberToRow(int packet_num) const
Converts a packet number to a row index.
Definition packet_list_model.cpp:138
void needRecreateVisibleRows()
Flags the model as needing to recreate its visible rows.
Definition packet_list_model.h:100
void goToPacket(int packet_num)
Signal emitted to navigate the view to a specific packet number.
int appendPacket(frame_data *fdata)
Appends a packet to the model.
Definition packet_list_model.cpp:1070
int visibleIndexOf(const frame_data *fdata) const
Returns the visible index of the given frame data.
Definition packet_list_model.cpp:1126
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the item in the model.
Definition packet_list_model.cpp:119
void toggleFrameRefTime(const QModelIndex &rt_index)
Toggles the reference time state for a specified frame.
Definition packet_list_model.cpp:350
void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row)
Signal emitted when a packet is successfully appended.
void setDisplayedFrameMark(bool set)
Sets the mark state for all currently displayed frames.
Definition packet_list_model.cpp:281
void toggleFrameMark(const QModelIndexList &indeces)
Toggles the mark state for the specified frames.
Definition packet_list_model.cpp:252
void addFrameComment(const QModelIndexList &indices, const QByteArray &comment)
Adds a comment to the specified frames.
Definition packet_list_model.cpp:400
void resetColumns()
Rebuild columns from settings.
Definition packet_list_model.cpp:221
Represents a single record within the packet list.
Definition packet_list_record.h:32
A frame for displaying progress indications and dialogs.
Definition progress_frame.h:45
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
Represents a capture file and its associated metadata.
Definition cfile.h:84