Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

pref_models.h
1 /* pref_models.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #ifndef PREF_MODELS_H
11 #define PREF_MODELS_H
12
13 #include <config.h>
14
15 #include <ui/qt/models/tree_model_helpers.h>
16
17 #include <epan/prefs.h>
18
19 #include <QSortFilterProxyModel>
20 #include <QTreeView>
21
22 class PrefsItem : public ModelHelperTreeItem<PrefsItem>
23 {
24 public:
25 PrefsItem(module_t *module, pref_t *pref, PrefsItem* parent);
26 PrefsItem(const QString name, PrefsItem* parent);
27 virtual ~PrefsItem();
28
29 QString getName() const {return name_;}
30 pref_t* getPref() const {return pref_;}
31 int getPrefType() const;
32 int getPrefGUIType() const;
33 bool isPrefDefault() const;
34 QString getPrefTypeName() const;
35 module_t* getModule() const {return module_;}
36 QString getModuleName() const;
37 QString getModuleTitle() const;
38 void setChanged(bool changed = true);
39
40 private:
41 pref_t *pref_;
42 module_t *module_;
43 QString name_;
44 //set to true if changed during module manipulation
45 //Used to determine proper "default" for comparison
46 bool changed_;
47 };
48
49
50 class PrefsModel : public QAbstractItemModel
51 {
52 Q_OBJECT
53
54 public:
55 explicit PrefsModel(QObject * parent = Q_NULLPTR);
56 virtual ~PrefsModel();
57
58 //Names of special preferences handled by the GUI
59 //Names used as keys to determine correct pan displayed
60 static const char* ADVANCED_PREFERENCE_TREE_NAME;
61 static const char* APPEARANCE_PREFERENCE_TREE_NAME;
62 static const char* LAYOUT_PREFERENCE_TREE_NAME;
63 static const char* COLUMNS_PREFERENCE_TREE_NAME;
64 static const char* FONT_AND_COLORS_PREFERENCE_TREE_NAME;
65 static const char* CAPTURE_PREFERENCE_TREE_NAME;
66 static const char* EXPERT_PREFERENCE_TREE_NAME;
67 static const char* FILTER_BUTTONS_PREFERENCE_TREE_NAME;
68
69 enum PrefsModelColumn {
70 colName = 0,
71 colStatus,
72 colType,
73 colValue,
74 colLast
75 };
76
77 QModelIndex index(int row, int column,
78 const QModelIndex & = QModelIndex()) const;
79 QModelIndex parent(const QModelIndex &) const;
80 QVariant data(const QModelIndex &index, int role) const;
81
82 int rowCount(const QModelIndex &parent = QModelIndex()) const;
83 int columnCount(const QModelIndex &parent = QModelIndex()) const;
84
85 private:
86 void populate();
87
88 PrefsItem* root_;
89 };
90
91 class AdvancedPrefsModel : public QSortFilterProxyModel
92 {
93 Q_OBJECT
94 public:
95
96 explicit AdvancedPrefsModel(QObject * parent = Q_NULLPTR);
97
98 enum AdvancedPrefsModelColumn {
99 colName = 0,
100 colStatus,
101 colType,
102 colValue,
103 colLast
104 };
105
106 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
107
108 void setFilter(const QString& filter);
109
110 QVariant headerData(int section, Qt::Orientation orientation,
111 int role = Qt::DisplayRole) const;
112 QVariant data(const QModelIndex &index, int role) const;
113 Qt::ItemFlags flags(const QModelIndex &index) const;
114 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
115
116 int columnCount(const QModelIndex &parent = QModelIndex()) const;
117
118 //Keep the internals of model hidden from tree
119 void setFirstColumnSpanned(QTreeView* tree, const QModelIndex &index = QModelIndex());
120
121 protected:
122 bool filterAcceptItem(PrefsItem& item) const;
123
124 private:
125
126 QString filter_;
127 };
128
129 class ModulePrefsModel : public QSortFilterProxyModel
130 {
131 Q_OBJECT
132 public:
133
134 explicit ModulePrefsModel(QObject * parent = Q_NULLPTR);
135
136 enum ModulePrefsModelColumn {
137 colName = 0,
138 colLast
139 };
140
141 enum ModulePrefsRoles {
142 ModuleName = Qt::UserRole + 1
143 };
144
145 QVariant data(const QModelIndex &index, int role) const;
146 Qt::ItemFlags flags(const QModelIndex &index) const;
147 int columnCount(const QModelIndex &parent = QModelIndex()) const;
148
149 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
150
151 protected:
152 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
153
154 private:
155 //cache of the translated "Advanced" preference name
156 QString advancedPrefName_;
157 };
158
159 extern pref_t *prefFromPrefPtr(void *pref_ptr);
160
161 #endif // PREF_MODELS_H
162
163 /*
164 * Editor modelines
165 *
166 * Local Variables:
167 * c-basic-offset: 4
168 * tab-width: 8
169 * indent-tabs-mode: nil
170 * End:
171 *
172 * ex: set shiftwidth=4 tabstop=8 expandtab:
173 * :indentSize=4:tabSize=8:noTabs=true:
174 */
AdvancedPrefsModel
Definition: pref_models.h:91
PrefsModel
Definition: pref_models.h:50
pref_module
Definition: prefs-int.h:27
ModelHelperTreeItem
Definition: tree_model_helpers.h:22
PrefsItem
Definition: pref_models.h:22
ModulePrefsModel
Definition: pref_models.h:129
preference
Definition: prefs.c:192