Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
preference_manager.h
Go to the documentation of this file.
1
10#ifndef PREFERENCE_MANAGER_H
11#define PREFERENCE_MANAGER_H
12
13#include <config.h>
14
15#include <QObject>
16#include <QMetaObject>
17#include <QHash>
18#include <QActionGroup>
19
21#include <ui/qt/capture_file.h>
22
25
29class PreferenceManager : public QObject
30{
31public:
37
41 virtual ~PreferenceManager();
42
48 void registerType(int pref, PreferenceFactory * factory);
49
55 void reuseType(int pref, int reuseFor);
56
63
64protected:
69 explicit PreferenceManager(QObject * parent = Q_NULLPTR);
70
71private:
76 static QMap<int, PreferenceFactory*> & factories();
77};
78
82class PreferenceFactory : public QObject
83{
84public:
88 virtual ~PreferenceFactory();
89
95 virtual WiresharkPreference * create(QObject * parent = Q_NULLPTR) = 0;
96};
97
103#define REGISTER_PREFERENCE_TYPE(pref_id, preference_class) \
104 class preference_class##pref_id##Factory : public PreferenceFactory { \
105 public: \
106 preference_class##pref_id##Factory() \
107 { \
108 PreferenceManager::instance()->registerType(pref_id, this); \
109 } \
110 virtual WiresharkPreference *create(QObject * parent) { \
111 WiresharkPreference * newPrefHandler = new preference_class(parent); \
112 return newPrefHandler; \
113 } \
114 }; \
115 static preference_class##pref_id##Factory global_##preference_class##pref_id##Factory;
116
117#endif // PREFERENCE_MANAGER_H
Abstract base class for creating Wireshark preference objects.
Definition preference_manager.h:83
virtual WiresharkPreference * create(QObject *parent=Q_NULLPTR)=0
Creates a new WiresharkPreference object.
virtual ~PreferenceFactory()
Destroys the PreferenceFactory.
Definition preference_manager.cpp:17
Manages the registration and creation of Wireshark preferences.
Definition preference_manager.h:30
void reuseType(int pref, int reuseFor)
Maps an existing preference factory to another preference type.
virtual ~PreferenceManager()
Destroys the PreferenceManager.
Definition preference_manager.cpp:29
void registerType(int pref, PreferenceFactory *factory)
Registers a preference factory for a specific preference type.
Definition preference_manager.cpp:44
WiresharkPreference * getPreference(PrefsItem *item)
Retrieves a WiresharkPreference instance for the given PrefsItem.
Definition preference_manager.cpp:54
static PreferenceManager * instance()
Retrieves the singleton instance of the PreferenceManager.
Definition preference_manager.cpp:35
A single node in the PrefsModel tree.
Definition pref_models.h:136
Base class for preference editor delegates used in the preferences tree view.
Definition wireshark_preference.h:27