Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
traffic_tree.h
Go to the documentation of this file.
1
9
10#ifndef TRAFFIC_TREE_H
11#define TRAFFIC_TREE_H
12
13#include "config.h"
14
15#include <ui/recent.h>
16
18#include <ui/qt/filter_action.h>
20
21#include <QTreeView>
22#include <QMenu>
23#include <QHeaderView>
24#include <QSortFilterProxyModel>
25
26#include <QWidgetAction>
27#include <QLineEdit>
28#include <QActionGroup>
29
33class MenuEditAction : public QWidgetAction
34{
35 Q_OBJECT
36public:
43 MenuEditAction(QString text, QString hintText, QObject * parent = nullptr);
44
49 QString text() const;
50
51protected:
57 virtual QWidget * createWidget(QWidget *parent) override;
58
59private:
61 QString _hintText;
62
64 QString _text;
65
67 QLineEdit * _lineEdit;
68
69private slots:
73 void triggerEntry();
74};
75
76
81{
82 Q_OBJECT
83public:
89 TrafficTreeHeaderView(GList ** recentColumnList, QWidget * parent = nullptr);
90
95
99 void applyRecent();
100
101signals:
106 void columnsHaveChanged(QList<int> visible);
107
114 void filterOnColumn(int column, int filterOn, QString filterText);
115
116private:
118 GList ** _recentColumnList;
119
121 QActionGroup * _actions;
122
124 QString _filterText;
125
126private slots:
131 void headerContextMenu(const QPoint &pos);
132
137 void columnTriggered(bool checked = false);
138
143 void menuActionTriggered(QAction * act);
144
149 void filterColumn(bool checked = false);
150};
151
152
156class TrafficDataFilterProxy : public QSortFilterProxyModel
157{
158 Q_OBJECT
159public:
160
162 enum {
169 };
170
175 TrafficDataFilterProxy(QObject *parent = nullptr);
176
182 void setColumnVisibility(int column, bool visible);
183
189 bool columnVisible(int column) const;
190
191public slots:
198 void filterForColumn(int column, int filterOn, QString filterText);
199
200protected:
207 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
208
215 virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override;
216
223 virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
224
225private:
227 QList<int> hideColumns_;
228
230 int _filterColumn;
231
233 int _filterOn;
234
236 QString _filterText;
237
243 int mapToSourceColumn(int proxyColumn) const;
244};
245
246
250class TrafficTree : public QTreeView
251{
252 Q_OBJECT
253
254public:
267
274 TrafficTree(QString baseName, GList ** recentColumnList, QWidget *parent = nullptr);
275
285 QMenu * createCopyMenu(QWidget * parent = nullptr);
286
290 void applyRecentColumns();
291
302 void widenColumnToContents(int column);
303
308 virtual void setModel(QAbstractItemModel *model) override;
309
310signals:
318
323 void columnsHaveChanged(QList<int> columns);
324
325public slots:
330 void tapListenerEnabled(bool enable);
331
335 void disableTap();
336
341 void columnsChanged(QList<int> columns);
342
343private:
345 bool _tapEnabled;
346
348 int _exportRole;
349
351 bool _saveRaw;
352
354 QString _baseName;
355
357 TrafficTreeHeaderView * _header;
358
363 ATapDataModel * dataModel();
364
372 QMenu * createActionSubMenu(FilterAction::Action cur_action, QModelIndex idx, bool isConversation);
373
378 void copyToClipboard(eTrafficTreeClipboard type);
379
382
383private slots:
388 void customContextMenu(const QPoint &pos);
389
393 void useFilterAction();
394
398 void clipboardAction();
399
403 void resizeAction();
404
408 void toggleSaveRawAction();
409
415 void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int>);
416
420 void handleLayoutChanged(const QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint);
421};
422
423#endif // TRAFFIC_TREE_H
DataModel for tap user data.
Definition atap_data_model.h:33
AdaptiveHeaderView(Qt::Orientation orientation, QWidget *parent=nullptr)
Constructs an AdaptiveHeaderView.
Definition adaptive_header_view.cpp:19
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
MenuEditAction(QString text, QString hintText, QObject *parent=nullptr)
Constructs a new MenuEditAction.
Definition traffic_tree.cpp:50
QString text() const
Retrieves the current text in the line edit.
Definition traffic_tree.cpp:73
virtual QWidget * createWidget(QWidget *parent) override
Creates the custom widget for this action.
Definition traffic_tree.cpp:57
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Determines if a row from the source model should be included.
Definition traffic_tree.cpp:323
void filterForColumn(int column, int filterOn, QString filterText)
Applies filtering criteria for a specific column.
Definition traffic_tree.cpp:274
@ TRAFFIC_DATA_GREATER
Filter for values strictly greater than the target.
Definition traffic_tree.h:166
@ TRAFFIC_DATA_EQUAL
Filter for values equal to the target.
Definition traffic_tree.h:168
@ TRAFFIC_DATA_LESS
Filter for values strictly less than the target.
Definition traffic_tree.h:164
TrafficDataFilterProxy(QObject *parent=nullptr)
Constructs a new TrafficDataFilterProxy.
Definition traffic_tree.cpp:264
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Compares two items for sorting.
Definition traffic_tree.cpp:379
bool columnVisible(int column) const
Checks if a column is currently visible.
Definition traffic_tree.cpp:541
virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override
Determines if a column from the source model should be included.
Definition traffic_tree.cpp:494
void setColumnVisibility(int column, bool visible)
Sets the visibility for a specific column.
Definition traffic_tree.cpp:526
void columnsHaveChanged(QList< int > visible)
Signal emitted when the visible columns have changed.
TrafficTreeHeaderView(GList **recentColumnList, QWidget *parent=nullptr)
Constructs a new TrafficTreeHeaderView.
Definition traffic_tree.cpp:78
~TrafficTreeHeaderView()
Destroys the TrafficTreeHeaderView.
Definition traffic_tree.cpp:101
void filterOnColumn(int column, int filterOn, QString filterText)
Signal emitted to filter data based on a column's criteria.
void applyRecent()
Applies the recently used column settings.
Definition traffic_tree.cpp:162
virtual void setModel(QAbstractItemModel *model) override
Sets the data model for the tree view.
Definition traffic_tree.cpp:568
void applyRecentColumns()
Applies the recently visible columns configuration.
Definition traffic_tree.cpp:893
void columnsChanged(QList< int > columns)
Slot triggered when columns are changed.
Definition traffic_tree.cpp:899
void widenColumnToContents(int column)
Increase column width if necessary to fit contents, but don't narrow it.
Definition traffic_tree.cpp:774
QMenu * createCopyMenu(QWidget *parent=nullptr)
Create a menu containing clipboard copy entries for this tab.
Definition traffic_tree.cpp:718
void tapListenerEnabled(bool enable)
Enables or disables the tap listener.
Definition traffic_tree.cpp:590
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type)
Signal emitted to perform a display filter action.
eTrafficTreeClipboard
Type for the selection of export.
Definition traffic_tree.h:259
@ CLIPBOARD_CSV
export as CSV
Definition traffic_tree.h:261
@ CLIPBOARD_YAML
export as YAML
Definition traffic_tree.h:263
@ CLIPBOARD_JSON
export as JSON
Definition traffic_tree.h:265
TrafficTree(QString baseName, GList **recentColumnList, QWidget *parent=nullptr)
Constructs a new TrafficTree.
Definition traffic_tree.cpp:547
friend class TrafficTreeHeaderView
Definition traffic_tree.h:381
void columnsHaveChanged(QList< int > columns)
Signal emitted when the visible columns have changed.
void disableTap()
Disables the tap completely.
Definition traffic_tree.cpp:885