Wireshark 5.1.0
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
24#include "packet_list_record.h"
25
26#include <epan/cfile.h>
27
35class PacketListModel : public QAbstractItemModel
36{
37 Q_OBJECT
38public:
39
43 enum {
51 };
52
58 explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
59
64
70
75 capture_file *captureFile() const { return cap_file_; }
76
84 QModelIndex index(int row, int column,
85 const QModelIndex &parent = QModelIndex()) const override;
86
91 QModelIndex parent(const QModelIndex &) const override;
92
105 PacketListRecord *physicalRecordForFrameNum(int frame_num) const;
106
112 PacketListRecord *physicalRecordAt(int row) const;
113
117 bool isEmpty() const { return physical_rows_.isEmpty(); }
118
122 void clear();
123
129 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
130
135 int columnCount(const QModelIndex & = QModelIndex()) const override;
136
142 Qt::ItemFlags flags(const QModelIndex &index) const override;
143
150 QVariant data(const QModelIndex &d_index, int role) const override;
151
159 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
160
167 int appendPacket(frame_data *fdata);
168
173
177 void resetColumns();
178
182 void resetColorized();
183
188 void toggleFrameMark(const QModelIndexList &indices);
189
195 void setFrameMark(const QVector<PacketListRecord *> &records, bool set);
196
201 void toggleFrameIgnore(const QModelIndexList &indices);
202
208 void setFrameIgnore(const QVector<PacketListRecord *> &records, bool set);
209
214 void toggleFrameRefTime(const QModelIndexList &indices);
215
220
226 void addFrameComment(const QModelIndexList &indices, const QByteArray &comment);
227
234 void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number);
235
240 void deleteFrameComments(const QModelIndexList &indices);
241
246
247signals:
254 void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row);
255
256public slots:
260 void flushNewRows();
261
262private slots:
265 void onThemeChanged();
266
267private:
269 QColor marked_fg_;
271 QColor marked_bg_;
273 QColor ignored_fg_;
275 QColor ignored_bg_;
276
282 void refreshThemeColors();
283
285 capture_file *cap_file_;
286
288 QList<QString> col_names_;
289
291 QVector<PacketListRecord *> physical_rows_;
292
294 int inserted_rows_;
295
296};
297
298#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:409
void deleteFrameComments(const QModelIndexList &indices)
Deletes comments from the specified frames.
Definition packet_list_model.cpp:440
void unsetAllFrameRefTime()
Unsets the reference time state for all frames.
Definition packet_list_model.cpp:344
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition packet_list_model.cpp:518
QModelIndex parent(const QModelIndex &) const override
Returns the parent of the model item.
Definition packet_list_model.cpp:102
void clear()
Clears the model data.
Definition packet_list_model.cpp:131
capture_file * captureFile() const
Returns the capture file associated with the model.
Definition packet_list_model.h:75
PacketListRecord * physicalRecordAt(int row) const
Retrieves the PacketListRecord at the given row.
Definition packet_list_model.cpp:123
void setFrameIgnore(const QVector< PacketListRecord * > &records, bool set)
Sets the ignore state for the given frames.
Definition packet_list_model.cpp:280
void flushNewRows()
Inserts the rows for any packets appended since the last flush.
Definition packet_list_model.cpp:662
void setFrameMark(const QVector< PacketListRecord * > &records, bool set)
Sets the mark state for the given frames.
Definition packet_list_model.cpp:234
void deleteAllFrameComments()
Deletes all frame comments from all frames.
Definition packet_list_model.cpp:473
void resetColorized()
Resets the colorized state for all rows.
Definition packet_list_model.cpp:194
void setCaptureFile(capture_file *cf)
Sets the capture file for the model.
Definition packet_list_model.cpp:82
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:637
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:527
int columnCount(const QModelIndex &=QModelIndex()) const override
Returns the number of columns.
Definition packet_list_model.cpp:513
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition packet_list_model.cpp:140
bool isEmpty() const
Returns true if no packets have been appended.
Definition packet_list_model.h:117
void toggleFrameMark(const QModelIndexList &indices)
Toggles the mark state for the specified frames.
Definition packet_list_model.cpp:205
~PacketListModel()
Destroys the PacketListModel.
Definition packet_list_model.cpp:75
void toggleFrameIgnore(const QModelIndexList &indices)
Toggles the ignore state for the specified frames.
Definition packet_list_model.cpp:251
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition packet_list_model.cpp:505
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:107
void toggleFrameRefTime(const QModelIndexList &indices)
Toggles the reference time state for the specified frames.
Definition packet_list_model.cpp:297
int appendPacket(frame_data *fdata)
Appends a packet to the model. The row is inserted the next time flushNewRows() runs,...
Definition packet_list_model.cpp:675
PacketListModel(QObject *parent=0, capture_file *cf=NULL)
Constructs a new PacketListModel.
Definition packet_list_model.cpp:60
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:88
@ HEADER_CAN_DISPLAY_DETAILS
Definition packet_list_model.h:47
@ COLORING_RULE_COLORS
Definition packet_list_model.h:50
@ HEADER_CAN_DISPLAY_STRINGS
Definition packet_list_model.h:45
void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row)
Signal emitted when a packet is successfully appended.
void addFrameComment(const QModelIndexList &indices, const QByteArray &comment)
Adds a comment to the specified frames.
Definition packet_list_model.cpp:366
void resetColumns()
Rebuild columns from settings.
Definition packet_list_model.cpp:180
Represents a single record within the packet list.
Definition packet_list_record.h:40
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.