diff options
author | Jaap Keuter <jaap.keuter@xs4all.nl> | 2017-01-24 19:42:18 +0100 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-01-26 08:20:14 +0000 |
commit | 795b5d44e5a091b9f87d7ea8aac4701077807bc3 (patch) | |
tree | 1f8e480077dc47487f8616e77b23c8cdbb1a9383 | |
parent | 6a99a2ce431a1b9188cd83c70dc16cd62cefead4 (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.cpp | 34 | ||||
-rw-r--r-- | ui/qt/display_filter_expression_dialog.ui | 10 |
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><html><head/><body><p>Relations can be used to restrict fields to specific values. Each relation does the following:</p> -<table><tbody> -<tr><th>is present</th><td>Match any packet that contains this field</td></tr> -<tr><th>==, !=, etc.</th><td>Compare the field to a specific value.</td></tr> -<tr><th>contains, matches</th><td>Check the field against a string (contains) or a regular expression (matches)</td></tr> -</tbody></table> -</body></html></string> + <string><html><head/><body><p>Relations can be used to restrict fields to specific values. Each relation does the following:</p><table border="0" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;" cellspacing="2" cellpadding="0"><tr><td><p align="center"><span style=" font-weight:600;">is present</span></p></td><td><p>Match any packet that contains this field</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">==, !=, etc.</span></p></td><td><p>Compare the field to a specific value.</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">contains, matches</span></p></td><td><p>Check the field against a string (contains) or a regular expression (matches)</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">in</span></p></td><td><p>Compare the field to a specific set of values</p></td></tr></table></body></html> + +</string> </property> <property name="text"> <string>Relation</string> |