Wireshark 4.7.4
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet_list_model.h
Go to the documentation of this file.
1
9
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
104 PacketListRecord *physicalRecordForFrameNum(int frame_num) const;
105
110 unsigned recreateVisibleRows();
111
115 inline void needRecreateVisibleRows() { need_recreate_visible_rows_ = !physical_rows_.isEmpty(); }
116
120 void clear();
121
127 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
128
133 int columnCount(const QModelIndex & = QModelIndex()) const override;
134
140 Qt::ItemFlags flags(const QModelIndex &index) const override;
141
148 QVariant data(const QModelIndex &d_index, int role) const override;
149
162 QVariant dataForFrameNum(int frame_num, int column, int role) const;
163
189 bool pinnedRecordLessThan(int frame_num_a, int frame_num_b) const;
190
198 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
199
205 int appendPacket(frame_data *fdata);
206
212 frame_data *getRowFdata(QModelIndex idx) const;
213
219 frame_data *getRowFdata(int row) const;
220
225 void ensureRowColorized(int row);
226
232 int visibleIndexOf(const frame_data *fdata) const;
233
238
242 void resetColumns();
243
247 void resetColorized();
248
253 void toggleFrameMark(const QModelIndexList &indeces);
254
259 void setDisplayedFrameMark(bool set);
260
265 void toggleFrameIgnore(const QModelIndexList &indeces);
266
271 void setDisplayedFrameIgnore(bool set);
272
277 void toggleFrameRefTime(const QModelIndex &rt_index);
278
283
289 void addFrameComment(const QModelIndexList &indices, const QByteArray &comment);
290
297 void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number);
298
303 void deleteFrameComments(const QModelIndexList &indices);
304
309
310signals:
317 void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row);
318
323 void goToPacket(int packet_num);
324
330 void bgColorizationProgress(int first, int last);
331
332public slots:
338 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
339
343 void stopSorting();
344
348 void flushVisibleRows();
349
354 void dissectIdle(bool reset = false);
355
356private slots:
359 void onThemeChanged();
360
361private:
363 QColor marked_fg_;
365 QColor marked_bg_;
367 QColor ignored_fg_;
369 QColor ignored_bg_;
370
376 void refreshThemeColors();
377
387 QVariant dataForRecord(PacketListRecord *record, int column, int role) const;
388
390 capture_file *cap_file_;
391
393 QList<QString> col_names_;
394
396 QVector<PacketListRecord *> physical_rows_;
397
399 QVector<PacketListRecord *> visible_rows_;
400
402 QVector<PacketListRecord *> new_visible_rows_;
403
405 QVector<int> number_to_row_;
406
408 QHash<QString, int> aggregation_key_row_;
409
411 bool need_recreate_visible_rows_;
412
414 static int sort_column_;
415
417 static int sort_column_is_numeric_;
418
420 static int text_sort_column_;
421
423 static Qt::SortOrder sort_order_;
424
426 static capture_file *sort_cap_file_;
427
434 static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
435
449 static bool compareRecords(PacketListRecord *r1, PacketListRecord *r2);
450
457 static double parseNumericColumn(const QString &val, bool *ok);
458
460 static bool stop_flag_;
461
463 static ProgressFrame *progress_frame_;
464
466 static double exp_comps_;
467
469 static double comps_;
470
472 QElapsedTimer *idle_dissection_timer_;
473
475 int idle_dissection_row_;
476
482 bool isNumericColumn(int column);
483
488 void updateVisibleRows(PacketListRecord* record);
489
495 bool updateVisibleAggregationViewRows(PacketListRecord* record);
496};
497
498#endif // PACKET_LIST_MODEL_H
struct _capture_file capture_file
Represents a capture file and its associated metadata.
void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number)
Sets a specific comment on a frame.
Definition packet_list_model.cpp:457
void deleteFrameComments(const QModelIndexList &indices)
Deletes comments from the specified frames.
Definition packet_list_model.cpp:488
frame_data * getRowFdata(QModelIndex idx) const
Retrieves the frame data for a given model index.
Definition packet_list_model.cpp:1149
void unsetAllFrameRefTime()
Unsets the reference time state for all frames.
Definition packet_list_model.cpp:392
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition packet_list_model.cpp:914
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:185
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_model.cpp:937
void toggleFrameIgnore(const QModelIndexList &indeces)
Toggles the ignore state for the specified frames.
Definition packet_list_model.cpp:317
void deleteAllFrameComments()
Deletes all frame comments from all frames.
Definition packet_list_model.cpp:521
void dissectIdle(bool reset=false)
Performs dissection work during application idle time.
Definition packet_list_model.cpp:1084
void resetColorized()
Resets the colorized state for all rows.
Definition packet_list_model.cpp:260
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:1067
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:1042
QVariant data(const QModelIndex &d_index, int role) const override
Returns the data stored under the given role for the specified index.
Definition packet_list_model.cpp:923
int columnCount(const QModelIndex &=QModelIndex()) const override
Returns the number of columns.
Definition packet_list_model.cpp:909
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition packet_list_model.cpp:206
~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:901
unsigned recreateVisibleRows()
Recreates the list of visible rows based on filters and state.
Definition packet_list_model.cpp:165
QVariant dataForFrameNum(int frame_num, int column, int role) const
Returns the same data data() would for a real, currently visible row, but for any frame/packet number...
Definition packet_list_model.cpp:932
PacketListRecord * physicalRecordForFrameNum(int frame_num) const
Retrieves the PacketListRecord for a given frame/packet number regardless of whether it currently pas...
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:565
void ensureRowColorized(int row)
Ensures that a specific row has been colorized.
Definition packet_list_model.cpp:1165
void setDisplayedFrameIgnore(bool set)
Sets the ignore state for all currently displayed frames.
Definition packet_list_model.cpp:346
void stopSorting()
Stops an ongoing sorting operation.
Definition packet_list_model.cpp:691
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:115
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:1121
int visibleIndexOf(const frame_data *fdata) const
Returns the visible index of the given frame data.
Definition packet_list_model.cpp:1177
PacketListModel(QObject *parent=0, capture_file *cf=NULL)
Constructs a new PacketListModel.
Definition packet_list_model.cpp:86
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
@ HEADER_CAN_DISPLAY_DETAILS
Definition packet_list_model.h:47
@ HEADER_CAN_DISPLAY_STRINGS
Definition packet_list_model.h:45
void toggleFrameRefTime(const QModelIndex &rt_index)
Toggles the reference time state for a specified frame.
Definition packet_list_model.cpp:363
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:300
void toggleFrameMark(const QModelIndexList &indeces)
Toggles the mark state for the specified frames.
Definition packet_list_model.cpp:271
void addFrameComment(const QModelIndexList &indices, const QByteArray &comment)
Adds a comment to the specified frames.
Definition packet_list_model.cpp:414
void resetColumns()
Rebuild columns from settings.
Definition packet_list_model.cpp:246
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:40
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.