aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/main_window.cpp2
-rw-r--r--ui/qt/main_window.ui15
-rw-r--r--ui/qt/main_window_slots.cpp1
-rw-r--r--ui/qt/proto_tree.cpp23
-rw-r--r--ui/qt/proto_tree.h1
5 files changed, 42 insertions, 0 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 568a3ebf4c..a571370551 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -672,6 +672,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(main_ui_->actionViewExpandSubtrees, SIGNAL(triggered()),
proto_tree_, SLOT(expandSubtrees()));
+ connect(main_ui_->actionViewCollapseSubtrees, SIGNAL(triggered()),
+ proto_tree_, SLOT(collapseSubtrees()));
connect(main_ui_->actionViewExpandAll, SIGNAL(triggered()),
proto_tree_, SLOT(expandAll()));
connect(main_ui_->actionViewCollapseAll, SIGNAL(triggered()),
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index 17d5d3242c..87ecfdd379 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -369,6 +369,7 @@
<addaction name="menuZoom"/>
<addaction name="separator"/>
<addaction name="actionViewExpandSubtrees"/>
+ <addaction name="actionViewCollapseSubtrees"/>
<addaction name="actionViewExpandAll"/>
<addaction name="actionViewCollapseAll"/>
<addaction name="separator"/>
@@ -1067,6 +1068,20 @@
<string notr="true">Shift+Right</string>
</property>
</action>
+ <action name="actionViewCollapseSubtrees">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Collapse Subtrees</string>
+ </property>
+ <property name="toolTip">
+ <string>Collapse the current packet detail</string>
+ </property>
+ <property name="shortcut">
+ <string notr="true">Shift+Left</string>
+ </property>
+ </action>
<action name="actionViewExpandAll">
<property name="text">
<string>&amp;Expand All</string>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index b83ad46bba..2f5ff9dc8e 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1451,6 +1451,7 @@ void MainWindow::setMenusForSelectedTreeRow(FieldInformation *finfo) {
main_ui_->actionFileExportPacketBytes->setEnabled(have_packet_bytes);
main_ui_->actionViewExpandSubtrees->setEnabled(have_subtree);
+ main_ui_->actionViewCollapseSubtrees->setEnabled(have_subtree);
main_ui_->actionGoGoToLinkedPacket->setEnabled(is_framenum);
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 2b91b1c37d..b64e89e1b9 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -60,6 +60,7 @@ ProtoTree::ProtoTree(QWidget *parent) :
QAction *action;
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewExpandSubtrees"));
+ ctx_menu_.addAction(window()->findChild<QAction *>("actionViewCollapseSubtrees"));
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewExpandAll"));
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewCollapseAll"));
ctx_menu_.addSeparator();
@@ -389,6 +390,28 @@ void ProtoTree::expandSubtrees()
updateContentWidth();
}
+void ProtoTree::collapseSubtrees()
+{
+ if (!selectionModel()->hasSelection()) return;
+
+ QStack<QModelIndex> index_stack;
+ index_stack.push(selectionModel()->selectedIndexes().first());
+
+ while (!index_stack.isEmpty()) {
+ QModelIndex index = index_stack.pop();
+ collapse(index);
+ int row_count = proto_tree_model_->rowCount(index);
+ for (int row = row_count - 1; row >= 0; row--) {
+ QModelIndex child = proto_tree_model_->index(row, 0, index);
+ if (proto_tree_model_->hasChildren(child)) {
+ index_stack.push(child);
+ }
+ }
+ }
+
+ updateContentWidth();
+}
+
void ProtoTree::expandAll()
{
for(int i = 0; i < num_tree_types; i++) {
diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h
index 2a9da487c2..6254e62521 100644
--- a/ui/qt/proto_tree.h
+++ b/ui/qt/proto_tree.h
@@ -79,6 +79,7 @@ public slots:
void expand(const QModelIndex & index);
void collapse(const QModelIndex & index);
void expandSubtrees();
+ void collapseSubtrees();
void expandAll();
void collapseAll();
void itemDoubleClicked(const QModelIndex & index);