| Wireshark 4.7.3 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 <ui/qt/progress_frame.h>
25
26#include "packet_list_record.h"
27
28#include <epan/cfile.h>
29
30 class QElapsedTimer;
31
35 class PacketListModel : public QAbstractItemModel
36{
37 Q_OBJECT
38 public:
39
43 enum {
45 HEADER_CAN_DISPLAY_STRINGS = Qt::UserRole,
47 HEADER_CAN_DISPLAY_DETAILS,
48 };
49
55 explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
56
60 ~PacketListModel();
61
66 void setCaptureFile(capture_file *cf);
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
181 void invalidateAllColumnStrings();
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
226 void unsetAllFrameRefTime();
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
252 void deleteAllFrameComments();
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
276 public 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
300 private slots:
303 void onThemeChanged();
304
305 private:
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
cfile.h
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
PacketListModel::setFrameComment
void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number)
Sets a specific comment on a frame.
Definition packet_list_model.cpp:431
PacketListModel::deleteFrameComments
void deleteFrameComments(const QModelIndexList &indices)
Deletes comments from the specified frames.
Definition packet_list_model.cpp:462
PacketListModel::getRowFdata
frame_data * getRowFdata(QModelIndex idx) const
Retrieves the frame data for a given model index.
Definition packet_list_model.cpp:1086
PacketListModel::unsetAllFrameRefTime
void unsetAllFrameRefTime()
Unsets the reference time state for all frames.
Definition packet_list_model.cpp:366
PacketListModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition packet_list_model.cpp:881
PacketListModel::parent
QModelIndex parent(const QModelIndex &) const override
Returns the parent of the model item.
Definition packet_list_model.cpp:133
PacketListModel::clear
void clear()
Clears the model data.
Definition packet_list_model.cpp:165
PacketListModel::toggleFrameIgnore
void toggleFrameIgnore(const QModelIndexList &indeces)
Toggles the ignore state for the specified frames.
Definition packet_list_model.cpp:291
PacketListModel::deleteAllFrameComments
void deleteAllFrameComments()
Deletes all frame comments from all frames.
Definition packet_list_model.cpp:495
PacketListModel::dissectIdle
void dissectIdle(bool reset=false)
Performs dissection work during application idle time.
Definition packet_list_model.cpp:1021
PacketListModel::resetColorized
void resetColorized()
Resets the colorized state for all rows.
Definition packet_list_model.cpp:234
PacketListModel::setCaptureFile
void setCaptureFile(capture_file *cf)
Sets the capture file for the model.
Definition packet_list_model.cpp:113
PacketListModel::bgColorizationProgress
void bgColorizationProgress(int first, int last)
Signal emitted to report background colorization progress.
PacketListModel::flushVisibleRows
void flushVisibleRows()
Flushes the newly visible rows into the main visible rows view.
Definition packet_list_model.cpp:1004
PacketListModel::headerData
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:979
PacketListModel::data
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:890
PacketListModel::columnCount
int columnCount(const QModelIndex &=QModelIndex()) const override
Returns the number of columns.
Definition packet_list_model.cpp:876
PacketListModel::invalidateAllColumnStrings
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition packet_list_model.cpp:180
PacketListModel::~PacketListModel
~PacketListModel()
Destroys the PacketListModel.
Definition packet_list_model.cpp:108
PacketListModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition packet_list_model.cpp:868
PacketListModel::recreateVisibleRows
unsigned recreateVisibleRows()
Recreates the list of visible rows based on filters and state.
Definition packet_list_model.cpp:145
PacketListModel::sort
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sorts the model based on the specified column.
Definition packet_list_model.cpp:539
PacketListModel::ensureRowColorized
void ensureRowColorized(int row)
Ensures that a specific row has been colorized.
Definition packet_list_model.cpp:1102
PacketListModel::setDisplayedFrameIgnore
void setDisplayedFrameIgnore(bool set)
Sets the ignore state for all currently displayed frames.
Definition packet_list_model.cpp:320
PacketListModel::stopSorting
void stopSorting()
Stops an ongoing sorting operation.
Definition packet_list_model.cpp:665
PacketListModel::packetNumberToRow
int packetNumberToRow(int packet_num) const
Converts a packet number to a row index.
Definition packet_list_model.cpp:138
PacketListModel::needRecreateVisibleRows
void needRecreateVisibleRows()
Flags the model as needing to recreate its visible rows.
Definition packet_list_model.h:100
PacketListModel::goToPacket
void goToPacket(int packet_num)
Signal emitted to navigate the view to a specific packet number.
PacketListModel::appendPacket
int appendPacket(frame_data *fdata)
Appends a packet to the model.
Definition packet_list_model.cpp:1058
PacketListModel::visibleIndexOf
int visibleIndexOf(const frame_data *fdata) const
Returns the visible index of the given frame data.
Definition packet_list_model.cpp:1114
PacketListModel::PacketListModel
PacketListModel(QObject *parent=0, capture_file *cf=NULL)
Constructs a new PacketListModel.
Definition packet_list_model.cpp:86
PacketListModel::index
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
PacketListModel::HEADER_CAN_DISPLAY_DETAILS
@ HEADER_CAN_DISPLAY_DETAILS
Definition packet_list_model.h:47
PacketListModel::HEADER_CAN_DISPLAY_STRINGS
@ HEADER_CAN_DISPLAY_STRINGS
Definition packet_list_model.h:45
PacketListModel::toggleFrameRefTime
void toggleFrameRefTime(const QModelIndex &rt_index)
Toggles the reference time state for a specified frame.
Definition packet_list_model.cpp:337
PacketListModel::packetAppended
void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row)
Signal emitted when a packet is successfully appended.
PacketListModel::setDisplayedFrameMark
void setDisplayedFrameMark(bool set)
Sets the mark state for all currently displayed frames.
Definition packet_list_model.cpp:274
PacketListModel::toggleFrameMark
void toggleFrameMark(const QModelIndexList &indeces)
Toggles the mark state for the specified frames.
Definition packet_list_model.cpp:245
PacketListModel::addFrameComment
void addFrameComment(const QModelIndexList &indices, const QByteArray &comment)
Adds a comment to the specified frames.
Definition packet_list_model.cpp:388
PacketListModel::resetColumns
void resetColumns()
Rebuild columns from settings.
Definition packet_list_model.cpp:220
PacketListRecord
Represents a single record within the packet list.
Definition packet_list_record.h:32
ProgressFrame
A frame for displaying progress indications and dialogs.
Definition progress_frame.h:40
frame_data
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
packet.h
packet_list_record.h
progress_frame.h