aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-12-18 10:25:03 +0100
committerAnders Broman <a.broman58@gmail.com>2017-12-19 04:46:49 +0000
commit9f7b8713fa8286611e84a68f82adc2d494b21173 (patch)
treeb18a303aff1c410059ebc896dce628fa403f7e67
parent5ebc3277ed98c39b24d971470d1aea0efe042351 (diff)
Qt: Add Collapse Subtrees
This item is missing from the Qt port. Change-Id: Iacc18a7c2eb2368d6566622788a4e900868d446e Reviewed-on: https://code.wireshark.org/review/24879 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-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 568a3eb..a571370 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 17d5d32..87ecfdd 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 b83ad46..2f5ff9d 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 2b91b1c..b64e89e 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 2a9da48..6254e62 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);