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