summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-11-26 19:15:44 +0100
committerAnders Broman <a.broman58@gmail.com>2015-11-27 05:30:22 +0000
commit036c404e6d82762c4c6d26159d34dde8bf6fa349 (patch)
tree9de40238f7eb3e53df5db4cb8df38ddaf98354c2
parent5eb60c0582f3ada89a636eb494f3e6d8fc04babd (diff)
downloadwireshark-036c404e6d82762c4c6d26159d34dde8bf6fa349.tar.gz
Qt: Check zero recent column width
Hidden columns may have been stored with zero width, so ensure we always check for this when fetching. Change-Id: I625c05adccaf2d81198fdeeccf7feeb9a9eb82c2 Reviewed-on: https://code.wireshark.org/review/12196 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> (cherry picked from commit f5b816d4c92e633453fe65dfa56d80ad32bab477) Reviewed-on: https://code.wireshark.org/review/12217
-rw-r--r--ui/qt/packet_list.cpp49
-rw-r--r--ui/qt/packet_list.h1
2 files changed, 28 insertions, 22 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 89cb4b3214..4c0ec0bdda 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -582,6 +582,30 @@ int PacketList::sizeHintForColumn(int column) const
return size_hint;
}
+void PacketList::setRecentColumnWidth(int col)
+{
+ int col_width = recent_get_column_width(col);
+
+ if (col_width < 1) {
+ int fmt = get_column_format(col);
+ const char *long_str = get_column_width_string(fmt, col);
+
+ QFontMetrics fm = QFontMetrics(wsApp->monospaceFont());
+ if (long_str) {
+ col_width = fm.width(long_str);
+ } else {
+ col_width = fm.width(MIN_COL_WIDTH_STR);
+ }
+
+ // Custom delegate padding
+ if (itemDelegateForColumn(col)) {
+ col_width += itemDelegateForColumn(col)->sizeHint(viewOptions(), QModelIndex()).width();
+ }
+ }
+
+ setColumnWidth(col, col_width);
+}
+
void PacketList::initHeaderContextMenu()
{
header_ctx_menu_.clear();
@@ -674,27 +698,8 @@ void PacketList::applyRecentColumnWidths()
{
// Either we've just started up or a profile has changed. Read
// the recent settings, apply them, and save the header state.
- QFontMetrics fm = QFontMetrics(wsApp->monospaceFont());
- for (int i = 0; i < prefs.num_cols; i++) {
- int col_width = recent_get_column_width(i);
-
- if (col_width < 1) {
- int fmt;
- const char *long_str;
-
- fmt = get_column_format(i);
- long_str = get_column_width_string(fmt, i);
- if (long_str) {
- col_width = fm.width(long_str);
- } else {
- col_width = fm.width(MIN_COL_WIDTH_STR);
- }
- // Custom delegate padding
- if (itemDelegateForColumn(i)) {
- col_width += itemDelegateForColumn(i)->sizeHint(viewOptions(), QModelIndex()).width();
- }
- }
- setColumnWidth(i, col_width) ;
+ for (int col = 0; col < prefs.num_cols; col++) {
+ setRecentColumnWidth(col);
}
column_state_ = header()->saveState();
}
@@ -1232,7 +1237,7 @@ void PacketList::columnVisibilityTriggered()
set_column_visible(col, ha->isChecked());
setColumnVisibility();
if (ha->isChecked()) {
- setColumnWidth(col, recent_get_column_width(col));
+ setRecentColumnWidth(col);
}
if (!prefs.gui_use_pref_save) {
prefs_main_write();
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index f4e6217088..f0786a5ecc 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -122,6 +122,7 @@ private:
void setFrameReftime(gboolean set, frame_data *fdata);
void setColumnVisibility();
int sizeHintForColumn(int column) const;
+ void setRecentColumnWidth(int column);
void initHeaderContextMenu();
void drawCurrentPacket();