Wireshark  4.3.0
The Wireshark network protocol analyzer
packet_list.h
Go to the documentation of this file.
1 
10 #ifndef PACKET_LIST_H
11 #define PACKET_LIST_H
12 
13 #include "byte_view_tab.h"
15 #include "proto_tree.h"
19 
20 #include <QMenu>
21 #include <QTime>
22 #include <QTreeView>
23 #include <QPainter>
24 
25 class PacketListHeader;
26 class OverlayScrollBar;
27 
28 class QAction;
29 class QTimerEvent;
30 
31 //
32 // XXX - Wireshark supports up to 2^32-1 packets in a capture, but
33 // row numbers in a QAbstractItemModel are ints, not unsigned ints,
34 // so we can only have 2^31-1 rows on ILP32, LP64, and LLP64 platforms.
35 // Does that mean we're permanently stuck at a maximum of 2^31-1 packets
36 // per capture?
37 //
38 class PacketList : public QTreeView
39 {
40  Q_OBJECT
41 public:
42  explicit PacketList(QWidget *parent = 0);
43  ~PacketList();
44 
45  enum SummaryCopyType {
46  CopyAsText,
47  CopyAsCSV,
48  CopyAsYAML
49  };
50  Q_ENUM(SummaryCopyType)
51 
52  QMenu *conversationMenu() { return &conv_menu_; }
53  QMenu *colorizeMenu() { return &colorize_menu_; }
54  void setProtoTree(ProtoTree *proto_tree);
55 
62  bool freeze(bool keep_current_frame = false);
70  bool thaw(bool restore_selection = false);
71  void clear();
72  void writeRecent(FILE *rf);
73  bool contextMenuActive();
74  QString getFilterFromRowAndColumn(QModelIndex idx);
75  void resetColorized();
76  QString getPacketComment(guint c_number);
77  void addPacketComment(QString new_comment);
78  void setPacketComment(guint c_number, QString new_comment);
79  QString allPacketComments();
80  void deleteCommentsFromPackets();
81  void deleteAllPacketComments();
82  void setVerticalAutoScroll(bool enabled = true);
83  void setCaptureInProgress(bool in_progress = false, bool auto_scroll = true) { capture_in_progress_ = in_progress; tail_at_end_ = in_progress && auto_scroll; }
84  void captureFileReadFinished();
85  void resetColumns();
86  bool haveNextHistory(bool update_cur = false);
87  bool havePreviousHistory(bool update_cur = false);
88 
89  frame_data * getFDataForRow(int row) const;
90 
91  bool uniqueSelectActive();
92  bool multiSelectActive();
93  QList<int> selectedRows(bool useFrameNum = false);
94 
95  QString createSummaryText(QModelIndex idx, SummaryCopyType type);
96  QString createHeaderSummaryText(SummaryCopyType type);
97 
98  void resizeAllColumns(bool onlyTimeFormatted = false);
99 
100 protected:
101 
102  void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) override;
103  virtual void contextMenuEvent(QContextMenuEvent *event) override;
104  void timerEvent(QTimerEvent *event) override;
105  void paintEvent(QPaintEvent *event) override;
106  virtual void mousePressEvent (QMouseEvent *event) override;
107  virtual void mouseReleaseEvent (QMouseEvent *event) override;
108  virtual void mouseMoveEvent (QMouseEvent *event) override;
109  virtual void resizeEvent(QResizeEvent *event) override;
110  virtual void keyPressEvent(QKeyEvent *event) override;
111 
112 protected slots:
113  void rowsInserted(const QModelIndex &parent, int start, int end) override;
114  virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option,
115  const QModelIndex &index) const override;
116 
117 private:
118  PacketListModel *packet_list_model_;
119  PacketListHeader * packet_list_header_;
120  ProtoTree *proto_tree_;
121  capture_file *cap_file_;
122  QMenu conv_menu_;
123  QMenu colorize_menu_;
124  QMenu proto_prefs_menus_;
125  int ctx_column_;
126  QByteArray column_state_;
127  OverlayScrollBar *overlay_sb_;
128  int overlay_timer_id_;
129  bool create_near_overlay_;
130  bool create_far_overlay_;
131  QVector<QRgb> overlay_colors_;
132  bool changing_profile_;
133 
134  QModelIndex mouse_pressed_at_;
135 
136  RelatedPacketDelegate related_packet_delegate_;
137  QAction *show_hide_separator_;
138  QList<QAction *>show_hide_actions_;
139  bool capture_in_progress_;
140  bool tail_at_end_;
141  bool columns_changed_;
142  bool set_column_visibility_;
143  QModelIndex frozen_current_row_;
144  QModelIndexList frozen_selected_rows_;
145  QVector<int> selection_history_;
146  int cur_history_;
147  bool in_history_;
148  GPtrArray *finfo_array; // Packet data from the last selected packet entry
149 
150  void setFrameReftime(gboolean set, frame_data *fdata);
151  void setColumnVisibility();
152  int sizeHintForColumn(int column) const override;
153  void setRecentColumnWidth(int column);
154  void drawCurrentPacket();
155  void applyRecentColumnWidths();
156  void scrollViewChanged(bool at_end);
157  void colorsChanged();
158  QString joinSummaryRow(QStringList col_parts, int row, SummaryCopyType type);
159 
160 signals:
161  void packetDissectionChanged();
162  void showColumnPreferences(QString pane_name);
163  void editColumn(int column);
164  void packetListScrolled(bool at_end);
165  void showProtocolPreferences(const QString module_name);
166  void editProtocolPreference(struct preference *pref, struct pref_module *module);
167 
168  void framesSelected(QList<int>);
169  void fieldSelected(FieldInformation *);
170 
171 public slots:
172  void setCaptureFile(capture_file *cf);
173  void setMonospaceFont(const QFont &mono_font);
174  void goNextPacket();
175  void goPreviousPacket();
176  void goFirstPacket();
177  void goLastPacket();
178  void goToPacket(int packet, int hf_id = -1);
179  void goNextHistoryPacket();
180  void goPreviousHistoryPacket();
181  void markFrame();
182  void markAllDisplayedFrames(bool set);
183  void ignoreFrame();
184  void ignoreAllDisplayedFrames(bool set);
185  void setTimeReference();
186  void unsetAllTimeReferences();
187  void applyTimeShift();
188  void recolorPackets();
189  void redrawVisiblePackets();
190  void redrawVisiblePacketsDontSelectCurrent();
191  void columnsChanged();
192  void fieldsChanged(capture_file *cf);
193  void preferencesChanged();
194  void freezePacketList(bool changing_profile);
195 
196 private slots:
197  void columnVisibilityTriggered();
198  void sectionResized(int col, int, int new_width);
199  void sectionMoved(int, int, int);
200  void updateRowHeights(const QModelIndex &ih_index);
201  void copySummary();
202  void vScrollBarActionTriggered(int);
203  void drawFarOverlay();
204  void drawNearOverlay();
205  void updatePackets(bool redraw);
206  void ctxDecodeAsDialog();
207 };
208 
209 #endif // PACKET_LIST_H
Definition: field_information.h:23
Definition: overlay_scroll_bar.h:18
Definition: packet_list_header.h:22
Definition: packet_list.h:39
bool freeze(bool keep_current_frame=false)
Definition: packet_list.cpp:1256
bool thaw(bool restore_selection=false)
Definition: packet_list.cpp:1284
Definition: packet_list_model.h:34
Definition: proto_tree.h:29
Definition: cfile.h:67
Definition: proto.h:897
Definition: prefs-int.h:27
Definition: prefs.c:200