Wireshark 4.5.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,
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(int type);
61 static QString typeToHelp(int type);
62
63private:
64 void populate();
65
66 PrefsItem* root_;
67};
68
69class PrefsItem : public ModelHelperTreeItem<PrefsItem>
70{
71public:
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
88private:
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
98class AdvancedPrefsModel : public QSortFilterProxyModel
99{
100 Q_OBJECT
101
102public:
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
129protected:
130 bool filterAcceptItem(PrefsItem& item) const;
131
132private:
133
134 QString filter_;
135 bool show_changed_values_;
136 const QChar passwordChar_;
137};
138
139class ModulePrefsModel : public QSortFilterProxyModel
140{
141public:
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
161protected:
162 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
163
164private:
165 //cache of the translated "Advanced" preference name
166 QString advancedPrefName_;
167};
168
169extern pref_t *prefFromPrefPtr(void *pref_ptr);
170
171#endif // PREF_MODELS_H
Definition pref_models.h:99
Definition tree_model_helpers.h:23
Definition pref_models.h:140
Definition pref_models.h:70
Definition pref_models.h:25
Definition wslua.h:247
Definition prefs-int.h:27
Definition prefs.c:248