aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-12-02 17:51:00 -0800
committerAnders Broman <a.broman58@gmail.com>2015-12-03 05:17:19 +0000
commitbdf8034fb1a4dc33cf87f67ecf6e4c2c6cfb08be (patch)
treecdb73368937011e21db3a4c36d9a9f84b6df5fae /ui
parente78093f69f1e95df919bbe644baa06c7e4e720c0 (diff)
Qt: Disable setStretchLastSection in the packet list.
QTreeView sets the stretchLastSection property of its header by default. In our case this means that if the sum of our recent column widths exceeds the width of the packet list viewport QHeaderView will shrink the last column to fit. Disable setStretchLastSection. We want its behavior when our columns are too narrow so check for that in ::showEvent and temporarily enable it there. Bug: 11738 Change-Id: Ia4aad63e4f4bf899891bcebb7032dc5ebeb74cc7 Reviewed-on: https://code.wireshark.org/review/12392 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/packet_list.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index a2f565505d..b1b665fc3b 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -262,6 +262,8 @@ PacketList::PacketList(QWidget *parent) :
setUniformRowHeights(true);
setAccessibleName("Packet list");
+ header()->setStretchLastSection(false);
+
overlay_sb_ = new OverlayScrollBar(Qt::Vertical, this);
setVerticalScrollBar(overlay_sb_);
@@ -430,6 +432,17 @@ PacketListModel *PacketList::packetListModel() const {
void PacketList::showEvent (QShowEvent *) {
setColumnVisibility();
+
+ int column_width = 0;
+ for (int col = 0; col < packet_list_model_->columnCount(); col++) {
+ column_width += columnWidth(col);
+ }
+
+ if (column_width < viewport()->width()) {
+ header()->setStretchLastSection(true);
+ applyRecentColumnWidths();
+ header()->setStretchLastSection(false);
+ }
}
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) {
@@ -703,11 +716,16 @@ void PacketList::fieldsChanged(capture_file *cf)
// Called via recentFilesRead.
void PacketList::applyRecentColumnWidths()
{
+// bool saved_stretch = header()->stretchLastSection();
+// header()->setStretchLastSection(false);
+
// Either we've just started up or a profile has changed. Read
// the recent settings, apply them, and save the header state.
for (int col = 0; col < prefs.num_cols; col++) {
setRecentColumnWidth(col);
}
+
+// header()->setStretchLastSection(saved_stretch);
column_state_ = header()->saveState();
}