diff options
Diffstat (limited to 'ui/qt/extcap_argument.cpp')
-rw-r--r-- | ui/qt/extcap_argument.cpp | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp index 0c06107f3e..3200a7e1d6 100644 --- a/ui/qt/extcap_argument.cpp +++ b/ui/qt/extcap_argument.cpp @@ -40,9 +40,12 @@ #include <QStandardItem> #include <QStandardItemModel> #include <QItemSelectionModel> +#include <QRegExp> #include <glib.h> #include <log.h> + +#include <extcap.h> #include <epan/prefs.h> #include <color_utils.h> @@ -57,6 +60,7 @@ QWidget * ExtArgSelector::createEditor(QWidget * parent) { int counter = 0; int selected = -1; + QString stored = _argument->storeval ? QString(_argument->storeval) : QString(); boxSelection = new QComboBox(parent); @@ -67,7 +71,10 @@ QWidget * ExtArgSelector::createEditor(QWidget * parent) while ( iter != values.constEnd() ) { boxSelection->addItem((*iter).value(), (*iter).call()); - if ( (*iter).isDefault() ) + + if ( ! _argument->storeval && (*iter).isDefault() ) + selected = counter; + else if ( _argument->storeval && stored.compare((*iter).call()) == 0 ) selected = counter; counter++; @@ -135,7 +142,7 @@ QWidget * ExtArgRadio::createEditor(QWidget * parent) ExtcapValueList::const_iterator iter = values.constBegin(); while ( iter != values.constEnd() ) - { + { QRadioButton * radio = new QRadioButton((*iter).value()); QString callString = (*iter).call(); callStrings->append(callString); @@ -219,6 +226,15 @@ QWidget * ExtArgBool::createEditor(QWidget * parent) if ( _argument->tooltip != NULL ) boolBox->setToolTip(QString().fromUtf8(_argument->tooltip)); + if ( _argument->storeval ) + { + QRegExp regexp(EXTCAP_BOOLEAN_REGEX); + + bool savedstate = ( regexp.indexIn(QString(_argument->storeval[0]), 0) != -1 ); + if ( savedstate != state ) + state = savedstate; + } + boolBox->setCheckState(state ? Qt::Checked : Qt::Unchecked ); connect (boolBox, SIGNAL(stateChanged(int)), SLOT(onIntChanged(int))); @@ -244,6 +260,13 @@ QString ExtArgBool::value() return QString(boolBox->checkState() == Qt::Checked ? "true" : "false"); } +QString ExtArgBool::prefValue() +{ + if ( boolBox == NULL ) + return QString("false"); + return QString(boolBox->checkState() == Qt::Checked ? "true" : "false"); +} + bool ExtArgBool::isValid() { /* A bool is allways valid, but the base function checks on string length, @@ -279,8 +302,17 @@ ExtArgText::ExtArgText(extcap_arg * argument) : QWidget * ExtArgText::createEditor(QWidget * parent) { + QString storeValue; QString text = defaultValue(); + if ( _argument->storeval ) + { + QString storeValue = _argument->storeval; + + if ( storeValue.length() > 0 && storeValue.compare(text) != 0 ) + text = storeValue.trimmed(); + } + textBox = new QLineEdit(text, parent); if ( _argument->tooltip != NULL ) @@ -334,7 +366,17 @@ ExtArgNumber::ExtArgNumber(extcap_arg * argument) : QWidget * ExtArgNumber::createEditor(QWidget * parent) { + QString storeValue; QString text = defaultValue(); + + if ( _argument->storeval ) + { + QString storeValue = _argument->storeval; + + if ( storeValue.length() > 0 && storeValue.compare(text) != 0 ) + text = storeValue; + } + textBox = (QLineEdit *)ExtArgText::createEditor(parent); textBox->disconnect(SIGNAL(textChanged(QString))); @@ -525,6 +567,10 @@ QString ExtcapArgument::value() return QString(); } +QString ExtcapArgument::prefValue() +{ + return value(); +} bool ExtcapArgument::isValid() { @@ -544,10 +590,17 @@ QString ExtcapArgument::defaultValue() if ( str != 0 ) return QString(str); } - return QString(); } +QString ExtcapArgument::prefKey() +{ + if ( ! _argument->save ) + return QString(); + + return QString(_argument->call).replace("-", ""); +} + bool ExtcapArgument::isRequired() { if ( _argument != NULL ) |