Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
dissector_tables_model.h
1 /* dissector_tables_model.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef DISSECTOR_TABLES_MODEL_H
11 #define DISSECTOR_TABLES_MODEL_H
12 
13 #include <config.h>
14 
15 #include <ui/qt/models/tree_model_helpers.h>
16 
17 #include <QSortFilterProxyModel>
18 
19 class DissectorTablesItem : public ModelHelperTreeItem<DissectorTablesItem>
20 {
21 public:
22  DissectorTablesItem(QString tableName, QString shortName, DissectorTablesItem* parent);
23  virtual ~DissectorTablesItem();
24 
25  QString tableName() const {return tableName_;}
26  QString shortName() const {return shortName_;}
27 
28  virtual bool lessThan(DissectorTablesItem &right) const;
29 
30 protected:
31  QString tableName_;
32  QString shortName_;
33 };
34 
35 class DissectorTablesModel : public QAbstractItemModel
36 {
37  Q_OBJECT
38 
39 public:
40  explicit DissectorTablesModel(QObject * parent = Q_NULLPTR);
41  virtual ~DissectorTablesModel();
42 
43  enum DissectorTablesColumn {
44  colTableName = 0,
45  colShortName,
46  colLast
47  };
48 
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;
53 
54  int rowCount(const QModelIndex &parent = QModelIndex()) const;
55  int columnCount(const QModelIndex &parent = QModelIndex()) const;
56 
57  void populate();
58 
59 private:
60  DissectorTablesItem* root_;
61 };
62 
63 class DissectorTablesProxyModel : public QSortFilterProxyModel
64 {
65  Q_OBJECT
66 public:
67 
68  explicit DissectorTablesProxyModel(QObject * parent = Q_NULLPTR);
69 
70  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
71 
72  QVariant headerData(int section, Qt::Orientation orientation,
73  int role = Qt::DisplayRole) const;
74 
75  void adjustHeader(const QModelIndex &currentIndex);
76  void setFilter(const QString& filter);
77 
78 protected:
79  bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
80  bool filterAcceptItem(DissectorTablesItem& item) const;
81 
82 private:
83 
84  QString tableName_;
85  QString shortName_;
86  QString filter_;
87 };
88 
89 #endif // DISSECTOR_TABLES_MODEL_H
90 
91 /*
92  * Editor modelines
93  *
94  * Local Variables:
95  * c-basic-offset: 4
96  * tab-width: 8
97  * indent-tabs-mode: nil
98  * End:
99  *
100  * ex: set shiftwidth=4 tabstop=8 expandtab:
101  * :indentSize=4:tabSize=8:noTabs=true:
102  */
Definition: dissector_tables_model.h:19
Definition: tree_model_helpers.h:22
Definition: dissector_tables_model.h:35
Definition: dissector_tables_model.h:63