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 
15 #include <glib.h>
16 
18 #include <ui/qt/filter_action.h>
19 #include <ui/qt/widgets/detachable_tabwidget.h>
21 
22 #include <QTabWidget>
23 #include <QTreeView>
24 #include <QFile>
25 #include <QUrl>
26 #include <QAbstractItemDelegate>
27 #include <QSortFilterProxyModel>
28 
37 typedef ATapDataModel * (*ATapModelCallback)(int protoId, QString filter);
38 
46 typedef QAbstractItemDelegate * (*ATapCreateDelegate)(QWidget * parent);
47 
48 class TabData
49 {
50 public:
51  TabData();
52  TabData(const TabData &) = default;
53  TabData &operator=(const TabData &) = default;
54 
55  TabData(QString name, int proto);
56 
57  QString name() const;
58  int protoId() const;
59 
60 private:
61  QString _name;
62  int _protoId;
63 };
64 
65 Q_DECLARE_METATYPE(TabData)
66 
67 
76 {
77  Q_OBJECT
78 
79 public:
80  TrafficTab(QWidget *parent = nullptr);
81  virtual ~TrafficTab();
82 
97  void setProtocolInfo(QString tableName, TrafficTypesList * trafficList, GList ** recentColumnList, ATapModelCallback createModel);
98 
107  void setDelegate(ATapCreateDelegate createDelegate);
108 
121  void setFilter(QString filter = QString());
122 
128  void setNameResolution(bool checked);
129 
137  void disableTap();
138 
148  QMenu * createCopyMenu(QWidget * parent = nullptr);
149 
157  bool hasNameResolution(int tabIdx = -1);
158 
159 #ifdef HAVE_MAXMINDDB
167  bool hasGeoIPData(int tabIdx = -1);
168 
176  QUrl createGeoIPMap(bool onlyJSON, int tabIdx = -1);
177 #endif
178 
186  QVariant currentItemData(int role = Qt::DisplayRole);
187 
193  void useNanosecondTimestamps(bool useNSTime);
194 
195 public slots:
196 
202  void useAbsoluteTime(bool absolute);
203 
204  void setOpenTabs(QList<int> protocols);
205 
206 signals:
207  void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
208  void tabDataChanged(int idx);
209  void retapRequired();
210  void disablingTaps();
211  void tabsChanged(QList<int> protocols);
212  void columnsHaveChanged(QList<int> columns);
213 
214 protected slots:
215 
216  virtual void detachTab(int idx, QPoint pos) override;
217  virtual void attachTab(QWidget * content, QString name) override;
218 
219 private:
220  QList<int> _allProtocols;
221  QMap<int, int> _tabs;
222  ATapModelCallback _createModel;
223  ATapCreateDelegate _createDelegate;
224  GList ** _recentColumnList;
225 
226  bool _disableTaps;
227  bool _nameResolution;
228 
229  QTreeView * createTree(int protoId);
230  ATapDataModel * modelForTabIndex(int tabIdx = -1);
231  ATapDataModel * modelForWidget(QWidget * widget);
232 
233  void insertProtoTab(int protoId, bool emitSignals = true);
234  void removeProtoTab(int protoId, bool emitSignals = true);
235 
236 #ifdef HAVE_MAXMINDDB
237  bool writeGeoIPMapFile(QFile * fp, bool json_only, ATapDataModel * dataModel);
238 #endif
239 
240 private slots:
241  void modelReset();
242 
243  void doCurrentIndexChange(const QModelIndex & cur, const QModelIndex & prev);
244 };
245 
246 #endif // TRAFFIC_TAB_H
DataModel for tap user data.
Definition: atap_data_model.h:35
Definition: detachable_tabwidget.h:24
Definition: traffic_tab.h:49
A QTabWidget class, providing tap information.
Definition: traffic_tab.h:76
Definition: traffic_types_list.h:102
QAbstractItemDelegate *(* ATapCreateDelegate)(QWidget *parent)
Callback for creating an item delegate.
Definition: traffic_tab.h:46
ATapDataModel *(* ATapModelCallback)(int protoId, QString filter)
Callback for creating an ATapDataModel.
Definition: traffic_tab.h:37