Wireshark  4.3.0
The Wireshark network protocol analyzer
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 <QFont>
21 #include <QVector>
22 
23 #include <ui/qt/progress_frame.h>
24 
25 #include "packet_list_record.h"
26 
27 #include "cfile.h"
28 
29 class QElapsedTimer;
30 
31 class PacketListModel : public QAbstractItemModel
32 {
33  Q_OBJECT
34 public:
35 
36  enum {
37  HEADER_CAN_RESOLVE = Qt::UserRole,
38  };
39 
40  explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL);
41  ~PacketListModel();
42  void setCaptureFile(capture_file *cf);
43  QModelIndex index(int row, int column,
44  const QModelIndex & = QModelIndex()) const;
45  QModelIndex parent(const QModelIndex &) const;
46  int packetNumberToRow(int packet_num) const;
47  unsigned recreateVisibleRows();
48  void clear();
49 
50  int rowCount(const QModelIndex &parent = QModelIndex()) const;
51  int columnCount(const QModelIndex & = QModelIndex()) const;
52  QVariant data(const QModelIndex &d_index, int role) const;
53  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
54 
55  int appendPacket(frame_data *fdata);
56  frame_data *getRowFdata(QModelIndex idx) const;
57  frame_data *getRowFdata(int row) const;
58  void ensureRowColorized(int row);
59  int visibleIndexOf(frame_data *fdata) const;
67  void resetColumns();
68  void resetColorized();
69  void toggleFrameMark(const QModelIndexList &indeces);
70  void setDisplayedFrameMark(bool set);
71  void toggleFrameIgnore(const QModelIndexList &indeces);
72  void setDisplayedFrameIgnore(bool set);
73  void toggleFrameRefTime(const QModelIndex &rt_index);
74  void unsetAllFrameRefTime();
75  void addFrameComment(const QModelIndexList &indices, const QByteArray &comment);
76  void setFrameComment(const QModelIndex &index, const QByteArray &comment, unsigned c_number);
77  void deleteFrameComments(const QModelIndexList &indices);
78  void deleteAllFrameComments();
79 
80  void setMaximumRowHeight(int height);
81 
82 signals:
83  void packetAppended(capture_file *cap_file, frame_data *fdata, qsizetype row);
84  void goToPacket(int);
85  void maxLineCountChanged(const QModelIndex &ih_index) const;
86  void itemHeightChanged(const QModelIndex &ih_index);
87 
88  void bgColorizationProgress(int first, int last);
89 
90 public slots:
91  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
92  void stopSorting();
93  void flushVisibleRows();
94  void dissectIdle(bool reset = false);
95 
96 private:
97  capture_file *cap_file_;
98  QList<QString> col_names_;
99  QVector<PacketListRecord *> physical_rows_;
100  QVector<PacketListRecord *> visible_rows_;
101  QVector<PacketListRecord *> new_visible_rows_;
102  QVector<int> number_to_row_;
103 
104  int max_row_height_; // px
105  int max_line_count_;
106 
107  static int sort_column_;
108  static int sort_column_is_numeric_;
109  static int text_sort_column_;
110  static Qt::SortOrder sort_order_;
111  static capture_file *sort_cap_file_;
112  static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2);
113  static double parseNumericColumn(const QString &val, bool *ok);
114 
115  static bool stop_flag_;
116  static ProgressFrame *progress_frame_;
117  static double exp_comps_;
118  static double comps_;
119 
120  QElapsedTimer *idle_dissection_timer_;
121  int idle_dissection_row_;
122 
123  bool isNumericColumn(int column);
124 
125 private slots:
126  void emitItemHeightChanged(const QModelIndex &ih_index);
127 };
128 
129 #endif // PACKET_LIST_MODEL_H
Definition: packet_list_model.h:32
void invalidateAllColumnStrings()
Invalidate any cached column strings.
Definition: packet_list_model.cpp:186
void resetColumns()
Rebuild columns from settings.
Definition: packet_list_model.cpp:227
Definition: packet_list_record.h:29
Definition: progress_frame.h:37
Definition: cfile.h:67