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"
15#include "proto_tree.h"
20
21#include <QMenu>
22#include <QTime>
23#include <QTreeView>
24#include <QPainter>
25
28class ProfileSwitcher;
29
30class QAction;
31class 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
44class PacketList : public QTreeView
45{
46 Q_OBJECT
47public:
52 explicit PacketList(QWidget *parent = 0);
53
58
72 Q_ENUM(SummaryCopyType)
73
74
79 virtual void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint = EnsureVisible) override;
80
85 QMenu *conversationMenu() { return &conv_menu_; }
86
91 QMenu *colorizeMenu() { return &colorize_menu_; }
92
98
107 bool freeze(bool keep_current_frame = false);
108
118 bool thaw(bool restore_selection = false);
119
123 void clear();
124
129 void writeRecent(FILE *rf);
130
135 bool contextMenuActive();
136
142 QString getFilterFromRowAndColumn(QModelIndex idx);
143
147 void resetColorized();
148
154 QString getPacketComment(unsigned c_number);
155
160 void addPacketComment(QString new_comment);
161
167 void setPacketComment(unsigned c_number, QString new_comment);
168
173 QString allPacketComments();
174
179
184
189 void setVerticalAutoScroll(bool enabled = true);
190
196 void setCaptureInProgress(bool in_progress = false, bool auto_scroll = true) { capture_in_progress_ = in_progress; tail_at_end_ = in_progress && auto_scroll; }
197
202
206 void setColumnDelegate();
207
211 void resetColumns();
212
218 bool haveNextHistory(bool update_cur = false);
219
225 bool havePreviousHistory(bool update_cur = false);
226
231 void setProfileSwitcher(ProfileSwitcher *profile_switcher);
232
238 frame_data * getFDataForRow(int row) const;
239
244 bool uniqueSelectActive();
245
250 bool multiSelectActive();
251
257 QList<int> selectedRows(bool useFrameNum = false);
258
265 QString createSummaryText(QModelIndex idx, SummaryCopyType type);
266
273
278 QStringList createHeaderPartsForAligned();
279
285
293 QList<int> createSizePartsForAligned(bool useHeader, QStringList hdr_parts, QList<int> rows);
294
302 QString createHeaderSummaryForAligned(QStringList hdr_parts, QList<int> align_parts, QList<int> size_parts);
303
311 QString createSummaryForAligned(QModelIndex idx, QList<int> align_parts, QList<int> size_parts);
312
318
323 QString createOpeningTagForHtml();
324
330
336 QString createSummaryForHtml(QModelIndex idx);
337
342 QString createClosingTagForHtml();
343
348 void resizeAllColumns(bool onlyTimeFormatted = false);
349
350protected:
356 void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) override;
357
362 virtual void contextMenuEvent(QContextMenuEvent *event) override;
363
368 void timerEvent(QTimerEvent *event) override;
369
374 void paintEvent(QPaintEvent *event) override;
375
380 virtual void mousePressEvent (QMouseEvent *event) override;
381
386 virtual void mouseReleaseEvent (QMouseEvent *event) override;
387
392 virtual void mouseMoveEvent (QMouseEvent *event) override;
393
398 virtual void resizeEvent(QResizeEvent *event) override;
399
404 virtual void keyPressEvent(QKeyEvent *event) override;
405
410 virtual void focusInEvent(QFocusEvent *event) override;
411
412protected slots:
419 void rowsInserted(const QModelIndex &parent, int start, int end) override;
420
427 virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option,
428 const QModelIndex &index) const override;
429
430private:
432 PacketListModel *packet_list_model_;
433
435 PacketListHeader * packet_list_header_;
436
438 ProtoTree *proto_tree_;
439
441 capture_file *cap_file_;
442
444 QMenu conv_menu_;
445
447 QMenu colorize_menu_;
448
450 int ctx_column_;
451
453 QByteArray column_state_;
454
456 OverlayScrollBar *overlay_sb_;
457
459 int overlay_timer_id_;
460
462 bool create_near_overlay_;
463
465 bool create_far_overlay_;
466
468 QVector<QRgb> overlay_colors_;
469
471 bool changing_profile_;
472
474 QModelIndex mouse_pressed_at_;
475
477 RelatedPacketDelegate related_packet_delegate_;
478
480 MultiColorPacketDelegate multi_color_delegate_;
481
483 QAction *show_hide_separator_;
484
486 QList<QAction *>show_hide_actions_;
487
489 bool capture_in_progress_;
490
492 bool tail_at_end_;
493
495 bool columns_changed_;
496
498 bool set_column_visibility_;
499
501 bool set_style_sheet_;
502
504 QModelIndex frozen_current_row_;
505
507 QModelIndexList frozen_selected_rows_;
508
510 QVector<int> selection_history_;
511
513 int cur_history_;
514
516 bool in_history_;
517
519 GPtrArray *finfo_array;
520
522 ProfileSwitcher *profile_switcher_;
523
529 void setFrameReftime(bool set, frame_data *fdata);
530
534 void setColumnVisibility();
535
540 void setRecentColumnWidth(int column);
541
545 void drawCurrentPacket();
546
550 void applyRecentColumnWidths();
551
556 void scrollViewChanged(bool at_end);
557
565 QString joinSummaryRow(QStringList col_parts, int row, SummaryCopyType type);
566
567signals:
572
577 void showColumnPreferences(QString pane_name);
578
583 void editColumn(int column);
584
589 void packetListScrolled(bool at_end);
590
595 void showProtocolPreferences(const QString module_name);
596
603
608 void framesSelected(QList<int> frames);
609
615
616public slots:
622
627 void setMonospaceFont(const QFont &mono_font);
628
633 void setRegularFont(const QFont &regular_font);
634
638 void goNextPacket();
639
643 void goPreviousPacket();
644
648 void goFirstPacket();
649
653 void goLastPacket();
654
660 void goToPacket(int packet, int hf_id = -1);
661
665 void goNextHistoryPacket();
666
671
675 void markFrame();
676
681 void markAllDisplayedFrames(bool set);
682
686 void ignoreFrame();
687
692 void ignoreAllDisplayedFrames(bool set);
693
697 void setTimeReference();
698
703
707 void applyTimeShift();
708
712 void recolorPackets();
713
718
723
727 void colorsChanged();
728
732 void columnsChanged();
733
738 void fieldsChanged(capture_file *cf);
739
743 void preferencesChanged();
744
749 void freezePacketList(bool changing_profile);
750
751private slots:
755 void columnVisibilityTriggered();
756
762 void sectionResized(int col, int, int new_width);
763
770 void sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
771
775 void copySummary();
776
780 void vScrollBarActionTriggered(int);
781
785 void drawFarOverlay();
786
790 void drawNearOverlay();
791
796 void updatePackets(bool redraw);
797
801 void ctxDecodeAsDialog();
802};
803
804#endif // PACKET_LIST_H
Represents information about a dissected packet field.
Definition field_information.h:26
A delegate for rendering multi-colored packet items in a view.
Definition multi_color_packet_delegate.h:25
A custom scroll bar with overlay images for packet representation.
Definition overlay_scroll_bar.h:21
Custom header view for the packet list.
Definition packet_list_header.h:25
The main packet list view for displaying captured packets.
Definition packet_list.h:45
void setRegularFont(const QFont &regular_font)
Sets the regular font used in the list.
Definition packet_list.cpp:1657
bool uniqueSelectActive()
Checks if a single unique selection is currently active.
Definition packet_list.cpp:422
QString createSummaryText(QModelIndex idx, SummaryCopyType type)
Creates a summary text for a specific index.
Definition packet_list.cpp:1971
QString allPacketComments()
Retrieves all packet comments in the capture.
Definition packet_list.cpp:1588
void applyTimeShift()
Applies a time shift to the capture packets.
Definition packet_list.cpp:1846
void timerEvent(QTimerEvent *event) override
Handles timer events.
Definition packet_list.cpp:792
void resizeAllColumns(bool onlyTimeFormatted=false)
Resizes all columns to fit their content.
Definition packet_list.cpp:2487
QString createHeaderSummaryForAligned(QStringList hdr_parts, QList< int > align_parts, QList< int > size_parts)
Creates an aligned header summary.
Definition packet_list.cpp:2054
void setTimeReference()
Toggles the time reference status on the currently selected frame.
Definition packet_list.cpp:1832
virtual void mouseMoveEvent(QMouseEvent *event) override
Handles mouse move events.
Definition packet_list.cpp:839
virtual void keyPressEvent(QKeyEvent *event) override
Handles key press events.
Definition packet_list.cpp:921
void markAllDisplayedFrames(bool set)
Marks or unmarks all displayed frames.
Definition packet_list.cpp:1781
QList< int > createAlignmentPartsForAligned()
Creates alignment parts for formatting.
Definition packet_list.cpp:2008
void setPacketComment(unsigned c_number, QString new_comment)
Sets the comment for a specific packet.
Definition packet_list.cpp:1564
void addPacketComment(QString new_comment)
Adds a new comment to the currently selected packet.
Definition packet_list.cpp:1538
void resetColumns()
Resets the columns to their default state.
Definition packet_list.cpp:1131
void goPreviousPacket()
Navigates to the previous packet.
Definition packet_list.cpp:1681
void setProfileSwitcher(ProfileSwitcher *profile_switcher)
Sets the profile switcher for the packet list.
Definition packet_list.cpp:1172
void redrawVisiblePackets()
Fully redraws all visible packets.
Definition packet_list.cpp:1120
bool freeze(bool keep_current_frame=false)
Disable and clear the packet list.
Definition packet_list.cpp:1325
void setCaptureInProgress(bool in_progress=false, bool auto_scroll=true)
Sets the capture in progress state.
Definition packet_list.h:196
QMenu * colorizeMenu()
Retrieves the colorize menu.
Definition packet_list.h:91
void captureFileReadFinished()
Handles the event when the capture file has finished reading.
Definition packet_list.cpp:1312
virtual void mousePressEvent(QMouseEvent *event) override
Handles mouse press events.
Definition packet_list.cpp:813
void writeRecent(FILE *rf)
Writes recent configuration to a file.
Definition packet_list.cpp:1411
QList< int > createSizePartsForAligned(bool useHeader, QStringList hdr_parts, QList< int > rows)
Creates size parts for aligned formatting.
Definition packet_list.cpp:2019
void deleteCommentsFromPackets()
Deletes comments from the selected packets.
Definition packet_list.cpp:1619
void colorsChanged()
Slot triggered when global color configurations change.
Definition packet_list.cpp:313
bool havePreviousHistory(bool update_cur=false)
Checks if there is a previous packet in the selection history.
Definition packet_list.cpp:1155
virtual void focusInEvent(QFocusEvent *event) override
Handles focus in events.
Definition packet_list.cpp:1007
virtual void contextMenuEvent(QContextMenuEvent *event) override
Handles context menu events.
Definition packet_list.cpp:601
virtual void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint=EnsureVisible) override
Scrolls the view to the given index.
Definition packet_list.cpp:300
void editColumn(int column)
Signal emitted to trigger editing for a specific column.
QString createOpeningTagForHtml()
Creates the opening tag block for HTML summaries.
Definition packet_list.cpp:2106
QMenu * conversationMenu()
Retrieves the conversation menu.
Definition packet_list.h:85
void setColumnDelegate()
Sets the column delegate for the view.
Definition packet_list.cpp:1046
bool haveNextHistory(bool update_cur=false)
Checks if there is a next packet in the selection history.
Definition packet_list.cpp:1137
bool thaw(bool restore_selection=false)
Enable and restore the packet list.
Definition packet_list.cpp:1353
void goNextPacket()
Navigates to the next packet.
Definition packet_list.cpp:1663
virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Custom drawing logic for a row.
Definition packet_list.cpp:402
void setProtoTree(ProtoTree *proto_tree)
Sets the protocol tree.
Definition packet_list.cpp:414
void goToPacket(int packet, int hf_id=-1)
Jumps directly to a specific packet number.
Definition packet_list.cpp:1720
void showProtocolPreferences(const QString module_name)
Signal emitted to show protocol specific preferences.
void clear()
Clears the packet list.
Definition packet_list.cpp:1395
void goNextHistoryPacket()
Navigates to the next packet in the selection history.
Definition packet_list.cpp:1734
bool multiSelectActive()
Checks if multiple selections are currently active.
Definition packet_list.cpp:427
QString getFilterFromRowAndColumn(QModelIndex idx)
Retrieves the filter string based on a given row and column.
Definition packet_list.cpp:1441
~PacketList()
Destroys the PacketList object.
Definition packet_list.cpp:292
void packetListScrolled(bool at_end)
Signal emitted when the packet list has been scrolled.
void deleteAllPacketComments()
Deletes all packet comments in the capture.
Definition packet_list.cpp:1629
void setMonospaceFont(const QFont &mono_font)
Sets the monospace font used in the list.
Definition packet_list.cpp:1652
virtual void mouseReleaseEvent(QMouseEvent *event) override
Handles mouse release events.
Definition packet_list.cpp:833
void goPreviousHistoryPacket()
Navigates to the previous packet in the selection history.
Definition packet_list.cpp:1743
void packetDissectionChanged()
Signal emitted when packet dissection data changes.
QList< int > selectedRows(bool useFrameNum=false)
Retrieves a list of selected row numbers.
Definition packet_list.cpp:432
void columnsChanged()
Slot triggered when the column configuration changes.
Definition packet_list.cpp:1186
void goFirstPacket()
Navigates to the very first packet.
Definition packet_list.cpp:1704
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
Handles selection change events.
Definition packet_list.cpp:471
void freezePacketList(bool changing_profile)
Slot to trigger freezing the packet list state.
Definition packet_list.cpp:1289
void redrawVisiblePacketsDontSelectCurrent()
Redraws all visible packets without modifying the current selection.
Definition packet_list.cpp:1127
void goLastPacket()
Navigates to the very last packet.
Definition packet_list.cpp:1712
void resetColorized()
Resets the colorized state of the packets.
Definition packet_list.cpp:1509
QString createDefaultStyleForHtml()
Retrieves the default CSS style for HTML summaries.
Definition packet_list.cpp:2094
QString createHeaderSummaryText(SummaryCopyType type)
Creates the header summary text.
Definition packet_list.cpp:1986
void editProtocolPreference(pref_t *pref, module_t *module)
Signal emitted to edit a specific protocol preference.
void rowsInserted(const QModelIndex &parent, int start, int end) override
Slot triggered when rows are inserted into the model.
Definition packet_list.cpp:2469
QString createClosingTagForHtml()
Creates the closing tag block for HTML summaries.
Definition packet_list.cpp:2152
QString createSummaryForAligned(QModelIndex idx, QList< int > align_parts, QList< int > size_parts)
Creates an aligned summary for a specific index.
Definition packet_list.cpp:2068
void recolorPackets()
Recolors the displayed packets based on rules.
Definition packet_list.cpp:1295
void unsetAllTimeReferences()
Unsets all time reference flags on all frames.
Definition packet_list.cpp:1839
QString createHeaderSummaryForHtml()
Creates the HTML header summary.
Definition packet_list.cpp:2111
QStringList createHeaderPartsForAligned()
Creates string parts for aligned headers.
Definition packet_list.cpp:1997
void setVerticalAutoScroll(bool enabled=true)
Enables or disables vertical auto-scrolling.
Definition packet_list.cpp:1302
void fieldsChanged(capture_file *cf)
Slot triggered when global fields configuration changes.
Definition packet_list.cpp:1207
void fieldSelected(FieldInformation *finfo)
Signal emitted when a specific field is selected.
void paintEvent(QPaintEvent *event) override
Handles paint events.
Definition packet_list.cpp:804
void setCaptureFile(capture_file *cf)
Sets the active capture file.
Definition packet_list.cpp:1640
QString getPacketComment(unsigned c_number)
Retrieves the comment for a specific packet.
Definition packet_list.cpp:1515
QString createSummaryForHtml(QModelIndex idx)
Creates an HTML summary for a specific index.
Definition packet_list.cpp:2126
bool contextMenuActive()
Checks if the context menu is currently active.
Definition packet_list.cpp:1436
SummaryCopyType
Types of formats available for copying packet summaries.
Definition packet_list.h:62
@ CopyAsYAML
Copy summary as YAML format.
Definition packet_list.h:68
@ CopyAsHTML
Copy summary as HTML format.
Definition packet_list.h:70
@ CopyAsCSV
Copy summary as Comma-Separated Values (CSV).
Definition packet_list.h:66
@ CopyAsText
Copy summary as plain text.
Definition packet_list.h:64
virtual void resizeEvent(QResizeEvent *event) override
Handles resize events.
Definition packet_list.cpp:1029
void framesSelected(QList< int > frames)
Signal emitted when multiple frames are selected.
void ignoreAllDisplayedFrames(bool set)
Ignores or un-ignores all displayed frames.
Definition packet_list.cpp:1823
void ignoreFrame()
Toggles the ignore status of the currently selected frame.
Definition packet_list.cpp:1794
void preferencesChanged()
Slot triggered when global preferences have changed.
Definition packet_list.cpp:1247
void markFrame()
Toggles the mark on the currently selected frame.
Definition packet_list.cpp:1752
void showColumnPreferences(QString pane_name)
Signal emitted to show preferences for a specific pane.
frame_data * getFDataForRow(int row) const
Retrieves the frame data for a specific row.
Definition packet_list.cpp:1180
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
Monitors incoming packets and automatically switches the active configuration profile when a packet m...
Definition profile_switcher.h:38
A tree view for displaying protocol dissection details.
Definition proto_tree.h:30
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
Represents a capture file and its associated metadata.
Definition cfile.h:84
Definition proto.h:909
Represents a preference module grouping related preferences under a named, hierarchical entry in the ...
Definition prefs-int.h:27
Definition prefs.c:207