Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tap_parameter_dialog.h
Go to the documentation of this file.
1
9
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 {
36class TapParameterDialog;
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) override;
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
209 Ui::TapParameterDialog * getUI(void)
210 {
211 return (ui);
212 }
213
214protected slots:
219
222
225
230 void updateWidgets() override;
231
232private:
233 Ui::TapParameterDialog *ui;
234 QMenu ctx_menu_;
235 QList<QAction *> filter_actions_;
236 int help_topic_;
237 static const QString action_name_;
238 QTimer *show_timer_;
239
245 virtual const QString filterExpression() { return QString(); }
246
253 QString itemDataToPlain(QVariant var, int width = 0);
254
261 virtual QList<QVariant> treeItemData(QTreeWidgetItem *) const;
262
268 virtual QByteArray getTreeAsString(st_format_type format);
269
270private slots:
275 virtual void fillTree() = 0;
276
280 void on_applyFilterButton_clicked();
281
285 void on_actionCopyToClipboard_triggered();
286
290 void on_actionSaveAs_triggered();
291
295 void on_buttonBox_helpRequested();
296};
297
298#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
static const QString & actionName()
Returns the action name string used to identify this dialog type in menus.
Definition tap_parameter_dialog.h:79
void contextMenuEvent(QContextMenuEvent *event) override
Shows the context menu with filter and tree collapse/expand actions.
Definition tap_parameter_dialog.cpp:434
void addFilterActions()
Populates the context menu with filter actions for the selected tree item.
Definition tap_parameter_dialog.cpp:445
Ui::TapParameterDialog * getUI(void)
Retrieves the UI object.
Definition tap_parameter_dialog.h:209
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 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 updateWidgets() override
Refreshes the enabled/disabled state of UI widgets based on current capture and filter state.
Definition tap_parameter_dialog.cpp:505
void setHint(const QString &hint)
Sets the hint text shown below the tree widget.
Definition tap_parameter_dialog.cpp:181
TapParameterDialog(QWidget &parent, CaptureFile &cf, int help_topic=0)
Constructs the tap parameter dialog and registers it for retapping.
Definition tap_parameter_dialog.cpp:69
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
WiresharkDialog(QWidget &parent, CaptureFile &capture_file)
Constructs a new WiresharkDialog object.
Definition wireshark_dialog.cpp:30
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