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