Wireshark  4.3.0
The Wireshark network protocol analyzer
interface_tree_model.h
Go to the documentation of this file.
1 
12 #ifndef INTERFACE_TREE_MODEL_H
13 #define INTERFACE_TREE_MODEL_H
14 
15 #include <config.h>
16 #include <wireshark.h>
17 
18 #ifdef HAVE_LIBPCAP
19 #include "ui/capture.h"
20 #include "ui/capture_globals.h"
21 #endif
22 
23 #include <QAbstractTableModel>
24 #include <QList>
25 #include <QMap>
26 #include <QItemSelection>
27 
28 typedef QList<int> PointList;
29 
30 /*
31  * When sorting, QSortFilterProxyModel creates its own mapping instead
32  * of using the QModelIndex mapping with mapToSource to determine which
33  * column in the proxy model maps to which column in the source. Its own
34  * mapping is always done in order; this means that it's easier if all
35  * the Views of this model keep the columns in the same relative order,
36  * but can omit columns. (If you really need to change the order,
37  * QHeaderView::swapSections() can be used.)
38  */
39 enum InterfaceTreeColumns
40 {
41  IFTREE_COL_EXTCAP, // InterfaceFrame interfaceTree
42  IFTREE_COL_EXTCAP_PATH,
43  IFTREE_COL_HIDDEN, // ManageInterfaceDialog localView
44  IFTREE_COL_DISPLAY_NAME, // InterfaceFrame interfaceTree
45  IFTREE_COL_DESCRIPTION, // ManageInterfaceDialog localView
46  IFTREE_COL_NAME, // ManageInterfaceDialog localView
47  IFTREE_COL_COMMENT, // ManageInterfaceDialog localView
48  IFTREE_COL_STATS, // InterfaceFrame interfaceTree
49  IFTREE_COL_DLT,
50  IFTREE_COL_PROMISCUOUSMODE,
51  IFTREE_COL_TYPE,
52  IFTREE_COL_ACTIVE,
53  IFTREE_COL_SNAPLEN,
54 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
55  IFTREE_COL_BUFFERLEN,
56 #endif
57 #ifdef HAVE_PCAP_CREATE
58  IFTREE_COL_MONITOR_MODE,
59 #endif
60  IFTREE_COL_CAPTURE_FILTER,
61  IFTREE_COL_PIPE_PATH, // ManageInterfaceDialog pipeView
62  IFTREE_COL_MAX /* is not being displayed, it is the definition for the maximum numbers of columns */
63 };
64 
65 class InterfaceTreeModel : public QAbstractTableModel
66 {
67  Q_OBJECT
68 
69 public:
70  InterfaceTreeModel(QObject *parent);
72 
73  int rowCount(const QModelIndex &parent = QModelIndex()) const;
74  int columnCount(const QModelIndex &parent = QModelIndex()) const;
75  QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
76  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
77 
78  void updateStatistic(unsigned int row);
79 #ifdef HAVE_LIBPCAP
80  void setCache(if_stat_cache_t *stat_cache);
81  void stopStatistic();
82 #endif
83 
84  QString interfaceError();
85  QItemSelection selectedDevices();
86  bool updateSelectedDevices(QItemSelection sourceSelection);
87 
88  QVariant getColumnContent(int idx, int col, int role = Qt::DisplayRole);
89 
90 #ifdef HAVE_PCAP_REMOTE
91  bool isRemote(int idx);
92 #endif
93 
94  static const QString DefaultNumericValue;
95 
96 public slots:
97  void interfaceListChanged();
98 
99 private:
100  QVariant toolTipForInterface(int idx) const;
101  QMap<QString, PointList> points;
102  QMap<QString, bool> active;
103 
104 #ifdef HAVE_LIBPCAP
105  if_stat_cache_t *stat_cache_;
106 #endif // HAVE_LIBPCAP
107 };
108 
109 #endif // INTERFACE_TREE_MODEL_H
Definition: interface_tree_model.h:66
InterfaceTreeModel(QObject *parent)
Definition: interface_tree_model.cpp:42
void interfaceListChanged()
Definition: interface_tree_model.cpp:357