3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef UI_QT_EXTCAP_ARGUMENT_H_
11 #define UI_QT_EXTCAP_ARGUMENT_H_
20 #include <QButtonGroup>
24 #include <extcap_parser.h>
26 #define EXTCAP_GUI_BLANK_LABEL "QLabel { color : ; }"
27 #define EXTCAP_GUI_ERROR_LABEL "QLabel { color : red; }"
31 typedef QList
<ExtcapValue
> ExtcapValueList
;
36 ExtcapValue(QString value
, QString call
, bool enabled
, bool isDefault
) :
37 _value(value
), _call(call
), _enabled(enabled
),
38 _isDefault(isDefault
), _depth(0) {}
39 virtual ~ExtcapValue();
41 void setChildren(ExtcapValueList children
);
42 ExtcapValueList
children()
44 if (_children
.length() == 0)
45 return ExtcapValueList();
49 QString
value() const { return _value
; }
50 const QString
call() const { return _call
; }
51 bool enabled() const { return _enabled
; }
52 bool isDefault() const { return _isDefault
; }
54 int depth() { return _depth
; }
65 ExtcapValueList _children
;
70 class ExtcapArgument
: public QObject
75 ExtcapArgument(QObject
*parent
= Q_NULLPTR
);
76 ExtcapArgument(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
77 ExtcapArgument(const ExtcapArgument
&obj
);
78 virtual ~ExtcapArgument();
80 virtual QWidget
* createLabel(QWidget
* parent
= 0);
81 virtual QWidget
* createEditor(QWidget
* parent
= 0);
83 virtual extcap_arg
* argument() { return _argument
; }
84 virtual QString
call();
85 virtual QString
value();
86 virtual QString
defaultValue();
89 virtual bool isValid();
93 QString
prefKey(const QString
& device_name
);
94 virtual QString
prefValue();
98 virtual QString
group() const;
99 virtual int argNr() const;
101 static ExtcapArgument
* create(extcap_arg
* argument
= Q_NULLPTR
, QObject
* parent
= Q_NULLPTR
);
102 virtual bool isSetDefaultValueSupported();
105 virtual void setDefaultValue();
114 ExtcapValueList
loadValues(QString parent
);
117 ExtcapValueList values
;
119 extcap_arg
* _argument
;
123 const QString label_style
;
127 void onStringChanged(QString
);
128 void onIntChanged(int);
129 void onBoolChanged(bool);
135 class ExtArgText
: public ExtcapArgument
140 ExtArgText(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
142 virtual QWidget
* createEditor(QWidget
* parent
);
143 virtual QString
value();
144 virtual bool isValid();
145 virtual bool isSetDefaultValueSupported();
148 virtual void setDefaultValue();
157 class ExtArgNumber
: public ExtArgText
162 ExtArgNumber(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
164 virtual QWidget
* createEditor(QWidget
* parent
);
165 virtual QString
defaultValue();
170 class ExtArgSelector
: public ExtcapArgument
175 ExtArgSelector(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
177 virtual QWidget
* createEditor(QWidget
* parent
);
178 virtual QString
value();
179 virtual bool isValid();
180 virtual bool isSetDefaultValueSupported();
183 virtual void setDefaultValue();
186 QComboBox
* boxSelection
;
189 void onReloadTriggered();
194 class ExtArgEditSelector
: public ExtArgSelector
199 ExtArgEditSelector(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
200 virtual QWidget
* createEditor(QWidget
* parent
);
201 virtual QString
value();
204 virtual void setDefaultValue();
208 class ExtArgRadio
: public ExtcapArgument
213 ExtArgRadio(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
214 virtual ~ExtArgRadio();
216 virtual QWidget
* createEditor(QWidget
* parent
);
217 virtual QString
value();
218 virtual bool isValid();
219 virtual bool isSetDefaultValueSupported();
222 virtual void setDefaultValue();
226 QButtonGroup
* selectorGroup
;
227 QList
<QString
> * callStrings
;
232 class ExtArgBool
: public ExtcapArgument
237 ExtArgBool(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
239 virtual QWidget
* createLabel(QWidget
* parent
);
240 virtual QWidget
* createEditor(QWidget
* parent
);
242 virtual QString
call();
243 virtual QString
value();
244 virtual bool isValid();
245 virtual QString
defaultValue();
246 virtual QString
prefValue();
247 virtual bool isSetDefaultValueSupported();
250 virtual void setDefaultValue();
261 class ExtArgTimestamp
: public ExtcapArgument
266 ExtArgTimestamp(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
267 virtual QWidget
* createEditor(QWidget
* parent
);
269 virtual bool isValid();
270 virtual QString
defaultValue();
271 virtual QString
value();
272 virtual QString
prefValue();
273 virtual bool isSetDefaultValueSupported();
276 virtual void setDefaultValue();
279 void onDateTimeChanged(QDateTime
);
283 QDateTimeEdit
*tsBox
;
286 #endif /* UI_QT_EXTCAP_ARGUMENT_H_ */