3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef DISSECTOR_TABLES_MODEL_H
11 #define DISSECTOR_TABLES_MODEL_H
15 #include <ui/qt/models/tree_model_helpers.h>
17 #include <QSortFilterProxyModel>
19 class DissectorTablesItem
: public ModelHelperTreeItem
<DissectorTablesItem
>
22 DissectorTablesItem(QString tableName
, QString dissectorDescription
, DissectorTablesItem
* parent
);
23 virtual ~DissectorTablesItem();
25 QString
tableName() const {return tableName_
;}
26 QString
dissectorDescription() const {return dissectorDescription_
;}
28 virtual bool lessThan(DissectorTablesItem
&right
) const;
32 QString dissectorDescription_
;
35 class DissectorTablesModel
: public QAbstractItemModel
40 explicit DissectorTablesModel(QObject
* parent
= Q_NULLPTR
);
41 virtual ~DissectorTablesModel();
43 enum DissectorTablesColumn
{
45 colDissectorDescription
,
49 QModelIndex
index(int row
, int column
,
50 const QModelIndex
& = QModelIndex()) const;
51 QModelIndex
parent(const QModelIndex
&) const;
52 QVariant
data(const QModelIndex
&index
, int role
) const;
54 int rowCount(const QModelIndex
&parent
= QModelIndex()) const;
55 int columnCount(const QModelIndex
&parent
= QModelIndex()) const;
60 DissectorTablesItem
* root_
;
63 class DissectorTablesProxyModel
: public QSortFilterProxyModel
68 explicit DissectorTablesProxyModel(QObject
* parent
= Q_NULLPTR
);
70 virtual bool filterAcceptsRow(int sourceRow
, const QModelIndex
&sourceParent
) const;
72 QVariant
headerData(int section
, Qt::Orientation orientation
,
73 int role
= Qt::DisplayRole
) const;
75 void adjustHeader(const QModelIndex
¤tIndex
);
76 void setFilter(const QString
& filter
);
79 bool lessThan(const QModelIndex
&source_left
, const QModelIndex
&source_right
) const;
80 bool filterAcceptItem(DissectorTablesItem
& item
) const;
85 QString dissectorDescription_
;
89 #endif // DISSECTOR_TABLES_MODEL_H