| 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 virtual void focusInEvent(QFocusEvent *event) override;
131
132 protected slots:
133 void rowsInserted(const QModelIndex &parent, int start, int end) override;
134 virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option,
135 const QModelIndex &index) const override;
136
137 private:
138 PacketListModel *packet_list_model_;
139 PacketListHeader * packet_list_header_;
140 ProtoTree *proto_tree_;
141 capture_file *cap_file_;
142 QMenu conv_menu_;
143 QMenu colorize_menu_;
144 int ctx_column_;
145 QByteArray column_state_;
146 OverlayScrollBar *overlay_sb_;
147 int overlay_timer_id_;
148 bool create_near_overlay_;
149 bool create_far_overlay_;
150 QVector<QRgb> overlay_colors_;
151 bool changing_profile_;
152
153 QModelIndex mouse_pressed_at_;
154
155 RelatedPacketDelegate related_packet_delegate_;
156 MultiColorPacketDelegate multi_color_delegate_;
157 QAction *show_hide_separator_;
158 QList<QAction *>show_hide_actions_;
159 bool capture_in_progress_;
160 bool tail_at_end_;
161 bool columns_changed_;
162 bool set_column_visibility_;
163 bool set_style_sheet_;
164 QModelIndex frozen_current_row_;
165 QModelIndexList frozen_selected_rows_;
166 QVector<int> selection_history_;
167 int cur_history_;
168 bool in_history_;
169 GPtrArray *finfo_array; // Packet data from the last selected packet entry
170 ProfileSwitcher *profile_switcher_;
171
172 void setFrameReftime(bool set, frame_data *fdata);
173 void setColumnVisibility();
174 void setRecentColumnWidth(int column);
175 void drawCurrentPacket();
176 void applyRecentColumnWidths();
177 void scrollViewChanged(bool at_end);
178 QString joinSummaryRow(QStringList col_parts, int row, SummaryCopyType type);
179
180signals:
181 void packetDissectionChanged();
182 void showColumnPreferences(QString pane_name);
183 void editColumn(int column);
184 void packetListScrolled(bool at_end);
185 void showProtocolPreferences(const QString module_name);
186 void editProtocolPreference(pref_t *pref, module_t *module);
187
188 void framesSelected(QList<int>);
189 void fieldSelected(FieldInformation *);
190
191 public slots:
192 void setCaptureFile(capture_file *cf);
193 void setMonospaceFont(const QFont &mono_font);
194 void setRegularFont(const QFont &regular_font);
195 void goNextPacket();
196 void goPreviousPacket();
197 void goFirstPacket();
198 void goLastPacket();
199 void goToPacket(int packet, int hf_id = -1);
200 void goNextHistoryPacket();
201 void goPreviousHistoryPacket();
202 void markFrame();
203 void markAllDisplayedFrames(bool set);
204 void ignoreFrame();
205 void ignoreAllDisplayedFrames(bool set);
206 void setTimeReference();
207 void unsetAllTimeReferences();
208 void applyTimeShift();
209 void recolorPackets();
210 void redrawVisiblePackets();
211 void redrawVisiblePacketsDontSelectCurrent();
212 void colorsChanged();
213 void columnsChanged();
214 void fieldsChanged(capture_file *cf);
215 void preferencesChanged();
216 void freezePacketList(bool changing_profile);
217
218 private slots:
219 void columnVisibilityTriggered();
220 void sectionResized(int col, int, int new_width);
221 void sectionMoved(int, int, int);
222 void copySummary();
223 void vScrollBarActionTriggered(int);
224 void drawFarOverlay();
225 void drawNearOverlay();
226 void updatePackets(bool redraw);
227 void ctxDecodeAsDialog();
228};
229
230#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:1330
PacketList::thaw
bool thaw(bool restore_selection=false)
Definition packet_list.cpp:1358
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:71
_proto_node
Definition proto.h:905
pref_module
Definition prefs-int.h:27
preference
Definition prefs.c:216