diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-02-25 15:41:02 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-02-27 09:09:35 +0000 |
commit | 61d033645d7b146c2535fce8ed1cbb6272dde2d7 (patch) | |
tree | 039728f6164288430ccc4cf91cffcfbdda59f6a3 /ui/qt/packet_list.cpp | |
parent | 30692e2f3a872a91d5c41cf59badf3eb393c5734 (diff) |
Qt/USB: Allow USB src/dst addresses to be selected for columns
Make "Prepare a Filter" from the Source and Destination columns work for
USB source and destination address, this value must be quoted as well.
Change-Id: Ib7a772050c204e716781cc27f9eddbdb7971e547
Reviewed-on: https://code.wireshark.org/review/26096
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/packet_list.cpp')
-rw-r--r-- | ui/qt/packet_list.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 657928a749..dd2582227d 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -1002,6 +1002,7 @@ QString PacketList::getFilterFromRowAndColumn() */ if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 && strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) { + gboolean is_string_value = FALSE; if (cap_file_->cinfo.columns[ctx_column_].col_fmt == COL_CUSTOM) { header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.columns[ctx_column_].col_custom_fields); if (hfi && hfi->parent == -1) { @@ -1009,16 +1010,27 @@ QString PacketList::getFilterFromRowAndColumn() filter.append(cap_file_->cinfo.col_expr.col_expr[ctx_column_]); } else if (hfi && hfi->type == FT_STRING) { /* Custom string, add quotes */ + is_string_value = TRUE; + } + } else { + header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.col_expr.col_expr[ctx_column_]); + if (hfi && hfi->type == FT_STRING) { + /* Could be an address type such as usb.src which must be quoted. */ + is_string_value = TRUE; + } + } + + if (filter.isEmpty()) { + if (is_string_value) { filter.append(QString("%1 == \"%2\"") .arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) .arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_])); + } else { + filter.append(QString("%1 == %2") + .arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) + .arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_])); } } - if (filter.isEmpty()) { - filter.append(QString("%1 == %2") - .arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) - .arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_])); - } } } |