aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2019-08-26 16:42:50 +0200
committerRoland Knall <rknall@gmail.com>2019-08-26 19:57:43 +0000
commit9bd2eef45ee657f90dff7e2e00354eee3d128e37 (patch)
treeacb074156037a3d24ce585099d8b5db11b2881a2 /ui
parentc9361120f0a7544d0fc95a24d0e51aaaaf09c89a (diff)
Qt: Add Apply/Prepare to Packet Dialog
Add the possibility to apply/prepare a field entry to the packet dialog. This works also if the corresponding source file had already been closed. Bug: 3537 Change-Id: I448ad6d5cb37f2cbb2c2f649512b1f3e5acde2de Reviewed-on: https://code.wireshark.org/review/34372 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/proto_tree.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 81dbd45bfd..8c98ea0dc3 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -112,10 +112,11 @@ void ProtoTree::protoTreeContextMenu(QContextMenuEvent * event)
#endif
QModelIndex index = indexAt(event->pos());
+ field_info * fi = Q_NULLPTR;
if ( index.isValid() )
{
FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode());
- field_info * fi = finfo.fieldInfo();
+ fi = finfo.fieldInfo();
bool is_selected = false;
@@ -146,6 +147,24 @@ void ProtoTree::protoTreeContextMenu(QContextMenuEvent * event)
ctxMenu.addAction(tr("Collapse All"), this, SLOT(collapseAll()));
ctxMenu.addSeparator();
+ epan_dissect_t *edt = cap_file_ ? cap_file_->edt : edt_;
+ if ( fi && edt )
+ {
+ char * selectedfilter = proto_construct_match_selected_string(fi, edt);
+ bool can_match_selected = proto_can_match_selected(fi, edt);
+ QMenu * main_menu_item = new QMenu(tr("Apply as Filter"), &ctxMenu);
+ QActionGroup * group = FilterAction::createFilterGroup(selectedfilter, false, can_match_selected, &ctxMenu);
+ main_menu_item->addActions(group->actions());
+ ctxMenu.addMenu(main_menu_item);
+ main_menu_item = new QMenu(tr("Prepare as Filter"), &ctxMenu);
+ group = FilterAction::createFilterGroup(selectedfilter, true, can_match_selected, &ctxMenu);
+ main_menu_item->addActions(group->actions());
+ ctxMenu.addMenu(main_menu_item);
+ if ( selectedfilter )
+ wmem_free(Q_NULLPTR, selectedfilter);
+ ctxMenu.addSeparator();
+ }
+
QMenu *submenu = ctxMenu.addMenu(tr("Copy"));
submenu->addAction(tr("All Visible Items"), this, SLOT(ctxCopyVisibleItems()));
action = submenu->addAction(tr("All Visible Selected Tree Items"), this, SLOT(ctxCopyVisibleItems()));