Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tap_parameter_dialog.h
Go to the documentation of this file.
1
10#ifndef TAP_PARAMETER_DIALOG_H
11#define TAP_PARAMETER_DIALOG_H
12
13/*
14 * @file Base class for statistics and analysis dialogs.
15 * Provides convenience classes for command-line tap parameters ("-z ...")
16 * and general tapping.
17 */
18
19#include "config.h"
20
21#include <epan/stat_groups.h>
22#include <epan/stat_tap_ui.h>
23
24#include <QMenu>
25
26#include "filter_action.h"
27#include "wireshark_dialog.h"
28
29class QHBoxLayout;
30class QLineEdit;
31class QTreeWidget;
32class QTreeWidgetItem;
33class QVBoxLayout;
34
35namespace Ui {
37}
38
48typedef TapParameterDialog *(*tpdCreator)(QWidget &parent, const QString cfg_str,
49 const QString arg, CaptureFile &cf);
50
51
58{
59 Q_OBJECT
60
61public:
68 explicit TapParameterDialog(QWidget &parent, CaptureFile &cf, int help_topic = 0);
69
74
79 static const QString &actionName() { return action_name_; }
80
90 static void registerDialog(const QString title, const char *cfg_abbr,
92 stat_tap_init_cb tap_init_cb,
93 tpdCreator creator);
94
103 static TapParameterDialog *showTapParameterStatistics(QWidget &parent, CaptureFile &cf,
104 const QString cfg_str,
105 const QString arg, void *);
106
107 // Needed by static member functions in subclasses. Should we just make
108 // "ui" available instead?
113 QTreeWidget *statsTreeWidget();
114
119 QLineEdit *displayFilterLineEdit();
120
125 QPushButton *applyFilterButton();
126
132 QVBoxLayout *verticalLayout();
133
138 QHBoxLayout *filterLayout();
139
144 void drawTreeItems();
145
146signals:
154
159 void updateFilter(QString filter);
160
161public slots:
162
163protected:
168 void contextMenuEvent(QContextMenuEvent *event);
169
173 void addFilterActions();
174
179
184 QString displayFilter();
185
190 void setDisplayFilter(const QString &filter);
191
196 void setHint(const QString &hint);
197
203 void setRetapOnShow(bool retap);
204
205protected slots:
210
213
216
221 void updateWidgets();
222
223private:
224 Ui::TapParameterDialog *ui;
225 QMenu ctx_menu_;
226 QList<QAction *> filter_actions_;
227 int help_topic_;
228 static const QString action_name_;
229 QTimer *show_timer_;
236 virtual const QString filterExpression() { return QString(); }
237
244 QString itemDataToPlain(QVariant var, int width = 0);
245
252 virtual QList<QVariant> treeItemData(QTreeWidgetItem *) const;
253
259 virtual QByteArray getTreeAsString(st_format_type format);
260
261private slots:
266 virtual void fillTree() = 0;
267
271 void on_applyFilterButton_clicked();
272
276 void on_actionCopyToClipboard_triggered();
277
281 void on_actionSaveAs_triggered();
282
286 void on_buttonBox_helpRequested();
287};
288
289#endif // TAP_PARAMETER_DIALOG_H
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
Action
Defines an action to be taken with a filter.
Definition filter_action.h:30
ActionType
Defines how the new filter should be combined with the existing one.
Definition filter_action.h:43
Base class for statistics dialogs driven by a tap and an optional display filter, presenting results ...
Definition tap_parameter_dialog.h:58
void updateWidgets()
Refreshes the enabled/disabled state of UI widgets based on current capture and filter state.
Definition tap_parameter_dialog.cpp:505
static const QString & actionName()
Returns the action name string used to identify this dialog type in menus.
Definition tap_parameter_dialog.h:79
void addFilterActions()
Populates the context menu with filter actions for the selected tree item.
Definition tap_parameter_dialog.cpp:445
void addTreeCollapseAllActions()
Adds "Collapse All" and "Expand All" actions to the context menu.
Definition tap_parameter_dialog.cpp:492
static void registerDialog(const QString title, const char *cfg_abbr, register_stat_group_t group, stat_tap_init_cb tap_init_cb, tpdCreator creator)
Registers a TapParameterDialog subclass so it can be opened via the statistics menu or the "-z" comma...
Definition tap_parameter_dialog.cpp:114
QHBoxLayout * filterLayout()
Returns the filter bar horizontal layout for use by subclasses.
Definition tap_parameter_dialog.cpp:164
void filterActionTriggered()
Applies the filter action associated with the triggered context menu action.
Definition tap_parameter_dialog.cpp:195
void collapseAllActionTriggered()
Collapses all items in the statistics tree.
Definition tap_parameter_dialog.cpp:207
void drawTreeItems()
Triggers a full redraw of all tree items, typically called after the tap has finished accumulating da...
Definition tap_parameter_dialog.cpp:415
QString displayFilter()
Returns the current display filter string from the filter line edit.
Definition tap_parameter_dialog.cpp:169
void contextMenuEvent(QContextMenuEvent *event)
Shows the context menu with filter and tree collapse/expand actions.
Definition tap_parameter_dialog.cpp:434
void setDisplayFilter(const QString &filter)
Sets the display filter line edit to the given expression.
Definition tap_parameter_dialog.cpp:176
QLineEdit * displayFilterLineEdit()
Returns the display filter line edit widget for use by subclasses.
Definition tap_parameter_dialog.cpp:149
void updateFilter(QString filter)
Emitted to push a new display filter to the main window filter bar.
void setHint(const QString &hint)
Sets the hint text shown below the tree widget.
Definition tap_parameter_dialog.cpp:181
void setRetapOnShow(bool retap)
Controls whether packets are retapped when the dialog is first shown. RPC statistics dialogs should d...
Definition tap_parameter_dialog.cpp:187
~TapParameterDialog()
Destroys the dialog, deregisters the tap, and releases UI resources.
Definition tap_parameter_dialog.cpp:107
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type)
Emitted when the user triggers a filter action from the context menu.
void expandAllActionTriggered()
Expands all items in the statistics tree.
Definition tap_parameter_dialog.cpp:210
QPushButton * applyFilterButton()
Returns the Apply Filter button for use by subclasses.
Definition tap_parameter_dialog.cpp:154
QVBoxLayout * verticalLayout()
Returns the main vertical layout for use by subclasses that need to insert additional widgets.
Definition tap_parameter_dialog.cpp:159
QTreeWidget * statsTreeWidget()
Returns the statistics results tree widget for use by subclasses.
Definition tap_parameter_dialog.cpp:144
static TapParameterDialog * showTapParameterStatistics(QWidget &parent, CaptureFile &cf, const QString cfg_str, const QString arg, void *)
Finds or creates and shows the tap statistics dialog matching cfg_str.
Definition tap_parameter_dialog.cpp:135
Base class for Wireshark specific dialogs that require interaction with a CaptureFile.
Definition wireshark_dialog.h:38
enum _st_format_type st_format_type
Output format used when saving statistics tree data via "Save As...".
enum register_stat_group_e register_stat_group_t
bool(* stat_tap_init_cb)(const char *opt_arg, void *userdata)
Callback invoked to initialize a tap statistic with its CLI argument string.
Definition stat_tap_ui.h:53
TapParameterDialog *(* tpdCreator)(QWidget &parent, const QString cfg_str, const QString arg, CaptureFile &cf)
Factory function signature for creating TapParameterDialog subclass instances.
Definition tap_parameter_dialog.h:48