| Wireshark 4.7.0 The Wireshark network protocol analyzer

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