Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
supported_protocols_model.h
Go to the documentation of this file.
1
9
10#ifndef SUPPORTED_PROTOCOLS_MODEL_H
11#define SUPPORTED_PROTOCOLS_MODEL_H
12
13#include <config.h>
14
16
17#include <epan/proto.h>
18
19#include <QSortFilterProxyModel>
20
26class SupportedProtocolsItem : public ModelHelperTreeItem<SupportedProtocolsItem>
27{
28public:
38 SupportedProtocolsItem(protocol_t *proto, const char *name, const char *filter,
39 ftenum_t ftype, const char *descr,
41
46
51 protocol_t *protocol() const { return proto_; }
52
57 QString name() const { return name_; }
58
63 ftenum_t type() const { return ftype_; }
64
69 QString filter() const { return filter_; }
70
75 QString description() const { return descr_; }
76
77private:
78 protocol_t *proto_;
79 QString name_;
80 QString filter_;
81 ftenum_t ftype_;
82 QString descr_;
83};
84
85
91class SupportedProtocolsModel : public QAbstractItemModel
92{
93 Q_OBJECT
94
95public:
100 explicit SupportedProtocolsModel(QObject *parent = Q_NULLPTR);
101
105 virtual ~SupportedProtocolsModel();
106
117
122 int fieldCount() { return field_count_; }
123
131 QModelIndex index(int row, int column,
132 const QModelIndex &parent = QModelIndex()) const override;
133
139 QModelIndex parent(const QModelIndex &index) const override;
140
147 QVariant data(const QModelIndex &index, int role) const override;
148
156 QVariant headerData(int section, Qt::Orientation orientation,
157 int role = Qt::DisplayRole) const override;
158
164 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
165
171 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
172
177 void populate();
178
179private:
181 int field_count_;
182};
183
184
190class SupportedProtocolsProxyModel : public QSortFilterProxyModel
191{
192public:
197 explicit SupportedProtocolsProxyModel(QObject *parent = Q_NULLPTR);
198
205 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
206
212 void setFilter(const QString &filter);
213
214protected:
221 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
222
229
230private:
231 QString filter_;
232};
233
234#endif // SUPPORTED_PROTOCOLS_MODEL_H
ModelHelperTreeItem(SupportedProtocolsItem *parent)
Definition tree_model_helpers.h:31
Tree item representing a single protocol or protocol field in the Supported Protocols tree,...
Definition supported_protocols_model.h:27
SupportedProtocolsItem(protocol_t *proto, const char *name, const char *filter, ftenum_t ftype, const char *descr, SupportedProtocolsItem *parent)
Constructs a supported-protocols tree item.
Definition supported_protocols_model.cpp:19
protocol_t * protocol() const
Returns the protocol descriptor associated with this item.
Definition supported_protocols_model.h:51
QString description() const
Returns the human-readable description of this protocol or field.
Definition supported_protocols_model.h:75
virtual ~SupportedProtocolsItem()
Destroys the item and all of its child items.
Definition supported_protocols_model.cpp:29
QString name() const
Returns the display name of the protocol or field.
Definition supported_protocols_model.h:57
ftenum_t type() const
Returns the field type of this item.
Definition supported_protocols_model.h:63
QString filter() const
Returns the filter expression string for this protocol or field.
Definition supported_protocols_model.h:69
SupportedProtocolsColumn
Column indices for the supported-protocols tree view.
Definition supported_protocols_model.h:110
@ colType
Definition supported_protocols_model.h:113
@ colDescription
Definition supported_protocols_model.h:114
@ colFilter
Definition supported_protocols_model.h:112
@ colLast
Definition supported_protocols_model.h:115
@ colName
Definition supported_protocols_model.h:111
int fieldCount()
Returns the total number of protocol fields loaded by populate().
Definition supported_protocols_model.h:122
QVariant data(const QModelIndex &index, int role) const override
Returns data for the given model index and role.
Definition supported_protocols_model.cpp:129
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns column header labels for the supported-protocols table.
Definition supported_protocols_model.cpp:68
QModelIndex parent(const QModelIndex &index) const override
Returns the parent index of the item at index.
Definition supported_protocols_model.cpp:88
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent.
Definition supported_protocols_model.cpp:46
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns in the model.
Definition supported_protocols_model.cpp:63
void populate()
Populates the model by iterating all registered protocols and their fields; must be called before the...
Definition supported_protocols_model.cpp:157
SupportedProtocolsModel(QObject *parent=Q_NULLPTR)
Constructs an empty model; call populate() to load protocol data.
Definition supported_protocols_model.cpp:34
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the item at row and column under parent.
Definition supported_protocols_model.cpp:107
virtual ~SupportedProtocolsModel()
Destroys the model and all tree items.
Definition supported_protocols_model.cpp:41
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Determines whether the source row should be visible given the current filter.
Definition supported_protocols_model.cpp:230
void setFilter(const QString &filter)
Sets the text filter used to match protocols and fields. An empty string shows all items.
Definition supported_protocols_model.cpp:258
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Compares two source rows for sorting using the active sort column.
Definition supported_protocols_model.cpp:197
SupportedProtocolsProxyModel(QObject *parent=Q_NULLPTR)
Constructs the proxy model.
Definition supported_protocols_model.cpp:191
bool filterAcceptItem(SupportedProtocolsItem &item) const
Tests whether a single SupportedProtocolsItem matches the current filter.
Definition supported_protocols_model.cpp:212
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
struct _protocol protocol_t
Definition proto.h:100