Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
extcap_argument.h
Go to the documentation of this file.
1
10#ifndef UI_QT_EXTCAP_ARGUMENT_H_
11#define UI_QT_EXTCAP_ARGUMENT_H_
12
13#include <QObject>
14#include <QWidget>
15#include <QLabel>
16#include <QVariant>
17#include <QList>
18#include <QLineEdit>
19#include <QComboBox>
20#include <QButtonGroup>
21#include <QCheckBox>
22#include <QDateTime>
23
24#include <extcap_parser.h>
25
26#define EXTCAP_GUI_BLANK_LABEL "QLabel { color : ; }"
27#define EXTCAP_GUI_ERROR_LABEL "QLabel { color : red; }"
28
29class ExtcapValue;
30
31typedef QList<ExtcapValue> ExtcapValueList;
32
37{
38public:
46 ExtcapValue(QString value, QString call, bool enabled, bool isDefault) :
47 _value(value), _call(call), _enabled(enabled),
48 _isDefault(isDefault), _depth(0) {}
49
53 virtual ~ExtcapValue();
54
59 void setChildren(ExtcapValueList children);
60
65 ExtcapValueList children()
66 {
67 if (_children.length() == 0)
68 return ExtcapValueList();
69 return _children;
70 }
71
76 QString value() const { return _value; }
77
82 const QString call() const { return _call; }
83
88 bool enabled() const { return _enabled; }
89
94 bool isDefault() const { return _isDefault; }
95
100 int depth() { return _depth; }
101
102private:
104 QString _value;
105
107 QString _call;
108
110 bool _enabled;
111
113 bool _isDefault;
114
116 int _depth;
117
119 ExtcapValueList _children;
120};
121
122
126class ExtcapArgument: public QObject
127{
128 Q_OBJECT
129
130public:
135 ExtcapArgument(QObject *parent = Q_NULLPTR);
136
142 ExtcapArgument(extcap_arg * argument, QObject *parent = Q_NULLPTR);
143
148 ExtcapArgument(const ExtcapArgument &obj);
149
153 virtual ~ExtcapArgument();
154
160 virtual QWidget * createLabel(QWidget * parent = 0);
161
167 virtual QWidget * createEditor(QWidget * parent = 0);
168
173 virtual extcap_arg * argument() { return _argument; }
174
179 virtual QString call();
180
185 virtual QString value();
186
191 virtual QString defaultValue();
192
197 bool isDefault();
198
203 virtual bool isValid();
204
209 bool isRequired();
210
215 bool isSufficient();
216
221 bool reload();
222
230 QString prefKey(const QString & device_name,
231 const QString & option_name, const QString & option_value);
232
237 virtual QString prefValue();
238
242 void resetValue();
243
248 virtual QString group() const;
249
254 virtual int argNr() const;
255
262 static ExtcapArgument * create(extcap_arg * argument = Q_NULLPTR, QObject * parent = Q_NULLPTR);
263
268 virtual bool isSetDefaultValueSupported();
269
270public Q_SLOTS:
274 virtual void setDefaultValue();
275
280 void onBoolChanged(bool val);
281
286 void onIntChanged(int val);
287
292 void onStringChanged(QString val);
293
294Q_SIGNALS:
299
300protected:
301
306 bool fileExists();
307
313 ExtcapValueList loadValues(QString parent);
314
319 bool reloadValues();
320
322 ExtcapValueList values;
323
326
328 QLabel * _label;
329
332};
333
334
339{
340 Q_OBJECT
341
342public:
348 ExtArgText(extcap_arg * argument, QObject *parent = Q_NULLPTR);
349
355 virtual QWidget * createEditor(QWidget * parent);
356
361 virtual QString value();
362
367 virtual bool isValid();
368
373 virtual bool isSetDefaultValueSupported();
374
375public Q_SLOTS:
379 virtual void setDefaultValue();
380
381protected:
382
384 QLineEdit * textBox;
385};
386
387
392{
393 Q_OBJECT
394
395public:
401 ExtArgNumber(extcap_arg * argument, QObject *parent = Q_NULLPTR);
402
408 virtual QWidget * createEditor(QWidget * parent);
409
414 virtual QString defaultValue();
415};
416
417
422{
423 Q_OBJECT
424
425public:
431 ExtArgSelector(extcap_arg * argument, QObject *parent = Q_NULLPTR);
432
438 virtual QWidget * createEditor(QWidget * parent);
439
444 virtual QString value();
445
450 virtual bool isValid();
451
456 virtual bool isSetDefaultValueSupported();
457
458public Q_SLOTS:
462 virtual void setDefaultValue();
463
464protected:
466 QComboBox * boxSelection;
467
468private Q_SLOTS:
472 void onReloadTriggered();
473
474};
475
480{
481 Q_OBJECT
482
483public:
489 ExtArgEditSelector(extcap_arg * argument, QObject *parent = Q_NULLPTR);
490
496 virtual QWidget * createEditor(QWidget * parent);
497
502 virtual QString value();
503
504public Q_SLOTS:
508 virtual void setDefaultValue();
509};
510
515{
516 Q_OBJECT
517
518public:
524 ExtArgRadio(extcap_arg * argument, QObject *parent = Q_NULLPTR);
525
529 virtual ~ExtArgRadio();
530
536 virtual QWidget * createEditor(QWidget * parent);
537
542 virtual QString value();
543
548 virtual bool isValid();
549
554 virtual bool isSetDefaultValueSupported();
555
556public Q_SLOTS:
560 virtual void setDefaultValue();
561
562private:
563
565 QButtonGroup * selectorGroup;
566
568 QList<QString> * callStrings;
569};
570
571
576{
577 Q_OBJECT
578
579public:
585 ExtArgBool(extcap_arg * argument, QObject *parent = Q_NULLPTR);
586
592 virtual QWidget * createLabel(QWidget * parent);
593
599 virtual QWidget * createEditor(QWidget * parent);
600
605 virtual QString call();
606
611 virtual QString value();
612
617 virtual bool isValid();
618
623 virtual QString defaultValue();
624
629 virtual QString prefValue();
630
635 virtual bool isSetDefaultValueSupported();
636
637public Q_SLOTS:
641 virtual void setDefaultValue();
642
643private:
644
646 QCheckBox * boolBox;
647
652 bool defaultBool();
653};
654
655
660{
661 Q_OBJECT
662
663public:
669 ExtArgTimestamp(extcap_arg * argument, QObject *parent = Q_NULLPTR);
670
676 virtual QWidget * createEditor(QWidget * parent);
677
682 virtual bool isValid();
683
688 virtual QString defaultValue();
689
694 virtual QString value();
695
700 virtual QString prefValue();
701
706 virtual bool isSetDefaultValueSupported();
707
708public Q_SLOTS:
712 virtual void setDefaultValue();
713
714private Q_SLOTS:
719 void onDateTimeChanged(QDateTime datetime);
720
721private:
723 QDateTime ts;
724
726 QDateTimeEdit *tsBox;
727};
728#endif /* UI_QT_EXTCAP_ARGUMENT_H_ */
Extcap argument representing a boolean toggle (checkbox).
Definition extcap_argument.h:576
virtual QString defaultValue()
Retrieves the default boolean value as a string.
Definition extcap_argument.cpp:516
virtual QString prefValue()
Retrieves the preference value for the boolean argument.
Definition extcap_argument.cpp:489
virtual QString value()
Retrieves the boolean state as a string.
Definition extcap_argument.cpp:482
virtual bool isSetDefaultValueSupported()
Checks if setting a default boolean value is supported.
Definition extcap_argument.cpp:521
virtual QWidget * createEditor(QWidget *parent)
Creates the checkbox editor widget.
Definition extcap_argument.cpp:442
virtual bool isValid()
Checks if the boolean state is valid.
Definition extcap_argument.cpp:496
virtual void setDefaultValue()
Sets the checkbox to its default state.
Definition extcap_argument.cpp:526
virtual QWidget * createLabel(QWidget *parent)
Creates the label widget for the boolean argument.
Definition extcap_argument.cpp:437
virtual QString call()
Retrieves the call string based on the boolean state.
Definition extcap_argument.cpp:471
Extcap argument representing an editable selection dropdown.
Definition extcap_argument.h:480
virtual QString value()
Retrieves the current text or selection value.
Definition extcap_argument.cpp:280
virtual void setDefaultValue()
Sets the editable selector to its default value.
Definition extcap_argument.cpp:293
virtual QWidget * createEditor(QWidget *parent)
Creates the editable combobox editor widget.
Definition extcap_argument.cpp:270
Extcap argument representing a numeric input field.
Definition extcap_argument.h:392
virtual QString defaultValue()
Retrieves the default numeric value.
Definition extcap_argument.cpp:721
virtual QWidget * createEditor(QWidget *parent)
Creates the numeric editor widget.
Definition extcap_argument.cpp:641
Extcap argument representing a set of radio buttons.
Definition extcap_argument.h:515
virtual QWidget * createEditor(QWidget *parent)
Creates the radio button group editor widget.
Definition extcap_argument.cpp:322
virtual bool isValid()
Checks if a valid radio button is selected.
Definition extcap_argument.cpp:376
virtual void setDefaultValue()
Selects the default radio button.
Definition extcap_argument.cpp:405
virtual bool isSetDefaultValueSupported()
Checks if setting a default radio button is supported.
Definition extcap_argument.cpp:400
virtual QString value()
Retrieves the value of the currently selected radio button.
Definition extcap_argument.cpp:363
virtual ~ExtArgRadio()
Destroys the ExtArgRadio.
Definition extcap_argument.cpp:317
Extcap argument representing a selection dropdown.
Definition extcap_argument.h:422
virtual bool isSetDefaultValueSupported()
Checks if setting a default selection is supported.
Definition extcap_argument.cpp:232
QComboBox * boxSelection
Definition extcap_argument.h:466
virtual void setDefaultValue()
Sets the dropdown to its default selection.
Definition extcap_argument.cpp:237
virtual bool isValid()
Checks if the current selection is valid.
Definition extcap_argument.cpp:209
virtual QString value()
Retrieves the currently selected value.
Definition extcap_argument.cpp:222
virtual QWidget * createEditor(QWidget *parent)
Creates the combobox editor widget.
Definition extcap_argument.cpp:125
Extcap argument representing a text input field.
Definition extcap_argument.h:339
virtual QWidget * createEditor(QWidget *parent)
Creates the text editor widget.
Definition extcap_argument.cpp:538
virtual bool isSetDefaultValueSupported()
Checks if setting a default text value is supported.
Definition extcap_argument.cpp:626
QLineEdit * textBox
Definition extcap_argument.h:384
virtual bool isValid()
Checks if the current text value is valid.
Definition extcap_argument.cpp:573
virtual void setDefaultValue()
Sets the text field to its default value.
Definition extcap_argument.cpp:631
virtual QString value()
Retrieves the current text value.
Definition extcap_argument.cpp:565
Extcap argument representing a timestamp input.
Definition extcap_argument.h:660
virtual bool isSetDefaultValueSupported()
Checks if setting a default timestamp is supported.
Definition extcap_argument.cpp:107
virtual void setDefaultValue()
Sets the timestamp to its default value.
Definition extcap_argument.cpp:112
virtual QString defaultValue()
Retrieves the default timestamp value.
Definition extcap_argument.cpp:82
virtual QString prefValue()
Retrieves the preference value for the timestamp.
Definition extcap_argument.cpp:102
virtual QString value()
Retrieves the current timestamp value.
Definition extcap_argument.cpp:97
virtual QWidget * createEditor(QWidget *parent)
Creates the datetime editor widget.
Definition extcap_argument.cpp:52
virtual bool isValid()
Checks if the timestamp input is valid.
Definition extcap_argument.cpp:87
Base class representing a command line argument for an extcap utility.
Definition extcap_argument.h:127
bool fileExists()
Checks if a file path specified by the argument exists.
Definition extcap_argument.cpp:984
virtual void setDefaultValue()
Slot to set the argument to its default value.
Definition extcap_argument.cpp:1059
virtual ~ExtcapArgument()
Destroys the ExtcapArgument.
Definition extcap_argument.cpp:847
extcap_arg * _argument
Definition extcap_argument.h:325
virtual extcap_arg * argument()
Retrieves the underlying extcap_arg structure.
Definition extcap_argument.h:173
virtual bool isValid()
Checks if the current state of the argument is valid.
Definition extcap_argument.cpp:899
virtual int argNr() const
Retrieves the argument number.
Definition extcap_argument.cpp:928
void onIntChanged(int val)
Slot to handle integer value changes.
Definition extcap_argument.cpp:1043
void onStringChanged(QString val)
Slot to handle string value changes.
Definition extcap_argument.cpp:1038
virtual QWidget * createLabel(QWidget *parent=0)
Creates a label widget for this argument.
Definition extcap_argument.cpp:851
virtual QString call()
Retrieves the call string for this argument.
Definition extcap_argument.cpp:876
ExtcapValueList loadValues(QString parent)
Loads the available values for this argument.
Definition extcap_argument.cpp:791
QString prefKey(const QString &device_name, const QString &option_name, const QString &option_value)
Generates a preference key for this argument.
Definition extcap_argument.cpp:933
static ExtcapArgument * create(extcap_arg *argument=Q_NULLPTR, QObject *parent=Q_NULLPTR)
Factory method to create an appropriate ExtcapArgument subclass.
Definition extcap_argument.cpp:1000
bool isSufficient()
Checks if the argument provides sufficient information on its own.
Definition extcap_argument.cpp:968
bool isRequired()
Checks if the argument is required.
Definition extcap_argument.cpp:960
void resetValue()
Resets the argument to its initial value.
Definition extcap_argument.cpp:891
bool isDefault()
Checks if the argument currently holds its default value.
Definition extcap_argument.cpp:992
ExtcapValueList values
Definition extcap_argument.h:322
int _number
Definition extcap_argument.h:331
virtual QString group() const
Retrieves the group name this argument belongs to.
Definition extcap_argument.cpp:920
virtual QWidget * createEditor(QWidget *parent=0)
Creates an editor widget for this argument.
Definition extcap_argument.cpp:871
void onBoolChanged(bool val)
Slot to handle boolean value changes.
Definition extcap_argument.cpp:1049
virtual QString prefValue()
Retrieves the preference value for this argument.
Definition extcap_argument.cpp:886
virtual QString value()
Retrieves the current value of the argument.
Definition extcap_argument.cpp:881
QLabel * _label
Definition extcap_argument.h:328
void valueChanged()
Signal emitted when the argument's value changes.
bool reload()
Reloads the argument data.
Definition extcap_argument.cpp:976
virtual bool isSetDefaultValueSupported()
Checks if setting a default value is supported by this argument type.
Definition extcap_argument.cpp:1054
virtual QString defaultValue()
Retrieves the default value of the argument.
Definition extcap_argument.cpp:909
bool reloadValues()
Reloads the values list.
Definition extcap_argument.cpp:828
Represents a single value option for an extcap argument.
Definition extcap_argument.h:37
ExtcapValue(QString value, QString call, bool enabled, bool isDefault)
Constructs a new ExtcapValue.
Definition extcap_argument.h:46
void setChildren(ExtcapValueList children)
Sets the child values for this value.
Definition extcap_argument.cpp:747
const QString call() const
Retrieves the call string.
Definition extcap_argument.h:82
QString value() const
Retrieves the display value.
Definition extcap_argument.h:76
ExtcapValueList children()
Retrieves the child values.
Definition extcap_argument.h:65
virtual ~ExtcapValue()
Destroys the ExtcapValue.
Definition extcap_argument.cpp:745
bool enabled() const
Checks if the value is enabled.
Definition extcap_argument.h:88
bool isDefault() const
Checks if the value is the default.
Definition extcap_argument.h:94
int depth()
Retrieves the hierarchical depth of this value.
Definition extcap_argument.h:100
A fully parsed extcap argument sentence with all its associated options.
Definition extcap_parser.h:118