Wireshark  4.3.0
The Wireshark network protocol analyzer
traffic_tab.h
Go to the documentation of this file.
1 
10 #ifndef TRAFFIC_TAB_H
11 #define TRAFFIC_TAB_H
12 
13 #include "config.h"
14 
16 #include <ui/qt/filter_action.h>
18 #include <ui/qt/widgets/detachable_tabwidget.h>
20 
21 #include <QTabWidget>
22 #include <QTreeView>
23 #include <QFile>
24 #include <QUrl>
25 #include <QAbstractItemDelegate>
26 #include <QSortFilterProxyModel>
27 
36 typedef ATapDataModel * (*ATapModelCallback)(int protoId, QString filter);
37 
45 typedef QAbstractItemDelegate * (*ATapCreateDelegate)(QWidget * parent);
46 
47 class TabData
48 {
49 public:
50  TabData();
51  TabData(const TabData &) = default;
52  TabData &operator=(const TabData &) = default;
53 
54  TabData(QString name, int proto);
55 
56  QString name() const;
57  int protoId() const;
58 
59 private:
60  QString _name;
61  int _protoId;
62 };
63 
64 Q_DECLARE_METATYPE(TabData)
65 
66 
75 {
76  Q_OBJECT
77 
78 public:
79  TrafficTab(QWidget *parent = nullptr);
80  virtual ~TrafficTab();
81 
96  void setProtocolInfo(QString tableName, TrafficTypesList * trafficList, GList ** recentColumnList, ATapModelCallback createModel);
97 
106  void setDelegate(ATapCreateDelegate createDelegate);
107 
120  void setFilter(QString filter = QString());
121 
127  void setNameResolution(bool checked);
128 
136  void disableTap();
137 
147  QMenu * createCopyMenu(QWidget * parent = nullptr);
148 
156  bool hasNameResolution(int tabIdx = -1);
157 
158 #ifdef HAVE_MAXMINDDB
166  bool hasGeoIPData(int tabIdx = -1);
167 
175  QUrl createGeoIPMap(bool onlyJSON, int tabIdx = -1);
176 #endif
177 
185  QVariant currentItemData(int role = Qt::DisplayRole);
186 
192  void useNanosecondTimestamps(bool useNSTime);
193 
194 public slots:
195 
201  void useAbsoluteTime(bool absolute);
202 
203  void setOpenTabs(QList<int> protocols);
204 
205 signals:
206  void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
207  void tabDataChanged(int idx);
208  void retapRequired();
209  void disablingTaps();
210  void tabsChanged(QList<int> protocols);
211  void columnsHaveChanged(QList<int> columns);
212 
213 protected slots:
214 
215  virtual void detachTab(int idx, QPoint pos) override;
216  virtual void attachTab(QWidget * content, QString name) override;
217 
218 private:
219  QList<int> _allProtocols;
220  QMap<int, int> _tabs;
221  ATapModelCallback _createModel;
222  ATapCreateDelegate _createDelegate;
223  GList ** _recentColumnList;
224 
225  bool _disableTaps;
226  bool _nameResolution;
227 
228  QTreeView * createTree(int protoId);
229  TrafficDataFilterProxy * modelForTabIndex(int tabIdx = -1);
230  TrafficDataFilterProxy * modelForWidget(QWidget * widget);
231  ATapDataModel * dataModelForTabIndex(int tabIdx = -1);
232  ATapDataModel * dataModelForWidget(QWidget * widget);
233 
234  void insertProtoTab(int protoId, bool emitSignals = true);
235  void removeProtoTab(int protoId, bool emitSignals = true);
236 
237 #ifdef HAVE_MAXMINDDB
238  bool writeGeoIPMapFile(QFile * fp, bool json_only, TrafficDataFilterProxy * model);
239 #endif
240 
241 private slots:
242  void modelReset();
243 
244  void doCurrentIndexChange(const QModelIndex & cur, const QModelIndex & prev);
245 };
246 
247 #endif // TRAFFIC_TAB_H
DataModel for tap user data.
Definition: atap_data_model.h:33
Definition: detachable_tabwidget.h:24
Definition: traffic_tab.h:48
Definition: traffic_tree.h:76
A QTabWidget class, providing tap information.
Definition: traffic_tab.h:75
Definition: traffic_types_list.h:100
QAbstractItemDelegate *(* ATapCreateDelegate)(QWidget *parent)
Callback for creating an item delegate.
Definition: traffic_tab.h:45
ATapDataModel *(* ATapModelCallback)(int protoId, QString filter)
Callback for creating an ATapDataModel.
Definition: traffic_tab.h:36