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>
This commit is contained in:
Gerald Combs 2014-06-17 15:38:29 -07:00
parent d5e2782629
commit ed38e69235
2 changed files with 11 additions and 18 deletions

View File

@ -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) {

View File

@ -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];