| 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
15#include <ui/qt/models/tree_model_helpers.h>
16
17#include <epan/proto.h>
18
19#include <QSortFilterProxyModel>
20
26 class SupportedProtocolsItem : public ModelHelperTreeItem<SupportedProtocolsItem>
27{
28 public:
38 SupportedProtocolsItem(protocol_t *proto, const char *name, const char *filter,
39 ftenum_t ftype, const char *descr,
40 SupportedProtocolsItem *parent);
41
45 virtual ~SupportedProtocolsItem();
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
77 private:
78 protocol_t *proto_;
79 QString name_;
80 QString filter_;
81 ftenum_t ftype_;
82 QString descr_;
83};
84
85
91 class SupportedProtocolsModel : public QAbstractItemModel
92{
93 Q_OBJECT
94
95 public:
100 explicit SupportedProtocolsModel(QObject *parent = Q_NULLPTR);
101
105 virtual ~SupportedProtocolsModel();
106
110 enum SupportedProtocolsColumn {
111 colName = 0,
112 colFilter,
113 colType,
114 colDescription,
115 colLast
116 };
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
179 private:
180 SupportedProtocolsItem *root_;
181 int field_count_;
182};
183
184
190 class SupportedProtocolsProxyModel : public QSortFilterProxyModel
191{
192 public:
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
214 protected:
221 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
222
228 bool filterAcceptItem(SupportedProtocolsItem &item) const;
229
230 private:
231 QString filter_;
232};
233
234#endif // SUPPORTED_PROTOCOLS_MODEL_H
ModelHelperTreeItem< SupportedProtocolsItem >::ModelHelperTreeItem
ModelHelperTreeItem(SupportedProtocolsItem *parent)
Definition tree_model_helpers.h:31
SupportedProtocolsItem
Tree item representing a single protocol or protocol field in the Supported Protocols tree,...
Definition supported_protocols_model.h:27
SupportedProtocolsItem::SupportedProtocolsItem
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
SupportedProtocolsItem::protocol
protocol_t * protocol() const
Returns the protocol descriptor associated with this item.
Definition supported_protocols_model.h:51
SupportedProtocolsItem::description
QString description() const
Returns the human-readable description of this protocol or field.
Definition supported_protocols_model.h:75
SupportedProtocolsItem::~SupportedProtocolsItem
virtual ~SupportedProtocolsItem()
Destroys the item and all of its child items.
Definition supported_protocols_model.cpp:29
SupportedProtocolsItem::name
QString name() const
Returns the display name of the protocol or field.
Definition supported_protocols_model.h:57
SupportedProtocolsItem::type
ftenum_t type() const
Returns the field type of this item.
Definition supported_protocols_model.h:63
SupportedProtocolsItem::filter
QString filter() const
Returns the filter expression string for this protocol or field.
Definition supported_protocols_model.h:69
SupportedProtocolsModel::SupportedProtocolsColumn
SupportedProtocolsColumn
Column indices for the supported-protocols tree view.
Definition supported_protocols_model.h:110
SupportedProtocolsModel::colType
@ colType
Definition supported_protocols_model.h:113
SupportedProtocolsModel::colDescription
@ colDescription
Definition supported_protocols_model.h:114
SupportedProtocolsModel::colFilter
@ colFilter
Definition supported_protocols_model.h:112
SupportedProtocolsModel::colLast
@ colLast
Definition supported_protocols_model.h:115
SupportedProtocolsModel::colName
@ colName
Definition supported_protocols_model.h:111
SupportedProtocolsModel::fieldCount
int fieldCount()
Returns the total number of protocol fields loaded by populate().
Definition supported_protocols_model.h:122
SupportedProtocolsModel::data
QVariant data(const QModelIndex &index, int role) const override
Returns data for the given model index and role.
Definition supported_protocols_model.cpp:129
SupportedProtocolsModel::headerData
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
SupportedProtocolsModel::parent
QModelIndex parent(const QModelIndex &index) const override
Returns the parent index of the item at index.
Definition supported_protocols_model.cpp:88
SupportedProtocolsModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent.
Definition supported_protocols_model.cpp:46
SupportedProtocolsModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns in the model.
Definition supported_protocols_model.cpp:63
SupportedProtocolsModel::populate
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::SupportedProtocolsModel
SupportedProtocolsModel(QObject *parent=Q_NULLPTR)
Constructs an empty model; call populate() to load protocol data.
Definition supported_protocols_model.cpp:34
SupportedProtocolsModel::index
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
SupportedProtocolsModel::~SupportedProtocolsModel
virtual ~SupportedProtocolsModel()
Destroys the model and all tree items.
Definition supported_protocols_model.cpp:41
SupportedProtocolsProxyModel::filterAcceptsRow
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
SupportedProtocolsProxyModel::setFilter
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
SupportedProtocolsProxyModel::lessThan
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::SupportedProtocolsProxyModel
SupportedProtocolsProxyModel(QObject *parent=Q_NULLPTR)
Constructs the proxy model.
Definition supported_protocols_model.cpp:191
SupportedProtocolsProxyModel::filterAcceptItem
bool filterAcceptItem(SupportedProtocolsItem &item) const
Tests whether a single SupportedProtocolsItem matches the current filter.
Definition supported_protocols_model.cpp:212
ftenum_t
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
protocol_t
struct _protocol protocol_t
Definition proto.h:100
proto.h
tree_model_helpers.h