diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-12-10 22:38:35 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-12-10 22:38:35 +0000 |
commit | 3889cfc91b984bbe5374ee8f4f07d84307b793cd (patch) | |
tree | c5de1a0d89481d529e50438ab283da206af2770e /ui | |
parent | 20c7414c71174df33ede6e89cd98e99b662e2174 (diff) |
From Deon van der Westhuysen via bug 9537:
----
The qt version of wireshark (stats_tree_dialog.cpp) by default expands
all nodes within a stats_tree (see for example the "Statistics" > "IP
Statistics" > "IP Destinations" stats_tree; you need this patch
installed before the item is added to the stats menu:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9528). This
behaviour is fine for small trees but becomes counter productive in
trees with many items or levels.
This patch changes the qt ui to act like the gtk ui: the first level of
nodes are expanded by default while deeper levels are collapsed.
----
From me: "Expand all" makes sense for a small number of items. Do so if
we have less than 100.
svn path=/trunk/; revision=53928
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/stats_tree_dialog.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ui/qt/stats_tree_dialog.cpp b/ui/qt/stats_tree_dialog.cpp index 76c2fd8acf..478a45bf84 100644 --- a/ui/qt/stats_tree_dialog.cpp +++ b/ui/qt/stats_tree_dialog.cpp @@ -50,6 +50,8 @@ const int item_col_ = 0; +const int expand_all_threshold_ = 100; // Arbitrary + Q_DECLARE_METATYPE(stat_node *); class StatsTreeWidgetItem : public QTreeWidgetItem @@ -224,6 +226,7 @@ void StatsTreeDialog::drawTreeItems(void *st_ptr) if (!st || !st->cfg || !st->cfg->pr || !st->cfg->pr->st_dlg) return; StatsTreeDialog *st_dlg = st->cfg->pr->st_dlg; QTreeWidgetItemIterator iter(st_dlg->ui->statsTreeWidget); + int node_count = 0; while (*iter) { stat_node *node = (*iter)->data(item_col_, Qt::UserRole).value<stat_node *>(); @@ -233,13 +236,17 @@ void StatsTreeDialog::drawTreeItems(void *st_ptr) (*iter)->setText(count,valstrs[count]); g_free(valstrs[count]); } - if (node->parent==(&st->root)) { - (*iter)->setExpanded(!(node->st_flags&ST_FLG_DEF_NOEXPAND)); - } + (*iter)->setExpanded( (node->parent==(&st->root)) && + (!(node->st_flags&ST_FLG_DEF_NOEXPAND)) ); g_free(valstrs); } + node_count++; ++iter; } + if (node_count < expand_all_threshold_) { + st_dlg->ui->statsTreeWidget->expandAll(); + } + for (int count = 0; count<st->num_columns; count++) { st_dlg->ui->statsTreeWidget->resizeColumnToContents(count); } |