aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-06-17 15:38:29 -0700
committerGerald Combs <gerald@wireshark.org>2014-06-17 22:39:09 +0000
commited38e69235256e4140a1c03e590e57e05c7e5ac9 (patch)
treebb6dd67ad5d7593e9ca6f3cff65cce8b5b4ce2d1 /ui
parentd5e278262939e878b432e68310b4f9a3c5081ac6 (diff)
Make sure we hide columns for live captures as well.
Remove some dependencies on having an open capture file. Change-Id: Iad5d03e0a45ed31c83781861ef1ed7fdeb92e4a5 Reviewed-on: https://code.wireshark.org/review/2352 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/packet_list.cpp15
-rw-r--r--ui/qt/packet_list_model.cpp14
2 files changed, 11 insertions, 18 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index b3a91ec02e..874ab47457 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -29,6 +29,7 @@
#include <epan/column-info.h>
#include <epan/column.h>
#include <epan/packet.h>
+#include <epan/prefs.h>
#include "packet_list.h"
#include "proto_tree.h"
@@ -80,11 +81,12 @@ packet_list_append(column_info *cinfo, frame_data *fdata)
// Copied from ui/gtk/packet_list.c
void packet_list_resize_column(gint col)
{
+ Q_UNUSED(col)
// xxx qtshark
// gint col_width;
// const gchar *long_str;
-g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: packet_list_resize_column %d", col);
+//g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: packet_list_resize_column %d", col);
// long_str = packet_list_get_widest_column_string(packetlist, col);
// if(!long_str || strcmp("",long_str)==0)
// /* If we get an empty string leave the width unchanged */
@@ -407,9 +409,7 @@ PacketListModel *PacketList::packetListModel() const {
void PacketList::showEvent (QShowEvent *event) {
Q_UNUSED(event);
- if (!cap_file_) return;
-
- for (int i = 0; i < cap_file_->cinfo.num_cols; i++) {
+ for (int i = 0; i < prefs.num_cols; i++) {
int fmt, col_width;
const char *long_str;
@@ -567,11 +567,7 @@ void PacketList::setFrameReftime(gboolean set, frame_data *fdata)
void PacketList::setColumnVisibility()
{
- if (!cap_file_) {
- return;
- }
-
- for (int i = 0; i < cap_file_->cinfo.num_cols; i++) {
+ for (int i = 0; i < prefs.num_cols; i++) {
setColumnHidden(i, get_column_visible(i) ? false : true);
}
}
@@ -618,6 +614,7 @@ void PacketList::clear() {
* Reset the sort column, use packetlist as model in case the list is frozen.
*/
sortByColumn(0, Qt::AscendingOrder);
+ setColumnVisibility();
}
void PacketList::writeRecent(FILE *rf) {
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp
index 638fa1b092..098f784648 100644
--- a/ui/qt/packet_list_model.cpp
+++ b/ui/qt/packet_list_model.cpp
@@ -55,7 +55,7 @@ QModelIndex PacketListModel::index(int row, int column, const QModelIndex &paren
{
Q_UNUSED(parent);
- if (row >= visible_rows_.count() || row < 0 || !cap_file_ || column >= cap_file_->cinfo.num_cols)
+ if (row >= visible_rows_.count() || row < 0 || !cap_file_ || column >= prefs.num_cols)
return QModelIndex();
PacketListRecord *record = visible_rows_[row];
@@ -115,9 +115,7 @@ void PacketListModel::resetColumns()
int PacketListModel::rowCount(const QModelIndex &parent) const
{
- if (!cap_file_) return 0;
-
- if (parent.column() >= cap_file_->cinfo.num_cols)
+ if (parent.column() >= prefs.num_cols)
return 0;
return visible_rows_.count();
@@ -127,9 +125,7 @@ int PacketListModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- if (!cap_file_) return 0;
-
- return cap_file_->cinfo.num_cols;
+ return prefs.num_cols;
}
QVariant PacketListModel::data(const QModelIndex &index, int role) const
@@ -203,7 +199,7 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const
int col_num = index.column();
// g_log(NULL, G_LOG_LEVEL_DEBUG, "showing col %d", col_num);
- if (!cap_file_ || col_num > cap_file_->cinfo.num_cols)
+ if (col_num > prefs.num_cols)
return QVariant();
epan_dissect_t edt;
@@ -302,7 +298,7 @@ QVariant PacketListModel::headerData(int section, Qt::Orientation orientation,
{
if (!cap_file_) return QVariant();
- if (orientation == Qt::Horizontal && section < cap_file_->cinfo.num_cols) {
+ if (orientation == Qt::Horizontal && section < prefs.num_cols) {
switch (role) {
case Qt::DisplayRole:
return cap_file_->cinfo.col_title[section];