Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
supported_protocols_model.h
Go to the documentation of this file.
1
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;
133
139 QModelIndex parent(const QModelIndex &index) const;
140
147 QVariant data(const QModelIndex &index, int role) const;
148
156 QVariant headerData(int section, Qt::Orientation orientation,
157 int role = Qt::DisplayRole) const;
158
164 int rowCount(const QModelIndex &parent = QModelIndex()) const;
165
171 int columnCount(const QModelIndex &parent = QModelIndex()) const;
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;
206
212 void setFilter(const QString &filter);
213
214protected:
221 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
222
229
230private:
231 QString filter_;
232};
233
234#endif // SUPPORTED_PROTOCOLS_MODEL_H
Base class to inherit basic tree item from.
Definition tree_model_helpers.h:25
Tree item representing a single protocol or protocol field in the Supported Protocols tree,...
Definition supported_protocols_model.h:27
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
Tree model that exposes all registered Wireshark protocols and their fields, organised as a parent–ch...
Definition supported_protocols_model.h:92
QModelIndex parent(const QModelIndex &index) const
Returns the parent index of the item at index.
Definition supported_protocols_model.cpp:88
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
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns column header labels for the supported-protocols table.
Definition supported_protocols_model.cpp:68
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the model.
Definition supported_protocols_model.cpp:63
int fieldCount()
Returns the total number of protocol fields loaded by populate().
Definition supported_protocols_model.h:122
void populate()
Populates the model by iterating all registered protocols and their fields; must be called before the...
Definition supported_protocols_model.cpp:157
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the model index for the item at row and column under parent.
Definition supported_protocols_model.cpp:107
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of child rows under parent.
Definition supported_protocols_model.cpp:46
virtual ~SupportedProtocolsModel()
Destroys the model and all tree items.
Definition supported_protocols_model.cpp:41
Sort/filter proxy model for SupportedProtocolsModel that performs case-insensitive substring filterin...
Definition supported_protocols_model.h:191
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
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 filterAcceptItem(SupportedProtocolsItem &item) const
Tests whether a single SupportedProtocolsItem matches the current filter.
Definition supported_protocols_model.cpp:212
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
Compares two source rows for sorting using the active sort column.
Definition supported_protocols_model.cpp:197
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
Definition proto.c:385