Qt: Set the packet list width when we apply recent column widths.

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>
This commit is contained in:
Gerald Combs 2015-12-06 12:08:52 -08:00 committed by Alexis La Goutte
parent ca9970cd27
commit 5f00849b97
1 changed files with 9 additions and 17 deletions

View 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();
}