summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extcap/sshdump.c2
-rw-r--r--extcap_parser.c8
-rw-r--r--extcap_parser.h5
-rw-r--r--ui/qt/CMakeLists.txt2
-rw-r--r--ui/qt/Makefile.common2
-rw-r--r--ui/qt/extcap_argument.cpp208
-rw-r--r--ui/qt/extcap_argument.h14
-rw-r--r--ui/qt/extcap_argument_file.cpp13
-rw-r--r--ui/qt/extcap_argument_file.h5
-rw-r--r--ui/qt/extcap_argument_multiselect.cpp202
-rw-r--r--ui/qt/extcap_argument_multiselect.h74
-rw-r--r--ui/qt/extcap_options_dialog.cpp50
-rw-r--r--ui/qt/extcap_options_dialog.h8
-rw-r--r--ui/qt/extcap_options_dialog.ui8
14 files changed, 436 insertions, 165 deletions
diff --git a/extcap/sshdump.c b/extcap/sshdump.c
index 2a954358b6..a00fba370f 100644
--- a/extcap/sshdump.c
+++ b/extcap/sshdump.c
@@ -541,7 +541,7 @@ static int list_config(char *interface, unsigned int remote_port)
g_print("arg {number=%u}{call=--remote-host}{display=Remote SSH server address}"
"{type=string}{tooltip=The remote SSH host. It can be both "
- "an IP address or a hostname}\n", inc++);
+ "an IP address or a hostname}{required=true}\n", inc++);
g_print("arg {number=%u}{call=--remote-port}{display=Remote SSH server port}"
"{type=unsigned}{default=22}{tooltip=The remote SSH host port (1-65535)}"
"{range=1,65535}\n", inc++);
diff --git a/extcap_parser.c b/extcap_parser.c
index 4228bc5bd3..154e4aa068 100644
--- a/extcap_parser.c
+++ b/extcap_parser.c
@@ -345,6 +345,8 @@ extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
tv->param_type = EXTCAP_PARAM_ENABLED;
} else if (g_ascii_strcasecmp(tv->arg, "parent") == 0) {
tv->param_type = EXTCAP_PARAM_PARENT;
+ } else if (g_ascii_strcasecmp(tv->arg, "required") == 0) {
+ tv->param_type = EXTCAP_PARAM_REQUIRED;
} else {
tv->param_type = EXTCAP_PARAM_UNKNOWN;
}
@@ -475,6 +477,7 @@ extcap_arg *extcap_new_arg(void) {
r->range_end = NULL;
r->default_complex = NULL;
r->fileexists = FALSE;
+ r->is_required = FALSE;
r->values = NULL;
/*r->next_arg = NULL; */
@@ -591,6 +594,11 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
target_arg->fileexists = (v->value[0] == 't' || v->value[0] == 'T');
}
+ if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_REQUIRED))
+ != NULL) {
+ target_arg->is_required = (v->value[0] == 't' || v->value[0] == 'T');
+ }
+
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_TYPE))
== NULL) {
/* printf("no type in ARG sentence\n"); */
diff --git a/extcap_parser.h b/extcap_parser.h
index 9e1e51b388..de7be00498 100644
--- a/extcap_parser.h
+++ b/extcap_parser.h
@@ -67,7 +67,8 @@ typedef enum {
EXTCAP_PARAM_NAME,
EXTCAP_PARAM_ENABLED,
EXTCAP_PARAM_FILE_MUSTEXIST,
- EXTCAP_PARAM_PARENT
+ EXTCAP_PARAM_PARENT,
+ EXTCAP_PARAM_REQUIRED
} extcap_param_type;
/* Values for a given sentence; values are all stored as a call
@@ -106,6 +107,8 @@ typedef struct _extcap_arg {
gchar *tooltip;
gboolean fileexists;
+ gboolean is_required;
+
extcap_arg_type arg_type;
extcap_complex *range_start;
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 9e4fb99532..2c03bc1f0b 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -161,6 +161,7 @@ if(ENABLE_EXTCAP)
${WIRESHARK_QT_HEADERS}
extcap_argument.h
extcap_argument_file.h
+ extcap_argument_multiselect.h
extcap_options_dialog.h
)
endif()
@@ -307,6 +308,7 @@ if(ENABLE_EXTCAP)
${WIRESHARK_QT_SRC}
extcap_argument.cpp
extcap_argument_file.cpp
+ extcap_argument_multiselect.cpp
extcap_options_dialog.cpp
)
endif()
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index 0c1d09cde1..c84ff3e534 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -181,6 +181,7 @@ MOC_HDRS = \
export_pdu_dialog.h \
extcap_argument.h \
extcap_argument_file.h \
+ extcap_argument_multiselect.h \
extcap_options_dialog.h \
file_set_dialog.h \
filter_action.h \
@@ -441,6 +442,7 @@ WIRESHARK_QT_SRC = \
export_pdu_dialog.cpp \
extcap_argument.cpp \
extcap_argument_file.cpp \
+ extcap_argument_multiselect.cpp \
extcap_options_dialog.cpp \
file_set_dialog.cpp \
filter_action.cpp \
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index ab1916db8d..b2ff0d04a7 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -44,149 +44,7 @@
#include <extcap_parser.h>
#include <extcap_argument_file.h>
-
-class ExtArgMultiSelect : public ExtcapArgument
-{
-public:
- ExtArgMultiSelect(extcap_arg * argument) :
- ExtcapArgument(argument), treeView(0), viewModel(0) {};
-
- virtual QList<QStandardItem *> valueWalker(ExtcapValueList list, QStringList &defaults)
- {
- ExtcapValueList::iterator iter = list.begin();
- QList<QStandardItem *> items;
-
- while ( iter != list.end() )
- {
- QStandardItem * item = new QStandardItem((*iter).value());
- if ( (*iter).enabled() == false )
- {
- item->setSelectable(false);
- }
- else
- item->setSelectable(true);
-
- item->setData((*iter).call(), Qt::UserRole);
- if ((*iter).isDefault())
- defaults << (*iter).call();
-
- item->setEditable(false);
- QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults);
- if ( childs.length() > 0 )
- item->appendRows(childs);
-
- items << item;
- ++iter;
- }
-
- return items;
- }
-
- void selectItemsWalker(QStandardItem * item, QStringList defaults)
- {
- QModelIndexList results;
- QModelIndex index;
-
- if ( item->hasChildren() )
- {
- for (int row = 0; row < item->rowCount(); row++)
- {
- QStandardItem * child = item->child(row);
- if ( child != 0 )
- {
- selectItemsWalker(child, defaults);
- }
- }
- }
-
- QString data = item->data(Qt::UserRole).toString();
-
- if ( defaults.contains(data) )
- {
- treeView->selectionModel()->select(item->index(), QItemSelectionModel::Select);
- index = item->index();
- while ( index.isValid() )
- {
- treeView->setExpanded(index, true);
- index = index.parent();
- }
- }
- }
-
- virtual QWidget * createEditor(QWidget * parent)
- {
- QStringList defaults;
-
- QList<QStandardItem *> items = valueWalker(values, defaults);
- if (items.length() == 0)
- return new QWidget();
-
- if ( _default != 0 )
- defaults = _default->toString().split(",", QString::SkipEmptyParts);
-
- viewModel = new QStandardItemModel();
- QList<QStandardItem *>::const_iterator iter = items.constBegin();
- while ( iter != items.constEnd() )
- {
- ((QStandardItemModel *)viewModel)->appendRow((*iter));
- ++iter;
- }
-
- treeView = new QTreeView(parent);
- treeView->setModel(viewModel);
-
- /* Shows at minimum 6 entries at most desktops */
- treeView->setMinimumHeight(100);
- treeView->setHeaderHidden(true);
- treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
- for (int row = 0; row < viewModel->rowCount(); row++ )
- selectItemsWalker(((QStandardItemModel*)viewModel)->item(row), defaults);
-
- return treeView;
- }
-
- virtual QString value()
- {
- if ( viewModel == 0 )
- return QString();
-
- QStringList result;
- QModelIndexList selected = treeView->selectionModel()->selectedIndexes();
-
- if ( selected.size() <= 0 )
- return QString();
-
- QModelIndexList::const_iterator iter = selected.constBegin();
- while ( iter != selected.constEnd() )
- {
- QModelIndex index = (QModelIndex)(*iter);
-
- result << viewModel->data(index, Qt::UserRole).toString();
-
- ++iter;
- }
-
- return result.join(QString(","));
- }
-
- virtual QString defaultValue()
- {
- if ( _argument != 0 && _argument->default_complex != 0)
- {
- gchar * str = extcap_get_complex_as_string(_argument->default_complex);
- if ( str != 0 )
- return QString(str);
- }
-
- return QString();
- }
-
-private:
- QTreeView * treeView;
- QAbstractItemModel * viewModel;
-};
+#include <extcap_argument_multiselect.h>
class ExtArgSelector : public ExtcapArgument
{
@@ -219,6 +77,8 @@ public:
boxSelection->setCurrentIndex(selected);
}
+ connect ( boxSelection, SIGNAL(currentIndexChanged(int)), SLOT(onIntChanged(int)) );
+
return boxSelection;
}
@@ -237,6 +97,7 @@ public:
}
private:
+
QComboBox * boxSelection;
};
@@ -287,6 +148,8 @@ public:
anyChecked = true;
}
}
+
+ connect(radio, SIGNAL(clicked(bool)), SLOT(onBoolChanged(bool)));
selectorGroup->addButton(radio, count);
vrLayout->addWidget(radio);
@@ -319,6 +182,7 @@ public:
}
private:
+
QButtonGroup * selectorGroup;
QList<QString> * callStrings;
};
@@ -350,6 +214,8 @@ public:
boolBox->setCheckState(Qt::Checked);
}
+ connect (boolBox, SIGNAL(stateChanged(int)), SLOT(onIntChanged(int)));
+
return boolBox;
}
@@ -381,11 +247,13 @@ public:
}
private:
+
QCheckBox * boolBox;
};
class ExtArgText : public ExtcapArgument
{
+
public:
ExtArgText(extcap_arg * argument) :
ExtcapArgument(argument), textBox(0)
@@ -402,6 +270,8 @@ public:
if ( _argument->tooltip != NULL )
textBox->setToolTip(QString().fromUtf8(_argument->tooltip));
+ connect(textBox , SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));
+
return textBox;
}
@@ -413,6 +283,14 @@ public:
return textBox->text();
}
+ virtual bool isValid()
+ {
+ if ( isRequired() && value().length() == 0 )
+ return false;
+
+ return true;
+ }
+
virtual QString defaultValue()
{
if ( _argument != 0 && _argument->default_complex != 0)
@@ -426,6 +304,7 @@ public:
}
protected:
+
QLineEdit * textBox;
};
@@ -438,6 +317,7 @@ public:
virtual QWidget * createEditor(QWidget * parent)
{
textBox = (QLineEdit *)ExtArgText::createEditor(parent);
+ textBox->disconnect(SIGNAL(textChanged(QString)));
if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
{
@@ -465,6 +345,8 @@ public:
textBox->setText(defaultValue());
+ connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));
+
return textBox;
};
@@ -488,6 +370,7 @@ public:
return result;
}
+
};
ExtcapValue::~ExtcapValue() {}
@@ -582,6 +465,12 @@ QString ExtcapArgument::value()
return QString();
}
+
+bool ExtcapArgument::isValid()
+{
+ return value().length() > 0;
+}
+
QString ExtcapArgument::defaultValue()
{
return QString();
@@ -609,6 +498,22 @@ void ExtcapArgument::setDefault(GHashTable * defaultsList)
}
}
+bool ExtcapArgument::isRequired()
+{
+ if ( _argument != NULL )
+ return _argument->is_required;
+
+ return FALSE;
+}
+
+bool ExtcapArgument::isDefault()
+{
+ if ( value().compare(defaultValue()) == 0 )
+ return true;
+
+ return false;
+}
+
ExtcapArgument * ExtcapArgument::create(extcap_arg * argument, GHashTable * device_defaults)
{
if ( argument == 0 || argument->display == 0 )
@@ -642,6 +547,23 @@ ExtcapArgument * ExtcapArgument::create(extcap_arg * argument, GHashTable * devi
return result;
}
+/* The following is a necessity, because Q_Object does not do well with multiple inheritances */
+void ExtcapArgument::onStringChanged(QString)
+{
+ emit valueChanged();
+}
+
+void ExtcapArgument::onIntChanged(int)
+{
+ if ( isValid() )
+ emit valueChanged();
+}
+
+void ExtcapArgument::onBoolChanged(bool)
+{
+ emit valueChanged();
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/extcap_argument.h b/ui/qt/extcap_argument.h
index 185f2bc607..0fdc59f31b 100644
--- a/ui/qt/extcap_argument.h
+++ b/ui/qt/extcap_argument.h
@@ -87,8 +87,15 @@ public:
virtual QString value();
virtual QString defaultValue();
+ bool isDefault();
+ bool isValid();
+ bool isRequired();
+
static ExtcapArgument * create(extcap_arg * argument = 0, GHashTable * device_defaults = 0);
+Q_SIGNALS:
+ void valueChanged();
+
protected:
void setDefault(GHashTable * defaultsList);
@@ -99,6 +106,13 @@ protected:
extcap_arg * _argument;
QVariant * _default;
+
+private Q_SLOTS:
+
+ void onStringChanged(QString);
+ void onIntChanged(int);
+ void onBoolChanged(bool);
+
};
#endif /* UI_QT_EXTCAP_ARGUMENT_H_ */
diff --git a/ui/qt/extcap_argument_file.cpp b/ui/qt/extcap_argument_file.cpp
index 7fec0a5fbc..557e3693b4 100644
--- a/ui/qt/extcap_argument_file.cpp
+++ b/ui/qt/extcap_argument_file.cpp
@@ -44,6 +44,12 @@ ExtcapArgumentFileSelection::ExtcapArgumentFileSelection (extcap_arg * argument)
_default = new QVariant(QString(""));
}
+ExtcapArgumentFileSelection::~ExtcapArgumentFileSelection()
+{
+ if ( textBox != NULL )
+ delete textBox;
+}
+
QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
{
QWidget * fileWidget = new QWidget(parent);
@@ -100,6 +106,13 @@ void ExtcapArgumentFileSelection::openFileDialog()
textBox->setText(filename);
}
+bool ExtcapArgumentFileSelection::isValid()
+{
+ if ( textBox->text().length() > 0 )
+ return true;
+ return false;
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/extcap_argument_file.h b/ui/qt/extcap_argument_file.h
index 14f715cb45..bc0ad5f725 100644
--- a/ui/qt/extcap_argument_file.h
+++ b/ui/qt/extcap_argument_file.h
@@ -34,12 +34,15 @@ class ExtcapArgumentFileSelection : public ExtcapArgument
Q_OBJECT
public:
- ExtcapArgumentFileSelection (extcap_arg * argument);
+ ExtcapArgumentFileSelection(extcap_arg * argument);
+ virtual ~ExtcapArgumentFileSelection();
virtual QWidget * createEditor(QWidget * parent);
virtual QString value();
+ virtual bool isValid();
+
protected:
QLineEdit * textBox;
diff --git a/ui/qt/extcap_argument_multiselect.cpp b/ui/qt/extcap_argument_multiselect.cpp
new file mode 100644
index 0000000000..b99a75379d
--- /dev/null
+++ b/ui/qt/extcap_argument_multiselect.cpp
@@ -0,0 +1,202 @@
+/* extcap_argument_multiselect.cpp
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <extcap_argument.h>
+#include <extcap_argument_file.h>
+
+#include <wsutil/utf8_entities.h>
+
+#include <QObject>
+#include <QWidget>
+#include <QLabel>
+#include <QLineEdit>
+#include <QBoxLayout>
+#include <QPushButton>
+#include <QVariant>
+
+#include <extcap_parser.h>
+#include <extcap_argument_multiselect.h>
+
+ExtArgMultiSelect::ExtArgMultiSelect(extcap_arg * argument) :
+ ExtcapArgument(argument), treeView(0), viewModel(0) {};
+
+ExtArgMultiSelect::~ExtArgMultiSelect()
+{
+ if ( treeView != 0 )
+ delete treeView;
+ if ( viewModel != 0 )
+ delete viewModel;
+}
+
+QList<QStandardItem *> ExtArgMultiSelect::valueWalker(ExtcapValueList list, QStringList &defaults)
+{
+ ExtcapValueList::iterator iter = list.begin();
+ QList<QStandardItem *> items;
+
+ while ( iter != list.end() )
+ {
+ QStandardItem * item = new QStandardItem((*iter).value());
+ if ( (*iter).enabled() == false )
+ {
+ item->setSelectable(false);
+ }
+ else
+ item->setSelectable(true);
+
+ item->setData((*iter).call(), Qt::UserRole);
+ if ((*iter).isDefault())
+ defaults << (*iter).call();
+
+ item->setEditable(false);
+ QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults);
+ if ( childs.length() > 0 )
+ item->appendRows(childs);
+
+ items << item;
+ ++iter;
+ }
+
+ return items;
+}
+
+void ExtArgMultiSelect::selectItemsWalker(QStandardItem * item, QStringList defaults)
+{
+ QModelIndexList results;
+ QModelIndex index;
+
+ if ( item->hasChildren() )
+ {
+ for (int row = 0; row < item->rowCount(); row++)
+ {
+ QStandardItem * child = item->child(row);
+ if ( child != 0 )
+ {
+ selectItemsWalker(child, defaults);
+ }
+ }
+ }
+
+ QString data = item->data(Qt::UserRole).toString();
+
+ if ( defaults.contains(data) )
+ {
+ treeView->selectionModel()->select(item->index(), QItemSelectionModel::Select);
+ index = item->index();
+ while ( index.isValid() )
+ {
+ treeView->setExpanded(index, true);
+ index = index.parent();
+ }
+ }
+}
+
+QWidget * ExtArgMultiSelect::createEditor(QWidget * parent)
+{
+ QStringList defaults;
+
+ QList<QStandardItem *> items = valueWalker(values, defaults);
+ if (items.length() == 0)
+ return new QWidget();
+
+ if ( _default != 0 )
+ defaults = _default->toString().split(",", QString::SkipEmptyParts);
+
+ viewModel = new QStandardItemModel();
+ QList<QStandardItem *>::const_iterator iter = items.constBegin();
+ while ( iter != items.constEnd() )
+ {
+ ((QStandardItemModel *)viewModel)->appendRow((*iter));
+ ++iter;
+ }
+
+ treeView = new QTreeView(parent);
+ treeView->setModel(viewModel);
+
+ /* Shows at minimum 6 entries at most desktops */
+ treeView->setMinimumHeight(100);
+ treeView->setHeaderHidden(true);
+ treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+ for (int row = 0; row < viewModel->rowCount(); row++ )
+ selectItemsWalker(((QStandardItemModel*)viewModel)->item(row), defaults);
+
+ connect ( treeView->selectionModel(),
+ SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ SLOT(selectionChanged(const QItemSelection &, const QItemSelection &)) );
+
+ return treeView;
+}
+
+QString ExtArgMultiSelect::value()
+{
+ if ( viewModel == 0 )
+ return QString();
+
+ QStringList result;
+ QModelIndexList selected = treeView->selectionModel()->selectedIndexes();
+
+ if ( selected.size() <= 0 )
+ return QString();
+
+ QModelIndexList::const_iterator iter = selected.constBegin();
+ while ( iter != selected.constEnd() )
+ {
+ QModelIndex index = (QModelIndex)(*iter);
+
+ result << viewModel->data(index, Qt::UserRole).toString();
+
+ ++iter;
+ }
+
+ return result.join(QString(","));
+}
+
+QString ExtArgMultiSelect::defaultValue()
+{
+ if ( _argument != 0 && _argument->default_complex != 0)
+ {
+ gchar * str = extcap_get_complex_as_string(_argument->default_complex);
+ if ( str != 0 )
+ return QString(str);
+ }
+
+ return QString();
+}
+
+void ExtArgMultiSelect::selectionChanged(const QItemSelection &, const QItemSelection &)
+{
+ emit valueChanged();
+}
+
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/extcap_argument_multiselect.h b/ui/qt/extcap_argument_multiselect.h
new file mode 100644
index 0000000000..9b9dcd6480
--- /dev/null
+++ b/ui/qt/extcap_argument_multiselect.h
@@ -0,0 +1,74 @@
+/* extcap_argument_multiselect.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_
+#define UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_
+
+#include <QObject>
+#include <QWidget>
+#include <QStandardItem>
+#include <QTreeView>
+#include <QAbstractItemModel>
+#include <QItemSelection>
+
+#include <extcap_parser.h>
+#include <extcap_argument.h>
+
+class ExtArgMultiSelect : public ExtcapArgument
+{
+ Q_OBJECT
+public:
+ ExtArgMultiSelect(extcap_arg * argument);
+ virtual ~ExtArgMultiSelect();
+
+ virtual QString value();
+ virtual QString defaultValue();
+
+protected:
+ virtual QList<QStandardItem *> valueWalker(ExtcapValueList list, QStringList &defaults);
+ void selectItemsWalker(QStandardItem * item, QStringList defaults);
+ virtual QWidget * createEditor(QWidget * parent);
+
+private Q_SLOTS:
+
+ void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
+
+private:
+
+ QTreeView * treeView;
+ QAbstractItemModel * viewModel;
+
+};
+
+#endif /* UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_ */
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp
index 9f5f515ba2..229c5e5843 100644
--- a/ui/qt/extcap_options_dialog.cpp
+++ b/ui/qt/extcap_options_dialog.cpp
@@ -62,17 +62,14 @@ ExtcapOptionsDialog::ExtcapOptionsDialog(QWidget *parent) :
ui(new Ui::ExtcapOptionsDialog),
device_name(""),
device_idx(0),
- device_defaults(NULL),
- start_bt_(NULL)
+ device_defaults(NULL)
{
ui->setupUi(this);
setWindowTitle(wsApp->windowTitleString(tr("Extcap Interface Options")));
- start_bt_ = ui->buttonBox->addButton(tr("Start"), QDialogButtonBox::AcceptRole);
+ ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start"));
- start_bt_->setEnabled((global_capture_opts.num_selected > 0)? true: false);
- connect(start_bt_, SIGNAL(clicked(bool)), this, SLOT(start_button_clicked()));
}
ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, QWidget *parent)
@@ -116,18 +113,38 @@ ExtcapOptionsDialog::~ExtcapOptionsDialog()
delete ui;
}
-void ExtcapOptionsDialog::start_button_clicked()
+void ExtcapOptionsDialog::on_buttonBox_accepted()
{
- if (saveOptionsToPreferences()) {
+ if (saveOptionToCaptureInfo()) {
accept();
}
}
+void ExtcapOptionsDialog::anyValueChanged()
+{
+ /* Guard, that only extcap arguments are given, which should be the case anyway */
+ if ( dynamic_cast<ExtcapArgument *>(QObject::sender()) == NULL )
+ return;
+
+ bool allowStart = true;
+
+ ExtcapArgumentList::const_iterator iter;
+
+ for(iter = extcapArguments.constBegin(); iter != extcapArguments.constEnd() && allowStart; ++iter)
+ {
+ if ( (*iter)->isRequired() && ! (*iter)->isValid() )
+ allowStart = false;
+ }
+
+ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowStart);
+}
+
void ExtcapOptionsDialog::updateWidgets()
{
GList * arguments = NULL, * walker = NULL, * item = NULL;
QWidget * lblWidget = NULL, *editWidget = NULL;
ExtcapArgument * argument = NULL;
+ bool allowStart = true;
unsigned int counter = 0;
@@ -158,6 +175,12 @@ void ExtcapOptionsDialog::updateWidgets()
{
layout->addWidget(editWidget, counter, 1, Qt::AlignVCenter);
}
+
+ if ( argument->isRequired() && ! argument->isValid() )
+ allowStart = false;
+
+ connect(argument, SIGNAL(valueChanged()), this, SLOT(anyValueChanged()));
+
counter++;
}
}
@@ -167,10 +190,15 @@ void ExtcapOptionsDialog::updateWidgets()
walker = walker->next;
}
- if ( counter > 0 ) {
+ if ( counter > 0 )
+ {
+ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowStart);
+
ui->verticalLayout->addLayout(layout);
ui->verticalLayout->addSpacerItem(new QSpacerItem(20, 100, QSizePolicy::Minimum, QSizePolicy::Expanding));
- } else {
+ }
+ else
+ {
delete layout;
}
}
@@ -178,7 +206,7 @@ void ExtcapOptionsDialog::updateWidgets()
// Not sure why we have to do this manually.
void ExtcapOptionsDialog::on_buttonBox_rejected()
{
- if (saveOptionsToPreferences()) {
+ if (saveOptionToCaptureInfo()) {
reject();
}
}
@@ -189,7 +217,7 @@ void ExtcapOptionsDialog::on_buttonBox_helpRequested()
wsApp->helpTopicAction(HELP_EXTCAP_OPTIONS_DIALOG);
}
-bool ExtcapOptionsDialog::saveOptionsToPreferences()
+bool ExtcapOptionsDialog::saveOptionToCaptureInfo()
{
GHashTable * ret_args;
interface_t device;
diff --git a/ui/qt/extcap_options_dialog.h b/ui/qt/extcap_options_dialog.h
index 9cd57fe9cb..c508d62701 100644
--- a/ui/qt/extcap_options_dialog.h
+++ b/ui/qt/extcap_options_dialog.h
@@ -53,11 +53,12 @@ public:
~ExtcapOptionsDialog();
static ExtcapOptionsDialog * createForDevice(QString &device_name, QWidget *parent = 0);
-private slots:
- void start_button_clicked();
+private Q_SLOTS:
+ void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void updateWidgets();
+ void anyValueChanged();
private:
explicit ExtcapOptionsDialog(QWidget *parent = 0);
@@ -66,11 +67,10 @@ private:
QString device_name;
guint device_idx;
GHashTable * device_defaults;
- QPushButton *start_bt_;
ExtcapArgumentList extcapArguments;
- bool saveOptionsToPreferences();
+ bool saveOptionToCaptureInfo();
};
#endif /* HAVE_EXTCAP */
diff --git a/ui/qt/extcap_options_dialog.ui b/ui/qt/extcap_options_dialog.ui
index 1600df9b7b..d22380aee3 100644
--- a/ui/qt/extcap_options_dialog.ui
+++ b/ui/qt/extcap_options_dialog.ui
@@ -6,13 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
- <width>450</width>
- <height>49</height>
+ <width>600</width>
+ <height>55</height>
</rect>
</property>
<property name="minimumSize">
<size>
- <width>450</width>
+ <width>600</width>
<height>0</height>
</size>
</property>
@@ -23,7 +23,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
- <set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>