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