Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
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
27{
28public:
34 TrafficTypesRowData(int protocol, QString name);
35
40 int protocol() const;
41
46 QString name() const;
47
52 bool checked() const;
53
58 void setChecked(bool checked);
59
60private:
61 int _protocol;
62 QString _name;
63 bool _checked;
64};
65
66
71class TrafficTypesModel : public QAbstractListModel
72{
73 Q_OBJECT
74
75public:
79 enum {
80 TRAFFIC_PROTOCOL = Qt::UserRole,
83
87 enum {
93
100 TrafficTypesModel(GList **recentList, QObject *parent = nullptr);
101
107 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
108
114 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
115
122 virtual QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
123
131 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
132
141 virtual bool setData(const QModelIndex &idx, const QVariant &value, int role) override;
142
148 virtual Qt::ItemFlags flags(const QModelIndex &idx) const override;
149
154 QList<int> protocols() const;
155
156public slots:
162 void selectProtocols(QList<int> protocols);
163
164signals:
169 void protocolsChanged(QList<int> protocols);
170
171private:
172 QList<TrafficTypesRowData> _allTaps;
173 GList **_recentList;
174};
175
176
181class TrafficListSortModel : public QSortFilterProxyModel
182{
183 Q_OBJECT
184
185public:
190 TrafficListSortModel(QObject *parent = nullptr);
191
197 void setFilter(QString filter = QString());
198
199protected:
207 virtual bool lessThan(const QModelIndex &source_left,
208 const QModelIndex &source_right) const override;
209
216 virtual bool filterAcceptsRow(int source_row,
217 const QModelIndex &source_parent) const override;
218
219private:
220 QString _filter;
221};
222
223
228class TrafficTypesList : public QTreeView
229{
230 Q_OBJECT
231
232public:
237 TrafficTypesList(QWidget *parent = nullptr);
238
245 void setProtocolInfo(QString name, GList **recentList);
246
253 QList<int> protocols(bool onlySelected = false) const;
254
255public slots:
260 void selectProtocols(QList<int> protocols);
261
266 void filterList(QString filter);
267
268signals:
273 void protocolsChanged(QList<int> protocols);
274
277
278private:
279 QString _name;
280 TrafficTypesModel *_model;
281 TrafficListSortModel *_sortModel;
282};
283
284#endif // TRAFFIC_TYPES_LIST_H
Sort/filter proxy model for TrafficTypesModel that supports case-insensitive name filtering and proto...
Definition traffic_types_list.h:182
void setFilter(QString filter=QString())
Sets the text filter used to show only protocols whose name contains the given string (case-insensiti...
Definition traffic_types_list.cpp:238
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Determines whether a source row should be visible given the current filter.
Definition traffic_types_list.cpp:253
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Compares two rows for sorting, using protocol name for the name column and numeric ordering for the p...
Definition traffic_types_list.cpp:228
Tree view widget that presents a filterable, sortable, checkable list of traffic-tap protocols and fo...
Definition traffic_types_list.h:229
void selectProtocols(QList< int > protocols)
Checks the given protocol IDs and unchecks all others.
Definition traffic_types_list.cpp:300
void clearFilterList()
Emitted to request that any external filter input be cleared.
void protocolsChanged(QList< int > protocols)
Emitted when the set of checked protocols changes.
void setProtocolInfo(QString name, GList **recentList)
Initialises the underlying model with the given protocol group name and recent-list pointer,...
Definition traffic_types_list.cpp:281
QList< int > protocols(bool onlySelected=false) const
Returns the list of protocol IDs tracked by this view.
Definition traffic_types_list.cpp:308
void filterList(QString filter)
Applies a name filter to the visible protocol list.
Definition traffic_types_list.cpp:323
List model that exposes all registered traffic-tap protocols with checkable rows, backed by a recent-...
Definition traffic_types_list.h:72
virtual bool setData(const QModelIndex &idx, const QVariant &value, int role) override
Sets data for the given index and role, updating the checked state and emitting protocolsChanged() wh...
Definition traffic_types_list.cpp:154
void selectProtocols(QList< int > protocols)
Replaces the current selection with the given protocol IDs and emits protocolsChanged().
Definition traffic_types_list.cpp:212
enum TrafficTypesModel::@618 eTrafficUserData
Custom Qt::UserRole values for retrieving protocol data from the model.
@ TRAFFIC_IS_CHECKED
Definition traffic_types_list.h:81
@ TRAFFIC_PROTOCOL
Definition traffic_types_list.h:80
@ COL_PROTOCOL
Definition traffic_types_list.h:91
@ COL_NAME
Definition traffic_types_list.h:89
@ COL_NUM
Definition traffic_types_list.h:90
@ COL_CHECKED
Definition traffic_types_list.h:88
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of protocol rows in the model.
Definition traffic_types_list.cpp:99
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns header labels for the traffic-types columns.
Definition traffic_types_list.cpp:135
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns in the model.
Definition traffic_types_list.cpp:104
void protocolsChanged(QList< int > protocols)
Emitted whenever the set of checked protocols changes.
QList< int > protocols() const
Returns the list of currently checked (selected) protocol IDs.
enum TrafficTypesModel::@619 eTrafficColumnNames
Column indices for the traffic-types table view.
Data record for a single row in the traffic-types protocol list, storing a protocol's numeric ID,...
Definition traffic_types_list.h:27
QString name() const
Returns the human-readable protocol name.
Definition traffic_types_list.cpp:30
void setChecked(bool checked)
Sets the checked (selected) state of this protocol.
Definition traffic_types_list.cpp:40
int protocol() const
Returns the numeric protocol ID.
Definition traffic_types_list.cpp:25
bool checked() const
Returns whether this protocol is currently checked (selected).
Definition traffic_types_list.cpp:35
Definition proto.c:385