| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
pref_models.h
Go to the documentation of this file.
1
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;
23
24 class PrefsModel : public QAbstractItemModel
25{
26 Q_OBJECT
27
28 public:
29 explicit PrefsModel(QObject * parent = Q_NULLPTR);
30 virtual ~PrefsModel();
31
32 enum PrefsModelType {
33 Advanced = Qt::UserRole,
34 Appearance,
35 Layout,
36 Columns,
37 FontAndColors,
38 Capture,
39 Expert,
40 FilterButtons,
41 RSAKeys
42 };
43
44 enum PrefsModelColumn {
45 colName = 0,
46 colStatus,
47 colType,
48 colValue,
49 colLast
50 };
51
52 QModelIndex index(int row, int column,
53 const QModelIndex & = QModelIndex()) const;
54 QModelIndex parent(const QModelIndex &) const;
55 QVariant data(const QModelIndex &index, int role) const;
56
57 int rowCount(const QModelIndex &parent = QModelIndex()) const;
58 int columnCount(const QModelIndex &parent = QModelIndex()) const;
59
60 static QString typeToString(PrefsModelType type);
61 static QString typeToHelp(PrefsModelType type);
62
63 private:
64 void populate();
65
66 PrefsItem* root_;
67};
68
69 class PrefsItem : public ModelHelperTreeItem<PrefsItem>
70{
71 public:
72 PrefsItem(module_t *module, pref_t *pref, PrefsItem* parent);
73 PrefsItem(const QString name, PrefsItem* parent);
74 PrefsItem(PrefsModel::PrefsModelType type, PrefsItem* parent);
75 virtual ~PrefsItem();
76
77 QString getName() const {return name_;}
78 pref_t* getPref() const {return pref_;}
79 int getPrefType() const;
80 bool isPrefDefault() const;
81 QString getPrefTypeName() const;
82 module_t* getModule() const {return module_;}
83 QString getModuleName() const;
84 QString getModuleTitle() const;
85 QString getModuleHelp() const;
86 void setChanged(bool changed = true);
87
88 private:
89 pref_t *pref_;
90 module_t *module_;
91 QString name_;
92 QString help_;
93 //set to true if changed during module manipulation
94 //Used to determine proper "default" for comparison
95 bool changed_;
96};
97
98 class AdvancedPrefsModel : public QSortFilterProxyModel
99{
100 Q_OBJECT
101
102 public:
103 explicit AdvancedPrefsModel(QObject * parent = Q_NULLPTR);
104
105 enum AdvancedPrefsModelColumn {
106 colName = 0,
107 colStatus,
108 colType,
109 colValue,
110 colLast
111 };
112
113 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
114
115 void setFilter(const QString& filter);
116 void setShowChangedValues(bool show_changed_values);
117
118 QVariant headerData(int section, Qt::Orientation orientation,
119 int role = Qt::DisplayRole) const;
120 QVariant data(const QModelIndex &index, int role) const;
121 Qt::ItemFlags flags(const QModelIndex &index) const;
122 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
123
124 int columnCount(const QModelIndex &parent = QModelIndex()) const;
125
126 //Keep the internals of model hidden from tree
127 void setFirstColumnSpanned(QTreeView* tree, const QModelIndex &index = QModelIndex());
128
129 protected:
130 bool filterAcceptItem(PrefsItem& item) const;
131
132 private:
133
134 QString filter_;
135 bool show_changed_values_;
136 const QChar passwordChar_;
137};
138
139 class ModulePrefsModel : public QSortFilterProxyModel
140{
141 public:
142
143 explicit ModulePrefsModel(QObject * parent = Q_NULLPTR);
144
145 enum ModulePrefsModelColumn {
146 colName = 0,
147 colLast
148 };
149
150 enum ModulePrefsRoles {
151 ModuleName = Qt::UserRole + 1,
152 ModuleHelp = Qt::UserRole + 2
153 };
154
155 QVariant data(const QModelIndex &index, int role) const;
156 Qt::ItemFlags flags(const QModelIndex &index) const;
157 int columnCount(const QModelIndex &parent = QModelIndex()) const;
158
159 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
160
161 protected:
162 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
163
164 private:
165 //cache of the translated "Advanced" preference name
166 QString advancedPrefName_;
167};
168
169 extern pref_t *prefFromPrefPtr(void *pref_ptr);
170
171#endif // PREF_MODELS_H
AdvancedPrefsModel
Definition pref_models.h:99
ModelHelperTreeItem
Definition tree_model_helpers.h:23
ModulePrefsModel
Definition pref_models.h:140
PrefsItem
Definition pref_models.h:70
PrefsModel
Definition pref_models.h:25
prefs.h
_wslua_cols
Definition wslua.h:247
pref_module
Definition prefs-int.h:27
preference
Definition prefs.c:216
tree_model_helpers.h