summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-11-09 13:56:12 +0100
committerAnders Broman <a.broman58@gmail.com>2016-12-09 04:49:33 +0000
commitb7e7796e20d5b194a72658a0e3f88522e7f66ebc (patch)
tree54291ca366573e7719a8bfd453410b209c7db708 /ui/qt
parentfb0c288f99518eac830cf29e92c3543a8045878e (diff)
downloadwireshark-b7e7796e20d5b194a72658a0e3f88522e7f66ebc.tar.gz
extcap: add new option type (timestamp).
Bug: 12787 Change-Id: I941833c55fb607c8af2ef832082af58d7b94e965 Reviewed-on: https://code.wireshark.org/review/18721 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/extcap_argument.cpp63
-rw-r--r--ui/qt/extcap_argument.h21
-rw-r--r--ui/qt/extcap_options_dialog.cpp9
3 files changed, 93 insertions, 0 deletions
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index 400bc3edae..72734b7bc6 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -25,6 +25,7 @@
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
+#include <QDateTimeEdit>
#include <QIntValidator>
#include <QDoubleValidator>
#include <QCheckBox>
@@ -54,6 +55,66 @@
#include <extcap_argument_file.h>
#include <extcap_argument_multiselect.h>
+ExtArgTimestamp::ExtArgTimestamp(extcap_arg * argument) :
+ ExtcapArgument(argument) {}
+
+QWidget * ExtArgTimestamp::createEditor(QWidget * parent)
+{
+ QDateTimeEdit * tsBox;
+ QString storeValue;
+ QString text = defaultValue();
+
+ if ( _argument->pref_valptr && *_argument->pref_valptr)
+ {
+ QString storeValue(*_argument->pref_valptr);
+
+ if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
+ text = storeValue.trimmed();
+ }
+
+ ts = QDateTime::fromTime_t(text.toInt());
+ tsBox = new QDateTimeEdit(ts, parent);
+ tsBox->setCalendarPopup(true);
+
+ if ( _argument->tooltip != NULL )
+ tsBox->setToolTip(QString().fromUtf8(_argument->tooltip));
+
+ connect(tsBox, SIGNAL(dateTimeChanged(QDateTime)), SLOT(onDateTimeChanged(QDateTime)));
+
+ return tsBox;
+}
+
+void ExtArgTimestamp::onDateTimeChanged(QDateTime t)
+{
+ ts = t;
+ emit valueChanged();
+}
+
+QString ExtArgTimestamp::defaultValue()
+{
+ return QString::number(QDateTime::currentDateTime().toTime_t());
+}
+
+bool ExtArgTimestamp::isValid()
+{
+ bool valid = true;
+
+ if ( value().length() == 0 && isRequired() )
+ valid = false;
+
+ return valid;
+}
+
+QString ExtArgTimestamp::value()
+{
+ return QString::number(ts.toTime_t());
+}
+
+QString ExtArgTimestamp::prefValue()
+{
+ return value();
+}
+
ExtArgSelector::ExtArgSelector(extcap_arg * argument) :
ExtcapArgument(argument), boxSelection(0) {}
@@ -687,6 +748,8 @@ ExtcapArgument * ExtcapArgument::create(extcap_arg * argument)
result = new ExtcapArgumentFileSelection(argument);
else if ( argument->arg_type == EXTCAP_ARG_MULTICHECK )
result = new ExtArgMultiSelect(argument);
+ else if ( argument->arg_type == EXTCAP_ARG_TIMESTAMP )
+ result = new ExtArgTimestamp(argument);
else
{
/* For everything else, we just print the label */
diff --git a/ui/qt/extcap_argument.h b/ui/qt/extcap_argument.h
index 5ff390c7d0..851fcfb009 100644
--- a/ui/qt/extcap_argument.h
+++ b/ui/qt/extcap_argument.h
@@ -31,6 +31,7 @@
#include <QComboBox>
#include <QButtonGroup>
#include <QCheckBox>
+#include <QDateTime>
#include <extcap_parser.h>
@@ -207,6 +208,26 @@ private:
bool defaultBool();
};
+class ExtArgTimestamp : public ExtcapArgument
+{
+ Q_OBJECT
+
+public:
+ ExtArgTimestamp(extcap_arg * argument);
+ virtual QWidget * createEditor(QWidget * parent);
+
+ virtual bool isValid();
+ virtual QString defaultValue();
+ virtual QString value();
+ virtual QString prefValue();
+
+private Q_SLOTS:
+ void onDateTimeChanged(QDateTime);
+
+private:
+ QDateTime ts;
+};
+
#endif /* UI_QT_EXTCAP_ARGUMENT_H_ */
/*
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp
index ae798e29d9..2aea0dc490 100644
--- a/ui/qt/extcap_options_dialog.cpp
+++ b/ui/qt/extcap_options_dialog.cpp
@@ -184,6 +184,11 @@ void ExtcapOptionsDialog::anyValueChanged()
if ( ! ((ExtArgText *)*iter)->isValid() )
allowStart = false;
}
+ else if ( dynamic_cast<ExtArgTimestamp *>((*iter)) != NULL)
+ {
+ if ( ! ((ExtArgTimestamp *)*iter)->isValid() )
+ allowStart = false;
+ }
else
if ( ! (*iter)->isValid() )
allowStart = false;
@@ -465,6 +470,10 @@ void ExtcapOptionsDialog::storeValues()
{
value = ((ExtArgText *)*iter)->prefValue();
}
+ else if ( dynamic_cast<ExtArgTimestamp *>((*iter)) != NULL)
+ {
+ value = ((ExtArgTimestamp *)*iter)->prefValue();
+ }
else
value = (*iter)->prefValue();