TODO netlogon_user_flags_ntlmv2_enabled
[wireshark-sm.git] / ui / qt / models / enabled_protocols_model.h
blobfe6caeabdbe4d4362ebe0b2c7d1a20460b7c835e
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef ENABLED_PROTOCOLS_MODEL_H
11 #define ENABLED_PROTOCOLS_MODEL_H
13 #include <config.h>
15 #include <ui/qt/models/tree_model_helpers.h>
17 #include <epan/proto.h>
19 #include <QAbstractItemModel>
20 #include <QSortFilterProxyModel>
22 class EnabledProtocolItem : public ModelHelperTreeItem<EnabledProtocolItem>
24 Q_GADGET
25 public:
26 enum EnableProtocolType{
27 Any,
28 Standard,
29 Heuristic
31 Q_ENUM(EnableProtocolType)
33 EnabledProtocolItem(QString name, QString description, bool enabled, EnabledProtocolItem* parent);
34 virtual ~EnabledProtocolItem();
36 QString name() const {return name_;}
37 QString description() const {return description_;}
38 bool enabled() const {return enabled_;}
39 void setEnabled(bool enable) {enabled_ = enable;}
41 EnableProtocolType type() const;
43 bool applyValue();
45 protected:
46 virtual void applyValuePrivate(bool value) = 0;
48 QString name_;
49 QString description_;
50 bool enabled_;
51 bool enabledInit_; //value that model starts with to determine change
52 EnableProtocolType type_;
55 class EnabledProtocolsModel : public QAbstractItemModel
57 Q_OBJECT
59 public:
60 explicit EnabledProtocolsModel(QObject * parent = Q_NULLPTR);
61 virtual ~EnabledProtocolsModel();
63 enum EnabledProtocolsColumn {
64 colProtocol = 0,
65 colDescription,
66 colLast
69 enum EnableProtocolData {
70 DATA_ENABLE = Qt::UserRole,
71 DATA_PROTOCOL_TYPE
74 QModelIndex index(int row, int column,
75 const QModelIndex & = QModelIndex()) const;
76 QModelIndex parent(const QModelIndex &) const;
77 Qt::ItemFlags flags(const QModelIndex &index) const;
78 QVariant data(const QModelIndex &index, int role) const;
79 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
81 QVariant headerData(int section, Qt::Orientation orientation,
82 int role = Qt::DisplayRole) const;
84 int rowCount(const QModelIndex &parent = QModelIndex()) const;
85 int columnCount(const QModelIndex &parent = QModelIndex()) const;
87 void populate();
89 void applyChanges(bool writeChanges = true);
90 static void disableProtocol(struct _protocol *protocol);
92 protected:
93 static void saveChanges(bool writeChanges = true);
95 private:
96 EnabledProtocolItem* root_;
99 class EnabledProtocolsProxyModel : public QSortFilterProxyModel
101 Q_OBJECT
103 public:
104 enum SearchType
106 EveryWhere,
107 OnlyProtocol,
108 OnlyDescription,
109 EnabledItems,
110 DisabledItems
112 Q_ENUM(SearchType)
114 enum EnableType
116 Enable,
117 Disable,
118 Invert
121 explicit EnabledProtocolsProxyModel(QObject * parent = Q_NULLPTR);
123 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
124 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
126 void setFilter(const QString& filter, EnabledProtocolsProxyModel::SearchType type,
127 EnabledProtocolItem::EnableProtocolType protocolType);
129 void setItemsEnable(EnabledProtocolsProxyModel::EnableType enable, QModelIndex parent = QModelIndex());
131 protected:
132 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
134 private:
135 EnabledProtocolsProxyModel::SearchType type_;
136 EnabledProtocolItem::EnableProtocolType protocolType_;
137 QString filter_;
139 bool filterAcceptsSelf(int sourceRow, const QModelIndex &sourceParent) const;
140 bool filterAcceptsChild(int sourceRow, const QModelIndex &sourceParent) const;
143 #endif // ENABLED_PROTOCOLS_MODEL_H