diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-03-31 02:08:30 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-03-31 09:44:51 +0000 |
commit | fff930d3939c21a1ed988ef9014c32f75739ea7c (patch) | |
tree | 1878acd337b45ef2440b50fff5abcb8a4adcd522 /ui/qt | |
parent | 641a48ec68778a5eaed82e436c09642e9ef1f911 (diff) |
Qt: do not expand collapsed trees when switching packets
Scenario: user selects a field, collapsed tha parent tree and selects
the next packet. Before this patch, the tree would be expanded again,
selecting the child. After this patch, the tree will not be expanded,
instead selecting the tree node that got collapsed.
Change-Id: I7968fca1056a937cf3b399afb6f3089c2d199067
Reviewed-on: https://code.wireshark.org/review/20801
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/proto_tree.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 2686b2ea69..32c73e4085 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -633,8 +633,15 @@ void ProtoTree::restoreSelectedField() field_info *fi = VariantPointer<field_info>::asPtr((*iter)->data(0, Qt::UserRole)); if (last_hf_id == fi->hfinfo->id && serializeAsPath(*iter) == selected_field_path_) { - setCurrentItem(*iter); - scrollToItem(*iter); + // focus the first item, but do not expand collapsed trees. + QTreeWidgetItem *item = *iter, *target = item; + do { + if (!item->isExpanded()) { + target = item; + } + } while ((item = item->parent())); + setCurrentItem(target); + scrollToItem(target); break; } ++iter; |