Wireshark  4.3.0
The Wireshark network protocol analyzer
traffic_types_list.h
Go to the documentation of this file.
1 
10 #ifndef TRAFFIC_TYPES_LIST_H
11 #define TRAFFIC_TYPES_LIST_H
12 
13 #include "config.h"
14 
15 #include <glib.h>
16 
17 #include <QTreeView>
18 #include <QAbstractListModel>
19 #include <QMap>
20 #include <QList>
21 #include <QString>
22 #include <QSortFilterProxyModel>
23 
25 {
26 
27 public:
28  TrafficTypesRowData(int protocol, QString name);
29 
30  int protocol() const;
31  QString name() const;
32  bool checked() const;
33  void setChecked(bool checked);
34 
35 private:
36  int _protocol;
37  QString _name;
38  bool _checked;
39 };
40 
41 
42 class TrafficTypesModel : public QAbstractListModel
43 {
44  Q_OBJECT
45 public:
46 
47  enum {
48  TRAFFIC_PROTOCOL = Qt::UserRole,
49  TRAFFIC_IS_CHECKED,
50  } eTrafficUserData;
51 
52  enum {
53  COL_CHECKED,
54  COL_NAME,
55  COL_NUM,
56  COL_PROTOCOL,
57  } eTrafficColumnNames;
58 
59  TrafficTypesModel(GList ** recentList, QObject *parent = nullptr);
60 
61  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
62  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
63  virtual QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
64  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
65 
66  virtual bool setData(const QModelIndex &idx, const QVariant &value, int role) override;
67  virtual Qt::ItemFlags flags (const QModelIndex & idx) const override;
68 
69  QList<int> protocols() const;
70 
71 public slots:
72  void selectProtocols(QList<int> protocols);
73 
74 signals:
75  void protocolsChanged(QList<int> protocols);
76 
77 private:
78  QList<TrafficTypesRowData> _allTaps;
79  GList ** _recentList;
80 
81 };
82 
83 
84 class TrafficListSortModel : public QSortFilterProxyModel
85 {
86  Q_OBJECT
87 public:
88  TrafficListSortModel(QObject * parent = nullptr);
89 
90  void setFilter(QString filter = QString());
91 
92 protected:
93  virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
94  virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
95 
96 private:
97  QString _filter;
98 };
99 
100 
101 class TrafficTypesList : public QTreeView
102 {
103  Q_OBJECT
104 public:
105 
106  TrafficTypesList(QWidget *parent = nullptr);
107 
108  void setProtocolInfo(QString name, GList ** recentList);
109  QList<int> protocols(bool onlySelected = false) const;
110 
111 public slots:
112  void selectProtocols(QList<int> protocols);
113  void filterList(QString);
114 
115 signals:
116  void protocolsChanged(QList<int> protocols);
117  void clearFilterList();
118 
119 private:
120  QString _name;
121  TrafficTypesModel * _model;
122  TrafficListSortModel * _sortModel;
123 };
124 
125 #endif // TRAFFIC_TYPES_LIST_H
Definition: traffic_types_list.h:85
Definition: traffic_types_list.h:102
Definition: traffic_types_list.h:43
Definition: traffic_types_list.h:25
Definition: proto.c:361