| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
packet_list.h
Go to the documentation of this file.
1
9
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
44 class PacketList : public QTreeView
45{
46 Q_OBJECT
47 public:
52 explicit PacketList(QWidget *parent = 0);
53
57 ~PacketList();
58
62 enum SummaryCopyType {
64 CopyAsText,
66 CopyAsCSV,
68 CopyAsYAML,
70 CopyAsHTML
71 };
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
97 void setProtoTree(ProtoTree *proto_tree);
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
178 void deleteCommentsFromPackets();
179
183 void deleteAllPacketComments();
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
201 void captureFileReadFinished();
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
272 QString createHeaderSummaryText(SummaryCopyType type);
273
278 QStringList createHeaderPartsForAligned();
279
284 QList<int> createAlignmentPartsForAligned();
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
317 QString createDefaultStyleForHtml();
318
323 QString createOpeningTagForHtml();
324
329 QString createHeaderSummaryForHtml();
330
336 QString createSummaryForHtml(QModelIndex idx);
337
342 QString createClosingTagForHtml();
343
348 void resizeAllColumns(bool onlyTimeFormatted = false);
349
350 protected:
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
412 protected 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
430 private:
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:
571 void packetDissectionChanged();
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
602 void editProtocolPreference(pref_t *pref, module_t *module);
603
608 void framesSelected(QList<int> frames);
609
614 void fieldSelected(FieldInformation *finfo);
615
616 public slots:
621 void setCaptureFile(capture_file *cf);
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
670 void goPreviousHistoryPacket();
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
702 void unsetAllTimeReferences();
703
707 void applyTimeShift();
708
712 void recolorPackets();
713
717 void redrawVisiblePackets();
718
722 void redrawVisiblePacketsDontSelectCurrent();
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
751 private 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
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
FieldInformation
Represents information about a dissected packet field.
Definition field_information.h:26
MultiColorPacketDelegate
A delegate for rendering multi-colored packet items in a view.
Definition multi_color_packet_delegate.h:25
OverlayScrollBar
A custom scroll bar with overlay images for packet representation.
Definition overlay_scroll_bar.h:21
PacketListHeader
Custom header view for the packet list.
Definition packet_list_header.h:26
PacketList::setRegularFont
void setRegularFont(const QFont &regular_font)
Sets the regular font used in the list.
Definition packet_list.cpp:1663
PacketList::uniqueSelectActive
bool uniqueSelectActive()
Checks if a single unique selection is currently active.
Definition packet_list.cpp:429
PacketList::createSummaryText
QString createSummaryText(QModelIndex idx, SummaryCopyType type)
Creates a summary text for a specific index.
Definition packet_list.cpp:1977
PacketList::allPacketComments
QString allPacketComments()
Retrieves all packet comments in the capture.
Definition packet_list.cpp:1594
PacketList::applyTimeShift
void applyTimeShift()
Applies a time shift to the capture packets.
Definition packet_list.cpp:1852
PacketList::timerEvent
void timerEvent(QTimerEvent *event) override
Handles timer events.
Definition packet_list.cpp:799
PacketList::resizeAllColumns
void resizeAllColumns(bool onlyTimeFormatted=false)
Resizes all columns to fit their content.
Definition packet_list.cpp:2493
PacketList::createHeaderSummaryForAligned
QString createHeaderSummaryForAligned(QStringList hdr_parts, QList< int > align_parts, QList< int > size_parts)
Creates an aligned header summary.
Definition packet_list.cpp:2060
PacketList::setTimeReference
void setTimeReference()
Toggles the time reference status on the currently selected frame.
Definition packet_list.cpp:1838
PacketList::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event) override
Handles mouse move events.
Definition packet_list.cpp:846
PacketList::PacketList
PacketList(QWidget *parent=0)
Constructs a new PacketList object.
Definition packet_list.cpp:211
PacketList::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event) override
Handles key press events.
Definition packet_list.cpp:928
PacketList::markAllDisplayedFrames
void markAllDisplayedFrames(bool set)
Marks or unmarks all displayed frames.
Definition packet_list.cpp:1787
PacketList::createAlignmentPartsForAligned
QList< int > createAlignmentPartsForAligned()
Creates alignment parts for formatting.
Definition packet_list.cpp:2014
PacketList::setPacketComment
void setPacketComment(unsigned c_number, QString new_comment)
Sets the comment for a specific packet.
Definition packet_list.cpp:1570
PacketList::addPacketComment
void addPacketComment(QString new_comment)
Adds a new comment to the currently selected packet.
Definition packet_list.cpp:1544
PacketList::resetColumns
void resetColumns()
Resets the columns to their default state.
Definition packet_list.cpp:1137
PacketList::goPreviousPacket
void goPreviousPacket()
Navigates to the previous packet.
Definition packet_list.cpp:1687
PacketList::setProfileSwitcher
void setProfileSwitcher(ProfileSwitcher *profile_switcher)
Sets the profile switcher for the packet list.
Definition packet_list.cpp:1178
PacketList::redrawVisiblePackets
void redrawVisiblePackets()
Fully redraws all visible packets.
Definition packet_list.cpp:1126
PacketList::freeze
bool freeze(bool keep_current_frame=false)
Disable and clear the packet list.
Definition packet_list.cpp:1331
PacketList::setCaptureInProgress
void setCaptureInProgress(bool in_progress=false, bool auto_scroll=true)
Sets the capture in progress state.
Definition packet_list.h:196
PacketList::colorizeMenu
QMenu * colorizeMenu()
Retrieves the colorize menu.
Definition packet_list.h:91
PacketList::captureFileReadFinished
void captureFileReadFinished()
Handles the event when the capture file has finished reading.
Definition packet_list.cpp:1318
PacketList::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event) override
Handles mouse press events.
Definition packet_list.cpp:820
PacketList::writeRecent
void writeRecent(FILE *rf)
Writes recent configuration to a file.
Definition packet_list.cpp:1417
PacketList::createSizePartsForAligned
QList< int > createSizePartsForAligned(bool useHeader, QStringList hdr_parts, QList< int > rows)
Creates size parts for aligned formatting.
Definition packet_list.cpp:2025
PacketList::deleteCommentsFromPackets
void deleteCommentsFromPackets()
Deletes comments from the selected packets.
Definition packet_list.cpp:1625
PacketList::colorsChanged
void colorsChanged()
Slot triggered when global color configurations change.
Definition packet_list.cpp:320
PacketList::havePreviousHistory
bool havePreviousHistory(bool update_cur=false)
Checks if there is a previous packet in the selection history.
Definition packet_list.cpp:1161
PacketList::focusInEvent
virtual void focusInEvent(QFocusEvent *event) override
Handles focus in events.
Definition packet_list.cpp:1014
PacketList::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *event) override
Handles context menu events.
Definition packet_list.cpp:608
PacketList::scrollTo
virtual void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint=EnsureVisible) override
Scrolls the view to the given index.
Definition packet_list.cpp:307
PacketList::editColumn
void editColumn(int column)
Signal emitted to trigger editing for a specific column.
PacketList::createOpeningTagForHtml
QString createOpeningTagForHtml()
Creates the opening tag block for HTML summaries.
Definition packet_list.cpp:2112
PacketList::conversationMenu
QMenu * conversationMenu()
Retrieves the conversation menu.
Definition packet_list.h:85
PacketList::setColumnDelegate
void setColumnDelegate()
Sets the column delegate for the view.
Definition packet_list.cpp:1053
PacketList::haveNextHistory
bool haveNextHistory(bool update_cur=false)
Checks if there is a next packet in the selection history.
Definition packet_list.cpp:1143
PacketList::thaw
bool thaw(bool restore_selection=false)
Enable and restore the packet list.
Definition packet_list.cpp:1359
PacketList::goNextPacket
void goNextPacket()
Navigates to the next packet.
Definition packet_list.cpp:1669
PacketList::drawRow
virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Custom drawing logic for a row.
Definition packet_list.cpp:409
PacketList::setProtoTree
void setProtoTree(ProtoTree *proto_tree)
Sets the protocol tree.
Definition packet_list.cpp:421
PacketList::goToPacket
void goToPacket(int packet, int hf_id=-1)
Jumps directly to a specific packet number.
Definition packet_list.cpp:1726
PacketList::showProtocolPreferences
void showProtocolPreferences(const QString module_name)
Signal emitted to show protocol specific preferences.
PacketList::clear
void clear()
Clears the packet list.
Definition packet_list.cpp:1401
PacketList::goNextHistoryPacket
void goNextHistoryPacket()
Navigates to the next packet in the selection history.
Definition packet_list.cpp:1740
PacketList::multiSelectActive
bool multiSelectActive()
Checks if multiple selections are currently active.
Definition packet_list.cpp:434
PacketList::getFilterFromRowAndColumn
QString getFilterFromRowAndColumn(QModelIndex idx)
Retrieves the filter string based on a given row and column.
Definition packet_list.cpp:1447
PacketList::~PacketList
~PacketList()
Destroys the PacketList object.
Definition packet_list.cpp:299
PacketList::packetListScrolled
void packetListScrolled(bool at_end)
Signal emitted when the packet list has been scrolled.
PacketList::deleteAllPacketComments
void deleteAllPacketComments()
Deletes all packet comments in the capture.
Definition packet_list.cpp:1635
PacketList::setMonospaceFont
void setMonospaceFont(const QFont &mono_font)
Sets the monospace font used in the list.
Definition packet_list.cpp:1658
PacketList::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *event) override
Handles mouse release events.
Definition packet_list.cpp:840
PacketList::goPreviousHistoryPacket
void goPreviousHistoryPacket()
Navigates to the previous packet in the selection history.
Definition packet_list.cpp:1749
PacketList::packetDissectionChanged
void packetDissectionChanged()
Signal emitted when packet dissection data changes.
PacketList::selectedRows
QList< int > selectedRows(bool useFrameNum=false)
Retrieves a list of selected row numbers.
Definition packet_list.cpp:439
PacketList::columnsChanged
void columnsChanged()
Slot triggered when the column configuration changes.
Definition packet_list.cpp:1192
PacketList::goFirstPacket
void goFirstPacket()
Navigates to the very first packet.
Definition packet_list.cpp:1710
PacketList::selectionChanged
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
Handles selection change events.
Definition packet_list.cpp:478
PacketList::freezePacketList
void freezePacketList(bool changing_profile)
Slot to trigger freezing the packet list state.
Definition packet_list.cpp:1295
PacketList::redrawVisiblePacketsDontSelectCurrent
void redrawVisiblePacketsDontSelectCurrent()
Redraws all visible packets without modifying the current selection.
Definition packet_list.cpp:1133
PacketList::goLastPacket
void goLastPacket()
Navigates to the very last packet.
Definition packet_list.cpp:1718
PacketList::resetColorized
void resetColorized()
Resets the colorized state of the packets.
Definition packet_list.cpp:1515
PacketList::createDefaultStyleForHtml
QString createDefaultStyleForHtml()
Retrieves the default CSS style for HTML summaries.
Definition packet_list.cpp:2100
PacketList::createHeaderSummaryText
QString createHeaderSummaryText(SummaryCopyType type)
Creates the header summary text.
Definition packet_list.cpp:1992
PacketList::editProtocolPreference
void editProtocolPreference(pref_t *pref, module_t *module)
Signal emitted to edit a specific protocol preference.
PacketList::rowsInserted
void rowsInserted(const QModelIndex &parent, int start, int end) override
Slot triggered when rows are inserted into the model.
Definition packet_list.cpp:2475
PacketList::createClosingTagForHtml
QString createClosingTagForHtml()
Creates the closing tag block for HTML summaries.
Definition packet_list.cpp:2158
PacketList::createSummaryForAligned
QString createSummaryForAligned(QModelIndex idx, QList< int > align_parts, QList< int > size_parts)
Creates an aligned summary for a specific index.
Definition packet_list.cpp:2074
PacketList::recolorPackets
void recolorPackets()
Recolors the displayed packets based on rules.
Definition packet_list.cpp:1301
PacketList::unsetAllTimeReferences
void unsetAllTimeReferences()
Unsets all time reference flags on all frames.
Definition packet_list.cpp:1845
PacketList::createHeaderSummaryForHtml
QString createHeaderSummaryForHtml()
Creates the HTML header summary.
Definition packet_list.cpp:2117
PacketList::createHeaderPartsForAligned
QStringList createHeaderPartsForAligned()
Creates string parts for aligned headers.
Definition packet_list.cpp:2003
PacketList::setVerticalAutoScroll
void setVerticalAutoScroll(bool enabled=true)
Enables or disables vertical auto-scrolling.
Definition packet_list.cpp:1308
PacketList::fieldsChanged
void fieldsChanged(capture_file *cf)
Slot triggered when global fields configuration changes.
Definition packet_list.cpp:1213
PacketList::fieldSelected
void fieldSelected(FieldInformation *finfo)
Signal emitted when a specific field is selected.
PacketList::paintEvent
void paintEvent(QPaintEvent *event) override
Handles paint events.
Definition packet_list.cpp:811
PacketList::setCaptureFile
void setCaptureFile(capture_file *cf)
Sets the active capture file.
Definition packet_list.cpp:1646
PacketList::getPacketComment
QString getPacketComment(unsigned c_number)
Retrieves the comment for a specific packet.
Definition packet_list.cpp:1521
PacketList::createSummaryForHtml
QString createSummaryForHtml(QModelIndex idx)
Creates an HTML summary for a specific index.
Definition packet_list.cpp:2132
PacketList::contextMenuActive
bool contextMenuActive()
Checks if the context menu is currently active.
Definition packet_list.cpp:1442
PacketList::SummaryCopyType
SummaryCopyType
Types of formats available for copying packet summaries.
Definition packet_list.h:62
PacketList::CopyAsYAML
@ CopyAsYAML
Copy summary as YAML format.
Definition packet_list.h:68
PacketList::CopyAsHTML
@ CopyAsHTML
Copy summary as HTML format.
Definition packet_list.h:70
PacketList::CopyAsCSV
@ CopyAsCSV
Copy summary as Comma-Separated Values (CSV).
Definition packet_list.h:66
PacketList::CopyAsText
@ CopyAsText
Copy summary as plain text.
Definition packet_list.h:64
PacketList::resizeEvent
virtual void resizeEvent(QResizeEvent *event) override
Handles resize events.
Definition packet_list.cpp:1036
PacketList::framesSelected
void framesSelected(QList< int > frames)
Signal emitted when multiple frames are selected.
PacketList::ignoreAllDisplayedFrames
void ignoreAllDisplayedFrames(bool set)
Ignores or un-ignores all displayed frames.
Definition packet_list.cpp:1829
PacketList::ignoreFrame
void ignoreFrame()
Toggles the ignore status of the currently selected frame.
Definition packet_list.cpp:1800
PacketList::preferencesChanged
void preferencesChanged()
Slot triggered when global preferences have changed.
Definition packet_list.cpp:1253
PacketList::markFrame
void markFrame()
Toggles the mark on the currently selected frame.
Definition packet_list.cpp:1758
PacketList::showColumnPreferences
void showColumnPreferences(QString pane_name)
Signal emitted to show preferences for a specific pane.
PacketList::getFDataForRow
frame_data * getFDataForRow(int row) const
Retrieves the frame data for a specific row.
Definition packet_list.cpp:1186
PacketListModel
A Qt item model representing the list of packets in a capture file.
Definition packet_list_model.h:36
ProfileSwitcher
Monitors incoming packets and automatically switches the active configuration profile when a packet m...
Definition profile_switcher.h:38
ProtoTree
A tree view for displaying protocol dissection details.
Definition proto_tree.h:30
RelatedPacketDelegate
Item delegate that visually annotates packet-list rows with relationship indicators — arrows,...
Definition related_packet_delegate.h:29
data_source_tab.h
field_information.h
frame_data
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
multi_color_packet_delegate.h
packet_list_model.h
proto_tree.h
related_packet_delegate.h