| 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/utils/field_information.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 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 setColumnDelegate();
89 void resetColumns();
90 bool haveNextHistory(bool update_cur = false);
91 bool havePreviousHistory(bool update_cur = false);
92 void setProfileSwitcher(ProfileSwitcher *profile_switcher);
93
94 frame_data * getFDataForRow(int row) const;
95
96 bool uniqueSelectActive();
97 bool multiSelectActive();
98 QList<int> selectedRows(bool useFrameNum = false);
99
100 QString createSummaryText(QModelIndex idx, SummaryCopyType type);
101 QString createHeaderSummaryText(SummaryCopyType type);
102
103 QStringList createHeaderPartsForAligned();
104 QList<int> createAlignmentPartsForAligned();
105 QList<int> createSizePartsForAligned(bool useHeader, QStringList hdr_parts, QList<int> rows);
106 QString createHeaderSummaryForAligned(QStringList hdr_parts, QList<int> align_parts, QList<int> size_parts);
107 QString createSummaryForAligned(QModelIndex idx, QList<int> align_parts, QList<int> size_parts);
108
109 QString createDefaultStyleForHtml();
110 QString createOpeningTagForHtml();
111 QString createHeaderSummaryForHtml();
112 QString createSummaryForHtml(QModelIndex idx);
113 QString createClosingTagForHtml();
114
115 void resizeAllColumns(bool onlyTimeFormatted = false);
116 bool selectRow(const frame_data*, bool = true);
117
118 protected:
119
120 void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) override;
121 virtual void contextMenuEvent(QContextMenuEvent *event) override;
122 void timerEvent(QTimerEvent *event) override;
123 void paintEvent(QPaintEvent *event) override;
124 virtual void mousePressEvent (QMouseEvent *event) override;
125 virtual void mouseReleaseEvent (QMouseEvent *event) override;
126 virtual void mouseMoveEvent (QMouseEvent *event) override;
127 virtual void resizeEvent(QResizeEvent *event) override;
128 virtual void keyPressEvent(QKeyEvent *event) override;
129
130 protected slots:
131 void rowsInserted(const QModelIndex &parent, int start, int end) override;
132 virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option,
133 const QModelIndex &index) const override;
134
135 private:
136 PacketListModel *packet_list_model_;
137 PacketListHeader * packet_list_header_;
138 ProtoTree *proto_tree_;
139 capture_file *cap_file_;
140 QMenu conv_menu_;
141 QMenu colorize_menu_;
142 int ctx_column_;
143 QByteArray column_state_;
144 OverlayScrollBar *overlay_sb_;
145 int overlay_timer_id_;
146 bool create_near_overlay_;
147 bool create_far_overlay_;
148 QVector<QRgb> overlay_colors_;
149 bool changing_profile_;
150
151 QModelIndex mouse_pressed_at_;
152
153 RelatedPacketDelegate related_packet_delegate_;
154 QAction *show_hide_separator_;
155 QList<QAction *>show_hide_actions_;
156 bool capture_in_progress_;
157 bool tail_at_end_;
158 bool columns_changed_;
159 bool set_column_visibility_;
160 bool set_style_sheet_;
161 QModelIndex frozen_current_row_;
162 QModelIndexList frozen_selected_rows_;
163 QVector<int> selection_history_;
164 int cur_history_;
165 bool in_history_;
166 GPtrArray *finfo_array; // Packet data from the last selected packet entry
167 ProfileSwitcher *profile_switcher_;
168
169 void setFrameReftime(bool set, frame_data *fdata);
170 void setColumnVisibility();
171 void setRecentColumnWidth(int column);
172 void drawCurrentPacket();
173 void applyRecentColumnWidths();
174 void scrollViewChanged(bool at_end);
175 QString joinSummaryRow(QStringList col_parts, int row, SummaryCopyType type);
176
177signals:
178 void packetDissectionChanged();
179 void showColumnPreferences(QString pane_name);
180 void editColumn(int column);
181 void packetListScrolled(bool at_end);
182 void showProtocolPreferences(const QString module_name);
183 void editProtocolPreference(pref_t *pref, module_t *module);
184
185 void framesSelected(QList<int>);
186 void fieldSelected(FieldInformation *);
187
188 public slots:
189 void setCaptureFile(capture_file *cf);
190 void setMonospaceFont(const QFont &mono_font);
191 void setRegularFont(const QFont &regular_font);
192 void goNextPacket();
193 void goPreviousPacket();
194 void goFirstPacket();
195 void goLastPacket();
196 void goToPacket(int packet, int hf_id = -1);
197 void goNextHistoryPacket();
198 void goPreviousHistoryPacket();
199 void markFrame();
200 void markAllDisplayedFrames(bool set);
201 void ignoreFrame();
202 void ignoreAllDisplayedFrames(bool set);
203 void setTimeReference();
204 void unsetAllTimeReferences();
205 void applyTimeShift();
206 void recolorPackets();
207 void redrawVisiblePackets();
208 void redrawVisiblePacketsDontSelectCurrent();
209 void colorsChanged();
210 void columnsChanged();
211 void fieldsChanged(capture_file *cf);
212 void preferencesChanged();
213 void freezePacketList(bool changing_profile);
214
215 private slots:
216 void columnVisibilityTriggered();
217 void sectionResized(int col, int, int new_width);
218 void sectionMoved(int, int, int);
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
FieldInformation
Definition field_information.h:23
OverlayScrollBar
Definition overlay_scroll_bar.h:18
PacketListHeader
Definition packet_list_header.h:22
PacketList
Definition packet_list.h:40
PacketList::freeze
bool freeze(bool keep_current_frame=false)
Definition packet_list.cpp:1295
PacketList::thaw
bool thaw(bool restore_selection=false)
Definition packet_list.cpp:1323
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
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