aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/packet_list.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-09-22 17:18:33 -0700
committerGerald Combs <gerald@wireshark.org>2015-09-23 20:53:18 +0000
commit30ff173a8792aede0901803b2dc37948e7406df7 (patch)
tree78ca3e9392fe8fe45b5b0d0782c3342a471ed4e8 /ui/qt/packet_list.cpp
parent3ff5afd54131dc611ac08cf4f256a7c081c0cbb3 (diff)
Qt: Always make the packet list row heights uniform.
In tests here using GTK+ 2.24 and 3.10, GtkTreeView handles multi-line items by adjusting the height for all rows, but only after the number of multi-line items exceeds some sort of threshold. For a packet capture which contains a few DNS packets and a lot of TCP packets, if I change "Standard query" to "Standard\nquery" in packet-dns.c I get single-height packet list items. If I change "[TCP segment of a reassembled PDU]" to "[TCP segment of a\nreassembled PDU]" in packet-tcp.c (which results in more multi-line column strings) I get double-height packet list items. The current Qt code initially sets the uniformRowHeights property then falls back to variable row heights if we run across a multi-line column string. This adds a lot of logic which can impact other functionality (e.g. column widths) and recalculating row heights is painfully slow for large numbers of packets. Instead of trying to manage variable row heights, always enable uniformRowHeights. Track the maximum newline count and trigger a row height adjustment when it changes. This mimics the GTK+ UI behavior, although it should be more reliable. Note that we need to adjust some numbers in RelatedPacketDelegate. Change-Id: I289e963b6f00338c4374e602fa3fc83d04554519 Ping-Bug: 11515 Ping-Bug: 10924 Reviewed-on: https://code.wireshark.org/review/10628 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/packet_list.cpp')
-rw-r--r--ui/qt/packet_list.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 1407390bc6..328c609f1b 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -256,6 +256,7 @@ PacketList::PacketList(QWidget *parent) :
setItemsExpandable(false);
setRootIsDecorated(false);
setSortingEnabled(true);
+ setUniformRowHeights(true);
setAccessibleName("Packet list");
setItemDelegateForColumn(0, &related_packet_delegate_);
@@ -375,8 +376,8 @@ PacketList::PacketList(QWidget *parent) :
g_assert(gbl_cur_packet_list == NULL);
gbl_cur_packet_list = this;
- connect(packet_list_model_, SIGNAL(rowHeightsVary()), this, SLOT(rowHeightsVary()));
connect(packet_list_model_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int)));
+ connect(packet_list_model_, SIGNAL(itemHeightChanged(const QModelIndex&)), this, SLOT(updateRowHeights(const QModelIndex&)));
connect(wsApp, SIGNAL(addressResolutionChanged()), this, SLOT(redrawVisiblePackets()));
header()->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -574,9 +575,7 @@ int PacketList::sizeHintForColumn(int column) const
// on OS X and Linux. We might want to add Q_OS_... #ifdefs accordingly.
size_hint = itemDelegateForColumn(column)->sizeHint(viewOptions(), QModelIndex()).width();
}
- packet_list_model_->setSizeHintEnabled(false);
size_hint += QTreeView::sizeHintForColumn(column); // Decoration padding
- packet_list_model_->setSizeHintEnabled(true);
return size_hint;
}
@@ -775,7 +774,6 @@ void PacketList::clear() {
create_near_overlay_ = true;
create_far_overlay_ = true;
- setUniformRowHeights(true);
setColumnVisibility();
}
@@ -963,12 +961,6 @@ void PacketList::setMonospaceFont(const QFont &mono_font)
{
setFont(mono_font);
header()->setFont(wsApp->font());
-
- // qtreeview.cpp does something similar in Qt 5 so this *should* be
- // safe...
- int row_height = itemDelegate()->sizeHint(viewOptions(), QModelIndex()).height();
- packet_list_model_->setMonospaceFont(mono_font, row_height);
- redrawVisiblePackets();
}
void PacketList::goNextPacket(void) {
@@ -1237,12 +1229,20 @@ void PacketList::sectionMoved(int, int, int)
wsApp->emitAppSignal(WiresharkApplication::ColumnsChanged);
}
-void PacketList::rowHeightsVary()
+void PacketList::updateRowHeights(const QModelIndex &ih_index)
{
- // This impairs performance considerably for large numbers of packets.
- // We should probably move a bunch of the code in ::data to
- // RelatedPacketDelegate and make it the delegate for everything.
- setUniformRowHeights(false);
+ QStyleOptionViewItem option = viewOptions();
+ int max_height = 0;
+
+ // One of our columns increased the maximum row height. Find out which one.
+ for (int col = 0; col < packet_list_model_->columnCount(); col++) {
+ QSize size_hint = itemDelegate()->sizeHint(option, packet_list_model_->index(ih_index.row(), col));
+ max_height = qMax(max_height, size_hint.height());
+ }
+
+ if (max_height > 0) {
+ packet_list_model_->setMaximiumRowHeight(max_height);
+ }
}
void PacketList::copySummary()