Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
packet_list.h
1 /* packet_list.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef PACKET_LIST_H
11 #define PACKET_LIST_H
12 
13 #include "byte_view_tab.h"
14 #include <ui/qt/models/packet_list_model.h>
15 #include "proto_tree.h"
16 #include "protocol_preferences_menu.h"
17 #include <ui/qt/models/related_packet_delegate.h>
18 #include <ui/qt/utils/field_information.h>
19 
20 #include <QMenu>
21 #include <QTime>
22 #include <QTreeView>
23 #include <QPainter>
24 
25 class OverlayScrollBar;
26 
27 class QAction;
28 class QTimerEvent;
29 
30 class PacketList : public QTreeView
31 {
32  Q_OBJECT
33 public:
34  enum ColumnActions {
35  caAlignLeft,
36  caAlignCenter,
37  caAlignRight,
38  caColumnPreferences,
39  caEditColumn,
40  caResolveNames,
41  caResizeToContents,
42  caDisplayedColumns,
43  caHideColumn,
44  caRemoveColumn
45  };
46  explicit PacketList(QWidget *parent = 0);
47  PacketListModel *packetListModel() const;
48  QMenu *conversationMenu() { return &conv_menu_; }
49  QMenu *colorizeMenu() { return &colorize_menu_; }
50  void setProtoTree(ProtoTree *proto_tree);
51 
57  void freeze();
65  void thaw(bool restore_selection = false);
66  void clear();
67  void writeRecent(FILE *rf);
68  bool contextMenuActive();
69  QString getFilterFromRowAndColumn();
70  void resetColorized();
71  QString packetComment();
72  void setPacketComment(QString new_comment);
73  QString allPacketComments();
74  void deleteAllPacketComments();
75  void setVerticalAutoScroll(bool enabled = true);
76  void setCaptureInProgress(bool in_progress = false) { capture_in_progress_ = in_progress; tail_at_end_ = in_progress; }
77  void captureFileReadFinished();
78  void resetColumns();
79  bool haveNextHistory(bool update_cur = false);
80  bool havePreviousHistory(bool update_cur = false);
81 
82 protected:
83  void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
84  void contextMenuEvent(QContextMenuEvent *event);
85  void timerEvent(QTimerEvent *event);
86  void paintEvent(QPaintEvent *event);
87  virtual void mousePressEvent (QMouseEvent *event);
88  virtual void resizeEvent(QResizeEvent *event);
89 
90 protected slots:
91  void rowsInserted(const QModelIndex &parent, int start, int end);
92  void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
93 
94 private:
95  PacketListModel *packet_list_model_;
96  ProtoTree *proto_tree_;
97  capture_file *cap_file_;
98  QMenu ctx_menu_;
99  QMenu conv_menu_;
100  QMenu colorize_menu_;
101  ProtocolPreferencesMenu proto_prefs_menu_;
102  QAction *decode_as_;
103  int ctx_column_;
104  QByteArray column_state_;
105  OverlayScrollBar *overlay_sb_;
106  int overlay_timer_id_;
107  bool create_near_overlay_;
108  bool create_far_overlay_;
109  QVector<QRgb> overlay_colors_;
110 
111  RelatedPacketDelegate related_packet_delegate_;
112  QMenu header_ctx_menu_;
113  QMap<ColumnActions, QAction*> header_actions_;
114  QList<ColumnActions> checkable_actions_;
115  int header_ctx_column_;
116  QAction *show_hide_separator_;
117  QList<QAction *>show_hide_actions_;
118  bool capture_in_progress_;
119  int tail_timer_id_;
120  bool tail_at_end_;
121  bool rows_inserted_;
122  bool columns_changed_;
123  bool set_column_visibility_;
124  int frozen_row_;
125  QVector<int> selection_history_;
126  int cur_history_;
127  bool in_history_;
128 
129  void setFrameReftime(gboolean set, frame_data *fdata);
130  void setColumnVisibility();
131  int sizeHintForColumn(int column) const;
132  void setRecentColumnWidth(int column);
133  void initHeaderContextMenu();
134  void drawCurrentPacket();
135  void applyRecentColumnWidths();
136  void scrollViewChanged(bool at_end);
137 
138 signals:
139  void packetDissectionChanged();
140  void showColumnPreferences(QString pane_name);
141  void editColumn(int column);
142  void packetListScrolled(bool at_end);
143  void showProtocolPreferences(const QString module_name);
144  void editProtocolPreference(struct preference *pref, struct pref_module *module);
145 
146  void frameSelected(int frameNum);
147  void fieldSelected(FieldInformation *);
148 
149 public slots:
150  void setCaptureFile(capture_file *cf);
151  void setMonospaceFont(const QFont &mono_font);
152  void goNextPacket();
153  void goPreviousPacket();
154  void goFirstPacket(bool user_selected = true);
155  void goLastPacket();
156  void goToPacket(int packet);
157  void goToPacket(int packet, int hf_id);
158  void goNextHistoryPacket();
159  void goPreviousHistoryPacket();
160  void markFrame();
161  void markAllDisplayedFrames(bool set);
162  void ignoreFrame();
163  void ignoreAllDisplayedFrames(bool set);
164  void setTimeReference();
165  void unsetAllTimeReferences();
166  void applyTimeShift();
167  void recolorPackets();
168  void redrawVisiblePackets();
169  void redrawVisiblePacketsDontSelectCurrent();
170  void columnsChanged();
171  void fieldsChanged(capture_file *cf);
172  void preferencesChanged();
173 
174 private slots:
175  void showHeaderMenu(QPoint pos);
176  void headerMenuTriggered();
177  void columnVisibilityTriggered();
178  void sectionResized(int col, int, int new_width);
179  void sectionMoved(int, int, int);
180  void updateRowHeights(const QModelIndex &ih_index);
181  void copySummary();
182  void vScrollBarActionTriggered(int);
183  void drawFarOverlay();
184  void drawNearOverlay();
185 };
186 
187 #endif // PACKET_LIST_H
188 
189 /*
190  * Editor modelines
191  *
192  * Local Variables:
193  * c-basic-offset: 4
194  * tab-width: 8
195  * indent-tabs-mode: nil
196  * End:
197  *
198  * ex: set shiftwidth=4 tabstop=8 expandtab:
199  * :indentSize=4:tabSize=8:noTabs=true:
200  */
Definition: field_information.h:21
Definition: packet_list.h:30
Definition: prefs-int.h:27
Definition: proto_tree.h:28
void freeze()
Definition: packet_list.cpp:894
Definition: pcapng.c:148
void thaw(bool restore_selection=false)
Definition: packet_list.cpp:911
Definition: prefs.c:192
Definition: overlay_scroll_bar.h:16
Definition: protocol_preferences_menu.h:19
Definition: packet_list_model.h:31
Definition: frame_data.h:53
Definition: proto.h:759
Definition: cfile.h:58