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