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();
106 void onBoolChanged(bool);
107 void onIntChanged(int);
108 void onStringChanged(QString
);
117 ExtcapValueList
loadValues(QString parent
);
120 ExtcapValueList values
;
122 extcap_arg
* _argument
;
126 const QString label_style
;
131 class ExtArgText
: public ExtcapArgument
136 ExtArgText(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
138 virtual QWidget
* createEditor(QWidget
* parent
);
139 virtual QString
value();
140 virtual bool isValid();
141 virtual bool isSetDefaultValueSupported();
144 virtual void setDefaultValue();
153 class ExtArgNumber
: public ExtArgText
158 ExtArgNumber(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
160 virtual QWidget
* createEditor(QWidget
* parent
);
161 virtual QString
defaultValue();
166 class ExtArgSelector
: public ExtcapArgument
171 ExtArgSelector(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
173 virtual QWidget
* createEditor(QWidget
* parent
);
174 virtual QString
value();
175 virtual bool isValid();
176 virtual bool isSetDefaultValueSupported();
179 virtual void setDefaultValue();
182 QComboBox
* boxSelection
;
185 void onReloadTriggered();
190 class ExtArgEditSelector
: public ExtArgSelector
195 ExtArgEditSelector(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
196 virtual QWidget
* createEditor(QWidget
* parent
);
197 virtual QString
value();
200 virtual void setDefaultValue();
204 class ExtArgRadio
: public ExtcapArgument
209 ExtArgRadio(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
210 virtual ~ExtArgRadio();
212 virtual QWidget
* createEditor(QWidget
* parent
);
213 virtual QString
value();
214 virtual bool isValid();
215 virtual bool isSetDefaultValueSupported();
218 virtual void setDefaultValue();
222 QButtonGroup
* selectorGroup
;
223 QList
<QString
> * callStrings
;
228 class ExtArgBool
: public ExtcapArgument
233 ExtArgBool(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
235 virtual QWidget
* createLabel(QWidget
* parent
);
236 virtual QWidget
* createEditor(QWidget
* parent
);
238 virtual QString
call();
239 virtual QString
value();
240 virtual bool isValid();
241 virtual QString
defaultValue();
242 virtual QString
prefValue();
243 virtual bool isSetDefaultValueSupported();
246 virtual void setDefaultValue();
257 class ExtArgTimestamp
: public ExtcapArgument
262 ExtArgTimestamp(extcap_arg
* argument
, QObject
*parent
= Q_NULLPTR
);
263 virtual QWidget
* createEditor(QWidget
* parent
);
265 virtual bool isValid();
266 virtual QString
defaultValue();
267 virtual QString
value();
268 virtual QString
prefValue();
269 virtual bool isSetDefaultValueSupported();
272 virtual void setDefaultValue();
275 void onDateTimeChanged(QDateTime
);
279 QDateTimeEdit
*tsBox
;
282 #endif /* UI_QT_EXTCAP_ARGUMENT_H_ */