Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
interface_tree_cache_model.h
1 /* interface_tree_cache_model.h
2  * Model caching interface changes before sending them to global storage
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_CACHE_MODEL_H_
12 #define INTERFACE_TREE_CACHE_MODEL_H_
13 
14 #include <ui/qt/models/interface_tree_model.h>
15 
16 #include <QMap>
17 #include <QAbstractItemModel>
18 #include <QIdentityProxyModel>
19 
20 class InterfaceTreeCacheModel : public QIdentityProxyModel
21 {
22  Q_OBJECT
23 
24 public:
25  explicit InterfaceTreeCacheModel(QObject *parent);
27 
28  int rowCount(const QModelIndex &parent = QModelIndex()) const;
29  QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
30 
31  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
32  Qt::ItemFlags flags(const QModelIndex &index) const;
33 
34  QVariant getColumnContent(int idx, int col, int role = Qt::DisplayRole);
35 
36 #ifdef HAVE_LIBPCAP
37  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
38 
39  void reset(int row);
40  void save();
41 
42  void addDevice(const interface_t * newDevice);
43  void deleteDevice(const QModelIndex &index);
44 #endif
45 
46 private:
47  InterfaceTreeModel * sourceModel;
48 
49 #ifdef HAVE_LIBPCAP
50  QList<interface_t> newDevices;
51 
52  void saveNewDevices();
53 #endif
54  QMap<int, QMap<InterfaceTreeColumns, QVariant> *> * storage;
55  QList<InterfaceTreeColumns> editableColumns;
56  QList<InterfaceTreeColumns> checkableColumns;
57 
58 #ifdef HAVE_LIBPCAP
59  const interface_t * lookup(const QModelIndex &index) const;
60 #endif
61 
62  bool changeIsAllowed(InterfaceTreeColumns col) const;
63  bool isAvailableField(const QModelIndex &index) const;
64  bool isAllowedToBeEdited(const QModelIndex &index) const;
65 
66 };
67 #endif /* INTERFACE_TREE_CACHE_MODEL_H_ */
68 
69 /*
70  * Editor modelines
71  *
72  * Local Variables:
73  * c-basic-offset: 4
74  * tab-width: 8
75  * indent-tabs-mode: nil
76  * End:
77  *
78  * ex: set shiftwidth=4 tabstop=8 expandtab:
79  * :indentSize=4:tabSize=8:noTabs=true:
80  */
Definition: interface_tree_model.h:54
Definition: interface_tree_cache_model.h:20
Definition: androiddump.c:211