Wireshark  4.3.0
The Wireshark network protocol analyzer
manuf_table_model.h
Go to the documentation of this file.
1 
10 #ifndef MANUF_TABLE_MODEL_H
11 #define MANUF_TABLE_MODEL_H
12 
13 #include <QSortFilterProxyModel>
14 #include <QAbstractTableModel>
15 #include <QList>
16 
17 #include <wireshark.h>
18 #include <epan/manuf.h>
19 
21 {
22 public:
23  ManufTableItem(struct ws_manuf *ptr);
24  ~ManufTableItem();
25 
26  QByteArray block_bytes_;
27  QString block_name_;
28  QString short_name_;
29  QString long_name_;
30 };
31 
32 class ManufTableModel : public QAbstractTableModel
33 {
34  Q_OBJECT
35 
36 public:
37  ManufTableModel(QObject *parent);
38  ~ManufTableModel();
39  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const ;
40  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
41  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
42  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
43 
44  void addRecord(struct ws_manuf *ptr);
45 
46  void clear();
47 
48  enum {
49  COL_MAC_PREFIX,
50  COL_SHORT_NAME,
51  COL_VENDOR_NAME,
52  NUM_COLS,
53  };
54 
55 private:
56  QList<ManufTableItem *> rows_;
57 };
58 
59 class ManufSortFilterProxyModel : public QSortFilterProxyModel
60 {
61  Q_OBJECT
62 
63 public:
64  enum ManufProxyFilterType
65  {
66  FilterEmpty = 0,
67  FilterByAddress,
68  FilterByName,
69  };
70  Q_ENUM(ManufProxyFilterType)
71 
72  ManufSortFilterProxyModel(QObject *parent);
73 
74  virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
75 
76 public slots:
77  void setFilterAddress(const QByteArray&);
78  void setFilterName(QRegularExpression&);
79  void clearFilter();
80 
81 private:
82  ManufProxyFilterType filter_type_;
83  QByteArray filter_bytes_;
84  QRegularExpression filter_name_;
85 
86  bool filterAddressAcceptsRow(int source_row, const QModelIndex& source_parent) const;
87  bool filterNameAcceptsRow(int source_row, const QModelIndex& source_parent) const;
88 };
89 
90 #endif
Definition: manuf_table_model.h:60
Definition: manuf_table_model.h:21
Definition: manuf_table_model.h:33
Definition: manuf.h:20