3 * Model caching interface changes before sending them to global storage
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef INTERFACE_TREE_CACHE_MODEL_H_
13 #define INTERFACE_TREE_CACHE_MODEL_H_
15 #include <ui/qt/models/interface_tree_model.h>
18 #include <QAbstractItemModel>
19 #include <QIdentityProxyModel>
21 class InterfaceTreeCacheModel
: public QIdentityProxyModel
26 explicit InterfaceTreeCacheModel(QObject
*parent
);
27 ~InterfaceTreeCacheModel();
29 int rowCount(const QModelIndex
&parent
= QModelIndex()) const;
30 QVariant
data (const QModelIndex
&index
, int role
= Qt::DisplayRole
) const;
32 bool setData(const QModelIndex
&index
, const QVariant
&value
, int role
= Qt::EditRole
);
33 Qt::ItemFlags
flags(const QModelIndex
&index
) const;
35 QVariant
getColumnContent(int idx
, int col
, int role
= Qt::DisplayRole
);
38 QModelIndex
index(int row
, int column
, const QModelIndex
&parent
= QModelIndex()) const;
43 void addDevice(const interface_t
* newDevice
);
44 void deleteDevice(const QModelIndex
&index
);
47 #ifdef HAVE_PCAP_REMOTE
48 bool isRemote(const QModelIndex
&index
) const;
52 InterfaceTreeModel
* sourceModel
;
55 QList
<interface_t
> newDevices
;
57 void saveNewDevices();
59 QMap
<int, QSharedPointer
<QMap
<InterfaceTreeColumns
, QVariant
> > > * storage
;
60 QList
<InterfaceTreeColumns
> editableColumns
;
61 QList
<InterfaceTreeColumns
> checkableColumns
;
64 const interface_t
* lookup(const QModelIndex
&index
) const;
67 bool changeIsAllowed(InterfaceTreeColumns col
) const;
68 bool isAvailableField(const QModelIndex
&index
) const;
69 bool isAllowedToBeEdited(const QModelIndex
&index
) const;
72 #endif /* INTERFACE_TREE_CACHE_MODEL_H_ */