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