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>
This commit is contained in:
Stig Bjørlykke 2017-12-18 10:25:03 +01:00 committed by Anders Broman
parent 5ebc3277ed
commit 9f7b8713fa
5 changed files with 42 additions and 0 deletions

View File

@ -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()),

View File

@ -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>

View File

@ -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);

View File

@ -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++) {

View File

@ -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);