| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
pref_models.h
Go to the documentation of this file.
1
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;
23
27 class PrefsModel : public QAbstractItemModel
28{
29 Q_OBJECT
30
31 public:
36 explicit PrefsModel(QObject *parent = Q_NULLPTR);
37
39 virtual ~PrefsModel();
40
44 enum PrefsModelType {
45 Advanced = Qt::UserRole,
46 Appearance,
47 Layout,
48 Columns,
49 FontAndColors,
50 WelcomePage,
51 Capture,
52 Expert,
53 FilterButtons,
54 RSAKeys,
55 Aggregation
56 };
57
61 enum PrefsModelColumn {
62 colName = 0,
63 colStatus,
64 colType,
65 colValue,
66 colLast
67 };
68
76 QModelIndex index(int row, int column,
77 const QModelIndex &parent = QModelIndex()) const override;
78
85 QModelIndex parent(const QModelIndex &index) const override;
86
93 QVariant data(const QModelIndex &index, int role) const override;
94
100 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
101
107 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
108
114 static QString typeToString(PrefsModelType type);
115
121 static QString typeToHelp(PrefsModelType type);
122
123 private:
127 void populate();
128
129 PrefsItem *root_;
130};
131
135 class PrefsItem : public ModelHelperTreeItem<PrefsItem>
136{
137 public:
144 PrefsItem(module_t *module, pref_t *pref, PrefsItem *parent);
145
151 PrefsItem(const QString name, PrefsItem *parent);
152
158 PrefsItem(PrefsModel::PrefsModelType type, PrefsItem *parent);
159
161 virtual ~PrefsItem();
162
167 QString getName() const { return name_; }
168
173 pref_t *getPref() const { return pref_; }
174
179 int getPrefType() const;
180
185 bool isPrefDefault() const;
186
191 QString getPrefTypeName() const;
192
197 module_t *getModule() const { return module_; }
198
203 QString getModuleName() const;
204
209 QString getModuleTitle() const;
210
215 QString getModuleHelp() const;
216
221 void setChanged(bool changed = true);
222
223 private:
224 pref_t *pref_;
225 module_t *module_;
226 QString name_;
227 QString help_;
230 bool changed_;
231};
232
236 class AdvancedPrefsModel : public QSortFilterProxyModel
237{
238 Q_OBJECT
239
240 public:
245 explicit AdvancedPrefsModel(QObject *parent = Q_NULLPTR);
246
250 enum AdvancedPrefsModelColumn {
251 colName = 0,
252 colStatus,
253 colType,
254 colValue,
255 colLast
256 };
257
268 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
269
278 void setFilter(const QString &filter);
279
285 void setShowChangedValues(bool show_changed_values);
286
294 QVariant headerData(int section, Qt::Orientation orientation,
295 int role = Qt::DisplayRole) const override;
296
304 QVariant data(const QModelIndex &index, int role) const override;
305
314 Qt::ItemFlags flags(const QModelIndex &index) const override;
315
324 bool setData(const QModelIndex &index, const QVariant &value,
325 int role = Qt::EditRole) override;
326
332 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
333
343 void setFirstColumnSpanned(QTreeView *tree, const QModelIndex &index = QModelIndex());
344
345 protected:
351 bool filterAcceptItem(PrefsItem &item) const;
352
353 private:
354 QString filter_;
355 bool show_changed_values_;
356 const QChar passwordChar_;
357};
358
363 class ModulePrefsModel : public QSortFilterProxyModel
364{
365 public:
370 explicit ModulePrefsModel(QObject *parent = Q_NULLPTR);
371
375 enum ModulePrefsModelColumn {
376 colName = 0,
377 colLast
378 };
379
383 enum ModulePrefsRoles {
384 ModuleName = Qt::UserRole + 1,
385 ModuleHelp = Qt::UserRole + 2
386 };
387
395 QVariant data(const QModelIndex &index, int role) const override;
396
403 Qt::ItemFlags flags(const QModelIndex &index) const override;
404
410 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
411
419 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
420
421 protected:
429 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
430
431 private:
434 QString advancedPrefName_;
435};
436
443 extern pref_t *prefFromPrefPtr(void *pref_ptr);
444
445#endif // PREF_MODELS_H
AdvancedPrefsModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Return the item flags for index.
Definition pref_models.cpp:624
AdvancedPrefsModel::setFirstColumnSpanned
void setFirstColumnSpanned(QTreeView *tree, const QModelIndex &index=QModelIndex())
Mark module-level rows as spanning all columns in tree.
Definition pref_models.cpp:653
AdvancedPrefsModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Return the column header label.
Definition pref_models.cpp:408
AdvancedPrefsModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns in this model.
Definition pref_models.cpp:647
AdvancedPrefsModel::AdvancedPrefsModelColumn
AdvancedPrefsModelColumn
Column indices for the Advanced preferences view.
Definition pref_models.h:250
AdvancedPrefsModel::colStatus
@ colStatus
Definition pref_models.h:252
AdvancedPrefsModel::colType
@ colType
Definition pref_models.h:253
AdvancedPrefsModel::colName
@ colName
Definition pref_models.h:251
AdvancedPrefsModel::colLast
@ colLast
Definition pref_models.h:255
AdvancedPrefsModel::colValue
@ colValue
Definition pref_models.h:254
AdvancedPrefsModel::data
QVariant data(const QModelIndex &index, int role) const override
Return data for index under role.
Definition pref_models.cpp:428
AdvancedPrefsModel::filterAcceptsRow
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Determine whether a source row should be included in the view.
Definition pref_models.cpp:722
AdvancedPrefsModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Write value to the preference at index.
Definition pref_models.cpp:527
AdvancedPrefsModel::setShowChangedValues
void setShowChangedValues(bool show_changed_values)
Restrict the view to preferences that differ from their defaults.
Definition pref_models.cpp:752
AdvancedPrefsModel::filterAcceptItem
bool filterAcceptItem(PrefsItem &item) const
Test whether a single PrefsItem passes the current filters.
Definition pref_models.cpp:677
AdvancedPrefsModel::setFilter
void setFilter(const QString &filter)
Set the text filter applied to preference names and values.
Definition pref_models.cpp:739
AdvancedPrefsModel::AdvancedPrefsModel
AdvancedPrefsModel(QObject *parent=Q_NULLPTR)
Construct an AdvancedPrefsModel.
Definition pref_models.cpp:400
ModelHelperTreeItem< PrefsItem >::ModelHelperTreeItem
ModelHelperTreeItem(PrefsItem *parent)
Definition tree_model_helpers.h:31
ModulePrefsModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Return the item flags for index.
Definition pref_models.cpp:807
ModulePrefsModel::ModulePrefsModel
ModulePrefsModel(QObject *parent=Q_NULLPTR)
Construct a ModulePrefsModel.
Definition pref_models.cpp:767
ModulePrefsModel::filterAcceptsRow
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Determine whether a source row should appear in the module pane.
Definition pref_models.cpp:875
ModulePrefsModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns in this model.
Definition pref_models.cpp:840
ModulePrefsModel::data
QVariant data(const QModelIndex &index, int role) const override
Return data for index under role.
Definition pref_models.cpp:773
ModulePrefsModel::ModulePrefsModelColumn
ModulePrefsModelColumn
Column indices for the module pane.
Definition pref_models.h:375
ModulePrefsModel::colName
@ colName
Definition pref_models.h:376
ModulePrefsModel::colLast
@ colLast
Definition pref_models.h:377
ModulePrefsModel::ModulePrefsRoles
ModulePrefsRoles
Custom data roles for module items.
Definition pref_models.h:383
ModulePrefsModel::ModuleHelp
@ ModuleHelp
Definition pref_models.h:385
ModulePrefsModel::ModuleName
@ ModuleName
Definition pref_models.h:384
ModulePrefsModel::lessThan
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Define the sort order for module rows.
Definition pref_models.cpp:845
PrefsItem
A single node in the PrefsModel tree.
Definition pref_models.h:136
PrefsItem::getModuleHelp
QString getModuleHelp() const
Return the help text for the associated module.
Definition pref_models.cpp:125
PrefsItem::setChanged
void setChanged(bool changed=true)
Mark this preference as having been changed during this session.
Definition pref_models.cpp:139
PrefsItem::getName
QString getName() const
Return the display name of this item.
Definition pref_models.h:167
PrefsItem::isPrefDefault
bool isPrefDefault() const
Return whether the preference currently holds its default value.
Definition pref_models.cpp:90
PrefsItem::getPrefTypeName
QString getPrefTypeName() const
Return a human-readable string for the preference type.
Definition pref_models.cpp:101
PrefsItem::PrefsItem
PrefsItem(module_t *module, pref_t *pref, PrefsItem *parent)
Construct a PrefsItem for an individual preference.
Definition pref_models.cpp:45
PrefsItem::getModuleName
QString getModuleName() const
Return the internal (short) name of the associated module.
Definition pref_models.cpp:109
PrefsItem::getPrefType
int getPrefType() const
Return the numeric type of the underlying preference.
Definition pref_models.cpp:82
PrefsItem::getModuleTitle
QString getModuleTitle() const
Return the display title of the associated module.
Definition pref_models.cpp:117
PrefsItem::getPref
pref_t * getPref() const
Return the pref_t this item represents.
Definition pref_models.h:173
PrefsItem::getModule
module_t * getModule() const
Return the preference module associated with this item.
Definition pref_models.h:197
PrefsItem::~PrefsItem
virtual ~PrefsItem()
Destroy this PrefsItem and all of its children.
Definition pref_models.cpp:78
PrefsModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of child rows under parent.
Definition pref_models.cpp:156
PrefsModel::typeToString
static QString typeToString(PrefsModelType type)
Return the display name for a built-in preference page type.
Definition pref_models.cpp:334
PrefsModel::~PrefsModel
virtual ~PrefsModel()
Destroy the model and its PrefsItem tree.
Definition pref_models.cpp:151
PrefsModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Return the model index for the item at (row, column) under parent.
Definition pref_models.cpp:198
PrefsModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns.
Definition pref_models.cpp:173
PrefsModel::PrefsModel
PrefsModel(QObject *parent=Q_NULLPTR)
Construct a PrefsModel and populate it from the preference registry.
Definition pref_models.cpp:144
PrefsModel::typeToHelp
static QString typeToHelp(PrefsModelType type)
Return the help text for a built-in preference page type.
Definition pref_models.cpp:356
PrefsModel::PrefsModelType
PrefsModelType
Top-level preference page type identifiers.
Definition pref_models.h:44
PrefsModel::Appearance
@ Appearance
Definition pref_models.h:46
PrefsModel::Capture
@ Capture
Definition pref_models.h:51
PrefsModel::Expert
@ Expert
Definition pref_models.h:52
PrefsModel::Advanced
@ Advanced
Definition pref_models.h:45
PrefsModel::FontAndColors
@ FontAndColors
Definition pref_models.h:49
PrefsModel::Layout
@ Layout
Definition pref_models.h:47
PrefsModel::FilterButtons
@ FilterButtons
Definition pref_models.h:53
PrefsModel::WelcomePage
@ WelcomePage
Definition pref_models.h:50
PrefsModel::RSAKeys
@ RSAKeys
Definition pref_models.h:54
PrefsModel::Columns
@ Columns
Definition pref_models.h:48
PrefsModel::Aggregation
@ Aggregation
Definition pref_models.h:55
PrefsModel::data
QVariant data(const QModelIndex &index, int role) const override
Return data for index under role.
Definition pref_models.cpp:220
PrefsModel::parent
QModelIndex parent(const QModelIndex &index) const override
Return the parent model index of index.
Definition pref_models.cpp:179
PrefsModel::PrefsModelColumn
PrefsModelColumn
Column indices for the raw PrefsModel tree.
Definition pref_models.h:61
PrefsModel::colStatus
@ colStatus
Definition pref_models.h:63
PrefsModel::colLast
@ colLast
Definition pref_models.h:66
PrefsModel::colValue
@ colValue
Definition pref_models.h:65
PrefsModel::colName
@ colName
Definition pref_models.h:62
PrefsModel::colType
@ colType
Definition pref_models.h:64
prefFromPrefPtr
pref_t * prefFromPrefPtr(void *pref_ptr)
Retrieves the preference structure associated with a given preference pointer.
Definition pref_models.cpp:27
prefs.h
tree_model_helpers.h