Qt: Set the packet list width when we apply recent column widths.
authorGerald Combs <gerald@zing.org>
Sun, 6 Dec 2015 20:08:52 +0000 (12:08 -0800)
committerAlexis La Goutte <alexis.lagoutte@gmail.com>
Mon, 7 Dec 2015 13:58:18 +0000 (13:58 +0000)
Instead of messing with stretchLastSection, simply widen the packet list
to the sum of our column widths. Do this whenever recent column widths
are applied instead of only when the packet list is shown.

Bug: 11849
Ping-Bug: 11738
Change-Id: If8f8c9a89da08387bbce38c663bbbe1d8f7e649a
Reviewed-on: https://code.wireshark.org/review/12455
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
ui/qt/packet_list.cpp

index b1b665fc3b77b567620379f9016f94e16c991772..0e409019e74bd63d788a4cae7dd6ea38c9e0dc0a 100644 (file)
@@ -262,8 +262,6 @@ PacketList::PacketList(QWidget *parent) :
     setUniformRowHeights(true);
     setAccessibleName("Packet list");
 
-    header()->setStretchLastSection(false);
-
     overlay_sb_ = new OverlayScrollBar(Qt::Vertical, this);
     setVerticalScrollBar(overlay_sb_);
 
@@ -432,17 +430,6 @@ 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) {
@@ -712,20 +699,25 @@ void PacketList::fieldsChanged(capture_file *cf)
 // - Persist across freezes and thaws.
 // - Persist across file closing and opening.
 // - Save to recent when we save our profile (including shutting down).
+// - Not be affected by the behavior of stretchLastSection.
 
 // 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.
+
+    int column_width = 0;
+
     for (int col = 0; col < prefs.num_cols; col++) {
         setRecentColumnWidth(col);
+        column_width += columnWidth(col);
+    }
+
+    if (column_width > width()) {
+        resize(column_width, height());
     }
 
-//    header()->setStretchLastSection(saved_stretch);
     column_state_ = header()->saveState();
 }