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
16
17#include <epan/prefs.h>
18
19#include <QSortFilterProxyModel>
20#include <QTreeView>
21
22class PrefsItem;
23
24class PrefsModel : public QAbstractItemModel
25{
26 Q_OBJECT
27
28public:
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,
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
64private:
65 void populate();
66
67 PrefsItem* root_;
68};
69
70class PrefsItem : public ModelHelperTreeItem<PrefsItem>
71{
72public:
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
89private:
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
99class AdvancedPrefsModel : public QSortFilterProxyModel
100{
101 Q_OBJECT
102
103public:
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
130protected:
131 bool filterAcceptItem(PrefsItem& item) const;
132
133private:
134
135 QString filter_;
136 bool show_changed_values_;
137 const QChar passwordChar_;
138};
139
140class ModulePrefsModel : public QSortFilterProxyModel
141{
142public:
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
162protected:
163 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
164
165private:
166 //cache of the translated "Advanced" preference name
167 QString advancedPrefName_;
168};
169
170extern pref_t *prefFromPrefPtr(void *pref_ptr);
171
172#endif // PREF_MODELS_H
Definition pref_models.h:100
Definition tree_model_helpers.h:23
Definition pref_models.h:141
Definition pref_models.h:71
Definition pref_models.h:25
Definition welcome_page.h:27
Definition wslua.h:247
Definition prefs-int.h:27
Definition prefs.c:201