1 /* interface_tree_model.h
2  * Model for the interface data for display in the interface frame
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef INTERFACE_TREE_MODEL_H
12 #define INTERFACE_TREE_MODEL_H
13 
14 #include <config.h>
15 
16 #ifdef HAVE_LIBPCAP
17 #include "ui/capture.h"
18 #include "ui/capture_globals.h"
19 #endif
20 
21 #include <glib.h>
22 
23 #include <QAbstractTableModel>
24 #include <QList>
25 #include <QMap>
26 #include <QItemSelection>
27 
28 typedef QList<int> PointList;
29 
30 enum InterfaceTreeColumns
31 {
32     IFTREE_COL_EXTCAP,
33     IFTREE_COL_EXTCAP_PATH,
34     IFTREE_COL_NAME,
35     IFTREE_COL_DESCRIPTION,
36     IFTREE_COL_DISPLAY_NAME,
37     IFTREE_COL_COMMENT,
38     IFTREE_COL_HIDDEN,
39     IFTREE_COL_DLT,
40     IFTREE_COL_PROMISCUOUSMODE,
41     IFTREE_COL_TYPE,
42     IFTREE_COL_STATS,
43     IFTREE_COL_SNAPLEN,
44 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
45     IFTREE_COL_BUFFERLEN,
46 #endif
47 #ifdef HAVE_PCAP_CREATE
48     IFTREE_COL_MONITOR_MODE,
49 #endif
50     IFTREE_COL_CAPTURE_FILTER,
51     IFTREE_COL_PIPE_PATH,
52     IFTREE_COL_MAX /* is not being displayed, it is the definition for the maximum numbers of columns */
53 };
54 
55 class InterfaceTreeModel : public QAbstractTableModel
56 {
57     Q_OBJECT
58 
59 public:
60     InterfaceTreeModel(QObject *parent);
61     ~InterfaceTreeModel();
62 
63     int rowCount(const QModelIndex &parent = QModelIndex()) const;
64     int columnCount(const QModelIndex &parent = QModelIndex()) const;
65     QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
66     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
67 
68     void updateStatistic(unsigned int row);
69 #ifdef HAVE_LIBPCAP
70     void stopStatistic();
71 #endif
72 
73     QString interfaceError();
74     QItemSelection selectedDevices();
75     bool updateSelectedDevices(QItemSelection sourceSelection);
76 
77     QVariant getColumnContent(int idx, int col, int role = Qt::DisplayRole);
78 
79 #ifdef HAVE_PCAP_REMOTE
80     bool isRemote(int idx);
81 #endif
82 
83     static const QString DefaultNumericValue;
84 
85 public slots:
86     void getPoints(int idx, PointList *pts);
87 
88 protected slots:
89     void interfaceListChanged();
90 
91 private:
92     QVariant toolTipForInterface(int idx) const;
93     QMap<QString, PointList> points;
94 
95 #ifdef HAVE_LIBPCAP
96     if_stat_cache_t *stat_cache_;
97 #endif // HAVE_LIBPCAP
98 };
99 
100 #endif // INTERFACE_TREE_MODEL_H
101