Wireshark  4.3.0
The Wireshark network protocol analyzer
dissector_tables_model.h
Go to the documentation of this file.
1 
10 #ifndef DISSECTOR_TABLES_MODEL_H
11 #define DISSECTOR_TABLES_MODEL_H
12 
13 #include <config.h>
14 
16 
17 #include <QSortFilterProxyModel>
18 
19 class DissectorTablesItem : public ModelHelperTreeItem<DissectorTablesItem>
20 {
21 public:
22  DissectorTablesItem(QString tableName, QString dissectorDescription, DissectorTablesItem* parent);
23  virtual ~DissectorTablesItem();
24 
25  QString tableName() const {return tableName_;}
26  QString dissectorDescription() const {return dissectorDescription_;}
27 
28  virtual bool lessThan(DissectorTablesItem &right) const;
29 
30 protected:
31  QString tableName_;
32  QString dissectorDescription_;
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  colDissectorDescription,
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 
67 public:
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 dissectorDescription_;
86  QString filter_;
87 };
88 
89 #endif // DISSECTOR_TABLES_MODEL_H
Definition: dissector_tables_model.h:20
Definition: dissector_tables_model.h:36
Definition: dissector_tables_model.h:64
Definition: tree_model_helpers.h:23