Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
supported_protocols_model.h
1 /* supported_protocols_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 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 
21 class SupportedProtocolsItem : public ModelHelperTreeItem<SupportedProtocolsItem>
22 {
23 public:
24  SupportedProtocolsItem(protocol_t* proto, const char *name, const char* filter, ftenum_t ftype, const char* descr, SupportedProtocolsItem* parent);
25  virtual ~SupportedProtocolsItem();
26 
27  protocol_t* protocol() const {return proto_; }
28  QString name() const { return name_; }
29  ftenum_t type() const {return ftype_; }
30  QString filter() const { return filter_; }
31  QString description() const { return descr_; }
32 
33 private:
34  protocol_t* proto_;
35  QString name_;
36  QString filter_;
37  ftenum_t ftype_;
38  QString descr_;
39 };
40 
41 
42 class SupportedProtocolsModel : public QAbstractItemModel
43 {
44  Q_OBJECT
45 
46 public:
47  explicit SupportedProtocolsModel(QObject * parent = Q_NULLPTR);
48  virtual ~SupportedProtocolsModel();
49 
50  enum SupportedProtocolsColumn {
51  colName = 0,
52  colFilter,
53  colType,
54  colDescription,
55  colLast
56  };
57 
58  int fieldCount() {return field_count_;}
59 
60  QModelIndex index(int row, int column,
61  const QModelIndex & = QModelIndex()) const;
62  QModelIndex parent(const QModelIndex &) const;
63  QVariant data(const QModelIndex &index, int role) const;
64 
65  QVariant headerData(int section, Qt::Orientation orientation,
66  int role = Qt::DisplayRole) const;
67 
68  int rowCount(const QModelIndex &parent = QModelIndex()) const;
69  int columnCount(const QModelIndex &parent = QModelIndex()) const;
70 
71  void populate();
72 
73 private:
75  int field_count_;
76 };
77 
78 class SupportedProtocolsProxyModel : public QSortFilterProxyModel
79 {
80  Q_OBJECT
81 public:
82 
83  explicit SupportedProtocolsProxyModel(QObject * parent = Q_NULLPTR);
84 
85  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
86 
87  void setFilter(const QString& filter);
88 
89 protected:
90  bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
91  bool filterAcceptItem(SupportedProtocolsItem& item) const;
92 
93 private:
94 
95  QString filter_;
96 };
97 
98 #endif // SUPPORTED_PROTOCOLS_MODEL_H
99 
100 /*
101  * Editor modelines
102  *
103  * Local Variables:
104  * c-basic-offset: 4
105  * tab-width: 8
106  * indent-tabs-mode: nil
107  * End:
108  *
109  * ex: set shiftwidth=4 tabstop=8 expandtab:
110  * :indentSize=4:tabSize=8:noTabs=true:
111  */
Definition: supported_protocols_model.h:21
Definition: supported_protocols_model.h:78
Definition: tree_model_helpers.h:22
Definition: supported_protocols_model.h:42
Definition: proto.c:312