Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
dissector_tables_model.h
Go to the documentation of this file.
1
9
10#ifndef DISSECTOR_TABLES_MODEL_H
11#define DISSECTOR_TABLES_MODEL_H
12
13#include <config.h>
14
16
17#include <QSortFilterProxyModel>
18
22class DissectorTablesItem : public ModelHelperTreeItem<DissectorTablesItem>
23{
24public:
32
36 virtual ~DissectorTablesItem();
37
42 QString tableName() const {return tableName_;}
43
49
55 virtual bool lessThan(DissectorTablesItem &right) const;
56
57protected:
59 QString tableName_;
60
63};
64
68class DissectorTablesModel : public QAbstractItemModel
69{
70 Q_OBJECT
71
72public:
77 explicit DissectorTablesModel(QObject * parent = Q_NULLPTR);
78
82 virtual ~DissectorTablesModel();
83
92
100 QModelIndex index(int row, int column,
101 const QModelIndex &parent = QModelIndex()) const override;
102
108 QModelIndex parent(const QModelIndex &index) const override;
109
116 QVariant data(const QModelIndex &index, int role) const override;
117
123 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
124
130 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
131
135 void populate();
136
137private:
139 DissectorTablesItem* root_;
140};
141
145class DissectorTablesProxyModel : public QSortFilterProxyModel
146{
147 Q_OBJECT
148
149public:
154 {
156 OnlyName = 0x1,
158 };
159 Q_ENUM(SearchType)
160 Q_DECLARE_FLAGS(SearchTypes, SearchType)
161
162
166 explicit DissectorTablesProxyModel(QObject * parent = Q_NULLPTR);
167
174 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
175
183 QVariant headerData(int section, Qt::Orientation orientation,
184 int role = Qt::DisplayRole) const override;
185
190 void adjustHeader(const QModelIndex &currentIndex);
191
196 void setFilter(const QString& filter, SearchTypes type);
197
198protected:
205 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
206
207private:
208
210 QString tableName_;
211
213 QString dissectorDescription_;
214
216 QString filter_;
217
218 DissectorTablesProxyModel::SearchTypes type_;
219};
220
221#endif // DISSECTOR_TABLES_MODEL_H
Represents a single item in the dissector tables model, supporting tree structures.
Definition dissector_tables_model.h:23
virtual bool lessThan(DissectorTablesItem &right) const
Compares this item with another for sorting purposes.
Definition dissector_tables_model.cpp:47
DissectorTablesItem(QString tableName, QString dissectorDescription, DissectorTablesItem *parent)
Constructs a new DissectorTablesItem.
Definition dissector_tables_model.cpp:36
QString dissectorDescription() const
Retrieves the dissector description associated with this item.
Definition dissector_tables_model.h:48
QString dissectorDescription_
Definition dissector_tables_model.h:62
QString tableName_
Definition dissector_tables_model.h:59
virtual ~DissectorTablesItem()
Destroys the DissectorTablesItem.
Definition dissector_tables_model.cpp:43
QString tableName() const
Retrieves the table name associated with this item.
Definition dissector_tables_model.h:42
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns under the given parent.
Definition dissector_tables_model.cpp:140
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
Definition dissector_tables_model.cpp:123
QVariant data(const QModelIndex &index, int role) const override
Retrieves data from the model for a given index and role.
Definition dissector_tables_model.cpp:186
virtual ~DissectorTablesModel()
Destroys the DissectorTablesModel.
Definition dissector_tables_model.cpp:118
DissectorTablesColumn
Enumeration of the columns available in the model.
Definition dissector_tables_model.h:87
@ colTableName
Definition dissector_tables_model.h:88
@ colDissectorDescription
Definition dissector_tables_model.h:89
@ colLast
Definition dissector_tables_model.h:90
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Generates an index for the specified row and column.
Definition dissector_tables_model.cpp:164
QModelIndex parent(const QModelIndex &index) const override
Retrieves the parent index for the given index.
Definition dissector_tables_model.cpp:145
void populate()
Populates the model with the currently registered dissector tables.
Definition dissector_tables_model.cpp:328
DissectorTablesModel(QObject *parent=Q_NULLPTR)
Constructs a new DissectorTablesModel.
Definition dissector_tables_model.cpp:111
SearchType
Defines the search filtering scope.
Definition dissector_tables_model.h:154
@ EveryWhere
Definition dissector_tables_model.h:155
@ OnlyName
Definition dissector_tables_model.h:156
@ OnlyDescription
Definition dissector_tables_model.h:157
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Compares two source indices to determine their sort order.
Definition dissector_tables_model.cpp:382
void setFilter(const QString &filter, SearchTypes type)
Sets the filter string used to screen items.
Definition dissector_tables_model.cpp:418
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Retrieves header data, potentially adjusted dynamically.
Definition dissector_tables_model.cpp:366
void adjustHeader(const QModelIndex &currentIndex)
Adjusts the header based on the currently selected index.
Definition dissector_tables_model.cpp:432
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Determines whether a row from the source model should be visible.
Definition dissector_tables_model.cpp:395
DissectorTablesProxyModel(QObject *parent=Q_NULLPTR)
Constructs a new DissectorTablesProxyModel.
Definition dissector_tables_model.cpp:355
ModelHelperTreeItem(DissectorTablesItem *parent)
Definition tree_model_helpers.h:31