aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2017-01-24 19:42:18 +0100
committerRoland Knall <rknall@gmail.com>2017-01-26 08:20:14 +0000
commit795b5d44e5a091b9f87d7ea8aac4701077807bc3 (patch)
tree1f8e480077dc47487f8616e77b23c8cdbb1a9383
parent6a99a2ce431a1b9188cd83c70dc16cd62cefead4 (diff)
Add 'in' operator in display filter expression dialog
Add the 'in' operator to the list of available operators, where 'eq' operator would be present also. Setup the curly bracket expression in the filter and allow for multiple enums to be selected. Ping-Bug: 12808 Change-Id: Ibeef52ba9d41549d0684b0069270ff09f5a93e81 Reviewed-on: https://code.wireshark.org/review/19767 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--ui/qt/display_filter_expression_dialog.cpp34
-rw-r--r--ui/qt/display_filter_expression_dialog.ui10
2 files changed, 29 insertions, 15 deletions
diff --git a/ui/qt/display_filter_expression_dialog.cpp b/ui/qt/display_filter_expression_dialog.cpp
index b7dd784d1b..b5e7f2ce72 100644
--- a/ui/qt/display_filter_expression_dialog.cpp
+++ b/ui/qt/display_filter_expression_dialog.cpp
@@ -59,7 +59,8 @@ enum {
ge_op_,
le_op_,
contains_op_,
- matches_op_
+ matches_op_,
+ in_op_
};
DisplayFilterExpressionDialog::DisplayFilterExpressionDialog(QWidget *parent) :
@@ -93,6 +94,7 @@ DisplayFilterExpressionDialog::DisplayFilterExpressionDialog(QWidget *parent) :
new QListWidgetItem("<=", ui->relationListWidget, le_op_);
new QListWidgetItem("contains", ui->relationListWidget, contains_op_);
new QListWidgetItem("matches", ui->relationListWidget, matches_op_);
+ new QListWidgetItem("in", ui->relationListWidget, in_op_);
value_label_pfx_ = ui->valueLabel->text();
@@ -174,10 +176,11 @@ void DisplayFilterExpressionDialog::updateWidgets()
bool value_enable = false;
bool enum_enable = false;
+ bool enum_multi_enable = false;
bool range_enable = false;
QString filter;
- if (field_ && rel_enable) {
+ if (field_) {
filter = field_;
QListWidgetItem *rli = ui->relationListWidget->currentItem();
if (rli && rli->type() != present_op_) {
@@ -189,10 +192,15 @@ void DisplayFilterExpressionDialog::updateWidgets()
filter.append(QString(" %1").arg(rli->text()));
}
if (value_enable && !ui->valueLineEdit->text().isEmpty()) {
- if (ftype_ == FT_STRING) {
- filter.append(QString(" \"%1\"").arg(ui->valueLineEdit->text()));
+ if (rli && rli->type() == in_op_) {
+ filter.append(QString(" {%1}").arg(ui->valueLineEdit->text()));
+ enum_multi_enable = enum_enable;
} else {
- filter.append(QString(" %1").arg(ui->valueLineEdit->text()));
+ if (ftype_ == FT_STRING) {
+ filter.append(QString(" \"%1\"").arg(ui->valueLineEdit->text()));
+ } else {
+ filter.append(QString(" %1").arg(ui->valueLineEdit->text()));
+ }
}
}
}
@@ -202,6 +210,8 @@ void DisplayFilterExpressionDialog::updateWidgets()
ui->enumLabel->setEnabled(enum_enable);
ui->enumListWidget->setEnabled(enum_enable);
+ ui->enumListWidget->setSelectionMode(enum_multi_enable ?
+ QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
ui->rangeLabel->setEnabled(range_enable);
ui->rangeLineEdit->setEnabled(range_enable);
@@ -357,6 +367,7 @@ void DisplayFilterExpressionDialog::on_fieldTreeWidget_itemSelectionChanged()
QListWidgetItem *li = ui->relationListWidget->item(i);
switch (li->type()) {
case eq_op_:
+ case in_op_:
li->setHidden(!ftype_can_eq(ftype_) && !(ftype_can_slice(ftype_) && ftype_can_eq(FT_BYTES)));
break;
case ne_op_:
@@ -409,10 +420,17 @@ void DisplayFilterExpressionDialog::on_relationListWidget_itemSelectionChanged()
void DisplayFilterExpressionDialog::on_enumListWidget_itemSelectionChanged()
{
- if (ui->enumListWidget->selectedItems().count() > 0) {
- QListWidgetItem *eli = ui->enumListWidget->selectedItems()[0];
- ui->valueLineEdit->setText(eli->data(Qt::UserRole).toString());
+ QStringList values;
+ QList<QListWidgetItem *> items = ui->enumListWidget->selectedItems();
+ QList<QListWidgetItem *>::const_iterator it = items.constBegin();
+ while (it != items.constEnd())
+ {
+ values << (*it)->data(Qt::UserRole).toString();
+ ++it;
}
+
+ ui->valueLineEdit->setText(values.join(" "));
+
updateWidgets();
}
diff --git a/ui/qt/display_filter_expression_dialog.ui b/ui/qt/display_filter_expression_dialog.ui
index 8651dd4409..2f45bfefcc 100644
--- a/ui/qt/display_filter_expression_dialog.ui
+++ b/ui/qt/display_filter_expression_dialog.ui
@@ -69,13 +69,9 @@
<item>
<widget class="QLabel" name="relationLabel">
<property name="toolTip">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Relations can be used to restrict fields to specific values. Each relation does the following:&lt;/p&gt;
-&lt;table&gt;&lt;tbody&gt;
-&lt;tr&gt;&lt;th&gt;is present&lt;/th&gt;&lt;td&gt;Match any packet that contains this field&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;th&gt;==, !=, etc.&lt;/th&gt;&lt;td&gt;Compare the field to a specific value.&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;th&gt;contains, matches&lt;/th&gt;&lt;td&gt;Check the field against a string (contains) or a regular expression (matches)&lt;/td&gt;&lt;/tr&gt;
-&lt;/tbody&gt;&lt;/table&gt;
-&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Relations can be used to restrict fields to specific values. Each relation does the following:&lt;/p&gt;&lt;table border=&quot;0&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;is present&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;Match any packet that contains this field&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;==, !=, etc.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;Compare the field to a specific value.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;contains, matches&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;Check the field against a string (contains) or a regular expression (matches)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;in&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;Compare the field to a specific set of values&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;
+
+</string>
</property>
<property name="text">
<string>Relation</string>