diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-05-12 16:28:39 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-05-13 19:37:58 +0000 |
commit | 703b5dc48a441689738f39641645cbf126a2acfb (patch) | |
tree | 900e53328750e4a3f02f32076f485a8256858b13 /ui/qt/proto_tree.cpp | |
parent | 84db6a661d7b4d0eb564cf047e09b17da5d5abab (diff) |
Qt: Don't set ProtoTree::uniformRowHeights.
Some packet detail items contain multiple lines. Show them, which
duplicates the GTK+ UI behavior. Add a note about adding a custom item
delegate if this affects performance.
Make item labels QStrings while we're here.
Bug: 10225
Change-Id: Ia39320028ecff5fe7fa3e4c09ff37405986b7f6e
Reviewed-on: https://code.wireshark.org/review/8445
Tested-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/proto_tree.cpp')
-rw-r--r-- | ui/qt/proto_tree.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 7af1956dbc..c12b2dc48d 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -40,8 +40,7 @@ static void proto_tree_draw_node(proto_node *node, gpointer data) { field_info *fi = PNODE_FINFO(node); - gchar label_str[ITEM_LABEL_LENGTH]; - gchar *label_ptr; + QString label; gboolean is_branch; /* dissection with an invisible proto tree? */ @@ -53,11 +52,12 @@ proto_tree_draw_node(proto_node *node, gpointer data) // Fill in our label /* was a free format label produced? */ if (fi->rep) { - label_ptr = fi->rep->representation; + label = fi->rep->representation; } else { /* no, make a generic label */ - label_ptr = label_str; + gchar label_str[ITEM_LABEL_LENGTH]; proto_item_fill_label(fi, label_str); + label = label_str; } if (node->first_child != NULL) { @@ -70,12 +70,12 @@ proto_tree_draw_node(proto_node *node, gpointer data) if (PROTO_ITEM_IS_GENERATED(node)) { if (PROTO_ITEM_IS_HIDDEN(node)) { - label_ptr = g_strdup_printf("<[%s]>", label_ptr); + label = QString("<[%1]>").arg(label); } else { - label_ptr = g_strdup_printf("[%s]", label_ptr); + label = QString("[%1]").arg(label); } } else if (PROTO_ITEM_IS_HIDDEN(node)) { - label_ptr = g_strdup_printf("<%s>", label_ptr); + label = QString("<%1>").arg(label); } QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data; @@ -131,13 +131,9 @@ proto_tree_draw_node(proto_node *node, gpointer data) item->setData(0, Qt::ForegroundRole, ColorUtils::expert_color_foreground); } - item->setText(0, label_ptr); + item->setText(0, label); item->setData(0, Qt::UserRole, qVariantFromValue(fi)); - if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) { - g_free(label_ptr); - } - if (is_branch) { if (tree_expanded(fi->tree_type)) { item->setExpanded(true); @@ -157,7 +153,10 @@ ProtoTree::ProtoTree(QWidget *parent) : QAction *action; setAccessibleName(tr("Packet details")); - setUniformRowHeights(true); + // Leave the uniformRowHeights property as-is (false) since items might + // have multiple lines (e.g. packet comments). If this slows things down + // too much we should add a custom delegate which handles SizeHintRole + // similar to PacketListModel::data. setHeaderHidden(true); if (window()->findChild<QAction *>("actionViewExpandSubtrees")) { |