From 9bd2eef45ee657f90dff7e2e00354eee3d128e37 Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Mon, 26 Aug 2019 16:42:50 +0200 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- ui/qt/proto_tree.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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())); -- cgit v1.2.3