From f77e02ccc62c9283eefba416efbb2f94e460066e Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 11 Mar 2015 15:22:20 -0700 Subject: Expert Info dialog. Show all expert messages in a combined view. Group top-level items by a (severity, group, protocol) tuple. Let the user enable and disable messages via a check menu. Add ProtoTree::goToField and expert_info_t.hf_index. Use them to jump to what we hope is the afflicted item. Enable the context menu only if the user has selected a packet item. Add a free-form search field that matches expert summaries. This differs from the GTK+ version but hopefully provides a smoother workflow. Bug: 10931 Change-Id: Ia12cb7c27cdea1634fa2798fb7e4c1b23bd16ad2 Reviewed-on: https://code.wireshark.org/review/8294 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/proto_tree.cpp | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'ui/qt/proto_tree.cpp') diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index ed07e0e36b..7af1956dbc 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -26,6 +26,8 @@ #include #include +#include "color_utils.h" + #include #include #include @@ -33,14 +35,6 @@ #include #include -QColor expert_color_comment ( 0xb7, 0xf7, 0x74 ); /* Green */ -QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */ -QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */ -QColor expert_color_warn ( 0xf7, 0xf2, 0x53 ); /* yellow */ -QColor expert_color_error ( 0xff, 0x5c, 0x5c ); /* pale red */ -QColor expert_color_foreground ( 0x00, 0x00, 0x00 ); /* black */ -QColor hidden_proto_item ( 0x44, 0x44, 0x44 ); /* gray */ - /* Fill a single protocol tree item with its string value and set its color. */ static void proto_tree_draw_node(proto_node *node, gpointer data) @@ -117,24 +111,24 @@ proto_tree_draw_node(proto_node *node, gpointer data) if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { case(PI_COMMENT): - item->setData(0, Qt::BackgroundRole, expert_color_comment); + item->setData(0, Qt::BackgroundRole, ColorUtils::expert_color_comment); break; case(PI_CHAT): - item->setData(0, Qt::BackgroundRole, expert_color_chat); + item->setData(0, Qt::BackgroundRole, ColorUtils::expert_color_chat); break; case(PI_NOTE): - item->setData(0, Qt::BackgroundRole, expert_color_note); + item->setData(0, Qt::BackgroundRole, ColorUtils::expert_color_note); break; case(PI_WARN): - item->setData(0, Qt::BackgroundRole, expert_color_warn); + item->setData(0, Qt::BackgroundRole, ColorUtils::expert_color_warn); break; case(PI_ERROR): - item->setData(0, Qt::BackgroundRole, expert_color_error); + item->setData(0, Qt::BackgroundRole, ColorUtils::expert_color_error); break; default: g_assert_not_reached(); } - item->setData(0, Qt::ForegroundRole, expert_color_foreground); + item->setData(0, Qt::ForegroundRole, ColorUtils::expert_color_foreground); } item->setText(0, label_ptr); @@ -302,6 +296,25 @@ void ProtoTree::emitRelatedFrame(int related_frame, ft_framenum_type_t framenum_ emit relatedFrame(related_frame, framenum_type); } +// XXX We select the first match, which might not be the desired item. +void ProtoTree::goToField(int hf_id) +{ + if (hf_id < 0) return; + + QTreeWidgetItemIterator iter(this); + while (*iter) { + field_info *fi = (*iter)->data(0, Qt::UserRole).value(); + + if (fi && fi->hfinfo) { + if (fi->hfinfo->id == hf_id) { + setCurrentItem(*iter); + break; + } + } + iter++; + } +} + void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item) { if (item) { -- cgit v1.2.3