2012-01-04 22:13:01 +00:00
|
|
|
/* packet_list.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
#include "packet_list.h"
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2015-02-12 23:35:59 +00:00
|
|
|
#include "file.h"
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
#include <epan/epan.h>
|
|
|
|
#include <epan/epan_dissect.h>
|
|
|
|
|
2013-10-18 13:06:05 +00:00
|
|
|
#include <epan/column-info.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
#include <epan/column.h>
|
2015-06-11 22:53:51 +00:00
|
|
|
#include <epan/ipproto.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
#include <epan/packet.h>
|
2014-06-17 22:38:29 +00:00
|
|
|
#include <epan/prefs.h>
|
2016-02-23 08:30:48 +00:00
|
|
|
#include <epan/proto.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-01-16 01:18:56 +00:00
|
|
|
#include "ui/main_statusbar.h"
|
2015-01-01 19:41:03 +00:00
|
|
|
#include "ui/packet_list_utils.h"
|
|
|
|
#include "ui/preference_utils.h"
|
2012-01-18 19:59:13 +00:00
|
|
|
#include "ui/recent.h"
|
2012-08-23 17:29:05 +00:00
|
|
|
#include "ui/recent_utils.h"
|
2012-01-16 01:18:56 +00:00
|
|
|
#include "ui/ui_util.h"
|
2015-10-04 17:10:29 +00:00
|
|
|
#include <wsutil/utf8_entities.h>
|
2015-06-11 22:53:51 +00:00
|
|
|
#include "ui/util.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-12-23 04:37:58 +00:00
|
|
|
#include "wsutil/str_util.h"
|
|
|
|
|
2015-12-22 20:07:00 +00:00
|
|
|
#include <epan/color_filters.h>
|
2013-07-11 05:47:02 +00:00
|
|
|
#include "frame_tvbuff.h"
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
#include "color_utils.h"
|
|
|
|
#include "overlay_scroll_bar.h"
|
|
|
|
#include "proto_tree.h"
|
|
|
|
#include "qt_ui_utils.h"
|
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
#include <QAction>
|
|
|
|
#include <QActionGroup>
|
2015-07-29 23:24:39 +00:00
|
|
|
#include <QClipboard>
|
2012-12-07 01:46:20 +00:00
|
|
|
#include <QContextMenuEvent>
|
2015-06-11 22:53:51 +00:00
|
|
|
#include <QtCore/qmath.h>
|
|
|
|
#include <QElapsedTimer>
|
2015-03-27 23:49:39 +00:00
|
|
|
#include <QFontMetrics>
|
2014-10-05 19:23:33 +00:00
|
|
|
#include <QHeaderView>
|
2012-12-17 23:03:21 +00:00
|
|
|
#include <QMessageBox>
|
2015-06-11 22:53:51 +00:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QScreen>
|
2014-10-05 19:23:33 +00:00
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTextEdit>
|
2015-02-20 14:30:23 +00:00
|
|
|
#include <QTimerEvent>
|
2014-10-05 19:23:33 +00:00
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2016-06-10 18:16:10 +00:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#include "wsutil/file_util.h"
|
|
|
|
#include <QSysInfo>
|
|
|
|
#endif
|
|
|
|
|
2014-10-05 19:23:33 +00:00
|
|
|
// To do:
|
2015-07-23 19:53:45 +00:00
|
|
|
// - Fix "apply as filter" behavior.
|
|
|
|
// - Add colorize conversation.
|
2015-02-20 14:30:23 +00:00
|
|
|
// - Use a timer to trigger automatic scrolling.
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
// If we ever add the ability to open multiple capture files we might be
|
|
|
|
// able to use something like QMap<capture_file *, PacketList *> to match
|
|
|
|
// capture files against packet lists and models.
|
2012-08-23 17:29:05 +00:00
|
|
|
static PacketList *gbl_cur_packet_list = NULL;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-12-23 04:37:58 +00:00
|
|
|
const int max_comments_to_fetch_ = 20000000; // Arbitrary
|
2015-02-20 14:30:23 +00:00
|
|
|
const int tail_update_interval_ = 100; // Milliseconds.
|
2015-06-11 22:53:51 +00:00
|
|
|
const int overlay_update_interval_ = 100; // 250; // Milliseconds.
|
2012-12-23 04:37:58 +00:00
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
guint
|
2015-07-07 06:24:50 +00:00
|
|
|
packet_list_append(column_info *, frame_data *fdata)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-01-04 22:13:01 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* fdata should be filled with the stuff we need
|
|
|
|
* strings are built at display time.
|
|
|
|
*/
|
|
|
|
guint visible_pos;
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
visible_pos = gbl_cur_packet_list->packetListModel()->appendPacket(fdata);
|
2012-01-04 22:13:01 +00:00
|
|
|
return visible_pos;
|
|
|
|
}
|
|
|
|
|
2012-09-04 01:57:36 +00:00
|
|
|
// Copied from ui/gtk/packet_list.c
|
2012-09-04 02:35:25 +00:00
|
|
|
void packet_list_resize_column(gint col)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-02-19 01:18:27 +00:00
|
|
|
if (!gbl_cur_packet_list) return;
|
|
|
|
gbl_cur_packet_list->resizeColumnToContents(col);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_first_row(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-08-13 01:50:14 +00:00
|
|
|
return;
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->goFirstPacket();
|
|
|
|
gbl_cur_packet_list->setFocus();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_last_row(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-08-13 01:50:14 +00:00
|
|
|
return;
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->goLastPacket();
|
|
|
|
gbl_cur_packet_list->setFocus();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a frame_data structure, scroll to and select the row in the
|
|
|
|
* packet list corresponding to that frame. If there is no such
|
|
|
|
* row, return FALSE, otherwise return TRUE.
|
|
|
|
*/
|
|
|
|
gboolean
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_row_from_data(frame_data *fdata_needle)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-09-18 16:48:09 +00:00
|
|
|
gbl_cur_packet_list->packetListModel()->flushVisibleRows();
|
2012-08-23 17:29:05 +00:00
|
|
|
int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle);
|
2012-01-04 22:13:01 +00:00
|
|
|
if (row >= 0) {
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row,0));
|
2012-01-04 22:13:01 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_check_end(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-02-20 14:30:23 +00:00
|
|
|
return FALSE; // GTK+ only.
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_clear(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
gbl_cur_packet_list->clear();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-07-07 06:24:50 +00:00
|
|
|
packet_list_enable_color(gboolean)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-07-12 19:56:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
gbl_cur_packet_list->recolorPackets();
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_freeze(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
2013-11-15 20:24:56 +00:00
|
|
|
gbl_cur_packet_list->freeze();
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_thaw(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
2013-11-15 20:24:56 +00:00
|
|
|
gbl_cur_packet_list->thaw();
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
packets_bar_update();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recreate_visible_rows(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list && gbl_cur_packet_list->packetListModel()) {
|
|
|
|
gbl_cur_packet_list->packetListModel()->recreateVisibleRows();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
frame_data *
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_get_row_data(gint row)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list && gbl_cur_packet_list->packetListModel()) {
|
|
|
|
return gbl_cur_packet_list->packetListModel()->getRowFdata(row);
|
|
|
|
}
|
|
|
|
return NULL;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 20:16:46 +00:00
|
|
|
// Called from cf_continue_tail and cf_finish_tail when auto_scroll_live
|
|
|
|
// is enabled.
|
2012-01-04 22:13:01 +00:00
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_moveto_end(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-03-06 20:16:46 +00:00
|
|
|
// gbl_cur_packet_list->scrollToBottom();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw the packet list *and* currently-selected detail */
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_queue_draw(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list)
|
2014-10-21 20:36:10 +00:00
|
|
|
gbl_cur_packet_list->redrawVisiblePackets();
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recent_write_all(FILE *rf) {
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
|
|
|
return;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->writeRecent(rf);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
#define MIN_COL_WIDTH_STR "MMMMMM"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-01-26 07:46:34 +00:00
|
|
|
Q_DECLARE_METATYPE(PacketList::ColumnActions)
|
2015-01-01 19:41:03 +00:00
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
enum copy_summary_type {
|
|
|
|
copy_summary_text_,
|
|
|
|
copy_summary_csv_,
|
|
|
|
copy_summary_yaml_
|
|
|
|
};
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
PacketList::PacketList(QWidget *parent) :
|
2012-10-30 19:21:24 +00:00
|
|
|
QTreeView(parent),
|
|
|
|
proto_tree_(NULL),
|
|
|
|
byte_view_tab_(NULL),
|
2012-12-07 20:08:00 +00:00
|
|
|
cap_file_(NULL),
|
2013-12-10 21:07:26 +00:00
|
|
|
decode_as_(NULL),
|
2015-02-20 14:30:23 +00:00
|
|
|
ctx_column_(-1),
|
2015-10-27 22:04:44 +00:00
|
|
|
overlay_timer_id_(0),
|
2015-06-11 22:53:51 +00:00
|
|
|
create_near_overlay_(true),
|
|
|
|
create_far_overlay_(true),
|
2015-02-20 14:30:23 +00:00
|
|
|
capture_in_progress_(false),
|
2015-03-07 12:30:46 +00:00
|
|
|
tail_timer_id_(0),
|
2015-11-23 13:06:59 +00:00
|
|
|
rows_inserted_(false),
|
2015-11-24 19:42:50 +00:00
|
|
|
columns_changed_(false),
|
|
|
|
set_column_visibility_(false)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2015-07-29 23:24:39 +00:00
|
|
|
QMenu *main_menu_item, *submenu;
|
2013-12-21 16:55:43 +00:00
|
|
|
QAction *action;
|
2012-12-07 20:08:00 +00:00
|
|
|
|
2014-10-05 19:23:33 +00:00
|
|
|
setItemsExpandable(false);
|
|
|
|
setRootIsDecorated(false);
|
|
|
|
setSortingEnabled(true);
|
2015-09-23 00:18:33 +00:00
|
|
|
setUniformRowHeights(true);
|
2012-01-04 22:13:01 +00:00
|
|
|
setAccessibleName("Packet list");
|
2012-12-07 20:08:00 +00:00
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
overlay_sb_ = new OverlayScrollBar(Qt::Vertical, this);
|
|
|
|
setVerticalScrollBar(overlay_sb_);
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
packet_list_model_ = new PacketListModel(this, cap_file_);
|
2012-08-19 23:52:08 +00:00
|
|
|
setModel(packet_list_model_);
|
2014-10-05 19:23:33 +00:00
|
|
|
sortByColumn(-1, Qt::AscendingOrder);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2013-10-14 16:54:41 +00:00
|
|
|
// XXX We might want to reimplement setParent() and fill in the context
|
|
|
|
// menu there.
|
2012-12-17 23:03:21 +00:00
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditMarkPacket"));
|
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket"));
|
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference"));
|
2012-12-21 19:21:34 +00:00
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditTimeShift"));
|
2012-12-23 04:37:58 +00:00
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditPacketComment"));
|
|
|
|
|
2013-09-09 19:30:30 +00:00
|
|
|
ctx_menu_.addSeparator();
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2015-07-21 16:51:12 +00:00
|
|
|
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewEditResolvedName"));
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
|
2015-07-27 22:28:50 +00:00
|
|
|
main_menu_item = window()->findChild<QMenu *>("menuApplyAsFilter");
|
|
|
|
submenu = new QMenu(main_menu_item->title());
|
2015-07-23 19:53:45 +00:00
|
|
|
ctx_menu_.addMenu(submenu);
|
2012-12-07 20:08:00 +00:00
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected"));
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2015-07-27 22:28:50 +00:00
|
|
|
main_menu_item = window()->findChild<QMenu *>("menuPrepareAFilter");
|
|
|
|
submenu = new QMenu(main_menu_item->title());
|
2015-07-23 19:53:45 +00:00
|
|
|
ctx_menu_.addMenu(submenu);
|
2012-12-07 20:08:00 +00:00
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrNotSelected"));
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2015-07-29 19:09:28 +00:00
|
|
|
const char *conv_menu_name = "menuConversationFilter";
|
|
|
|
main_menu_item = window()->findChild<QMenu *>(conv_menu_name);
|
|
|
|
conv_menu_.setTitle(main_menu_item->title());
|
|
|
|
conv_menu_.setObjectName(conv_menu_name);
|
2014-08-08 10:59:42 +00:00
|
|
|
ctx_menu_.addMenu(&conv_menu_);
|
|
|
|
|
2015-07-29 19:09:28 +00:00
|
|
|
const char *colorize_menu_name = "menuColorizeConversation";
|
|
|
|
main_menu_item = window()->findChild<QMenu *>(colorize_menu_name);
|
|
|
|
colorize_menu_.setTitle(main_menu_item->title());
|
|
|
|
colorize_menu_.setObjectName(colorize_menu_name);
|
|
|
|
ctx_menu_.addMenu(&colorize_menu_);
|
|
|
|
|
|
|
|
main_menu_item = window()->findChild<QMenu *>("menuSCTP");
|
|
|
|
submenu = new QMenu(main_menu_item->title());
|
|
|
|
ctx_menu_.addMenu(submenu);
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionSCTPAnalyseThisAssociation"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionSCTPShowAllAssociations"));
|
2015-07-30 20:55:46 +00:00
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionSCTPFilterThisAssociation"));
|
|
|
|
|
|
|
|
main_menu_item = window()->findChild<QMenu *>("menuFollow");
|
|
|
|
submenu = new QMenu(main_menu_item->title());
|
|
|
|
ctx_menu_.addMenu(submenu);
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowSSLStream"));
|
2016-01-02 13:58:08 +00:00
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowHTTPStream"));
|
2015-07-29 19:09:28 +00:00
|
|
|
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_menu_.addSeparator();
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
main_menu_item = window()->findChild<QMenu *>("menuEditCopy");
|
|
|
|
submenu = new QMenu(main_menu_item->title());
|
2015-07-23 19:53:45 +00:00
|
|
|
ctx_menu_.addMenu(submenu);
|
2015-07-29 23:24:39 +00:00
|
|
|
|
2015-07-30 19:34:53 +00:00
|
|
|
action = submenu->addAction(tr("Summary as Text"));
|
2015-07-29 23:24:39 +00:00
|
|
|
action->setData(copy_summary_text_);
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(copySummary()));
|
2015-07-31 19:21:28 +00:00
|
|
|
action = submenu->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as CSV"));
|
2015-07-29 23:24:39 +00:00
|
|
|
action->setData(copy_summary_csv_);
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(copySummary()));
|
2015-07-31 19:21:28 +00:00
|
|
|
action = submenu->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as YAML"));
|
2015-07-29 23:24:39 +00:00
|
|
|
action->setData(copy_summary_yaml_);
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(copySummary()));
|
2012-12-07 20:08:00 +00:00
|
|
|
submenu->addSeparator();
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2015-07-30 19:23:03 +00:00
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionEditCopyAsFilter"));
|
|
|
|
submenu->addSeparator();
|
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesHexTextDump");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesHexDump");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesPrintableText");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesHexStream");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesBinary");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
2016-09-14 03:33:54 +00:00
|
|
|
action = window()->findChild<QAction *>("actionContextCopyBytesEscapedString");
|
|
|
|
submenu->addAction(action);
|
|
|
|
copy_actions_ << action;
|
2015-07-23 19:53:45 +00:00
|
|
|
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_menu_.addSeparator();
|
2015-06-17 00:24:19 +00:00
|
|
|
ctx_menu_.addMenu(&proto_prefs_menu_);
|
2013-12-10 21:07:26 +00:00
|
|
|
decode_as_ = window()->findChild<QAction *>("actionAnalyzeDecodeAs");
|
|
|
|
ctx_menu_.addAction(decode_as_);
|
2015-02-11 23:00:27 +00:00
|
|
|
// "Print" not ported intentionally
|
|
|
|
action = window()->findChild<QAction *>("actionViewShowPacketInNewWindow");
|
|
|
|
ctx_menu_.addAction(action);
|
2012-12-07 20:08:00 +00:00
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
initHeaderContextMenu();
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
g_assert(gbl_cur_packet_list == NULL);
|
|
|
|
gbl_cur_packet_list = this;
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2016-06-10 18:16:10 +00:00
|
|
|
bool style_inactive_selected = true;
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN // && Qt version >= 4.8.6
|
2016-06-13 18:17:48 +00:00
|
|
|
if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8) {
|
2016-06-10 18:16:10 +00:00
|
|
|
// See if we're running Vista or 7 and we have a theme applied.
|
|
|
|
HMODULE uxtheme_lib = (HMODULE) ws_load_library("uxtheme.dll");
|
|
|
|
|
|
|
|
if (uxtheme_lib) {
|
|
|
|
typedef BOOL (WINAPI *IsAppThemedHandler)(void);
|
|
|
|
typedef BOOL (WINAPI *IsThemeActiveHandler)(void);
|
|
|
|
|
|
|
|
IsAppThemedHandler PIsAppThemed = (IsAppThemedHandler) GetProcAddress(uxtheme_lib, "IsAppThemed");
|
|
|
|
IsThemeActiveHandler PIsThemeActive = (IsThemeActiveHandler) GetProcAddress(uxtheme_lib, "IsThemeActive");
|
|
|
|
if (PIsAppThemed && PIsAppThemed() && PIsThemeActive && PIsThemeActive()) {
|
|
|
|
style_inactive_selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (style_inactive_selected) {
|
|
|
|
// XXX Style the protocol tree as well?
|
|
|
|
QPalette inactive_pal = palette();
|
|
|
|
inactive_pal.setCurrentColorGroup(QPalette::Inactive);
|
|
|
|
QColor border = QColor::fromRgb(ColorUtils::alphaBlend(
|
|
|
|
inactive_pal.highlightedText(),
|
|
|
|
inactive_pal.highlight(),
|
|
|
|
0.25));
|
|
|
|
QColor shadow = QColor::fromRgb(ColorUtils::alphaBlend(
|
|
|
|
inactive_pal.highlightedText(),
|
|
|
|
inactive_pal.highlight(),
|
|
|
|
0.07));
|
|
|
|
setStyleSheet(QString(
|
|
|
|
"QTreeView::item:selected:first:!active {"
|
|
|
|
" border-left: 1px solid %1;"
|
|
|
|
"}"
|
|
|
|
"QTreeView::item:selected:last:!active {"
|
|
|
|
" border-right: 1px solid %1;"
|
|
|
|
"}"
|
|
|
|
"QTreeView::item:selected:!active {"
|
|
|
|
" border-top: 1px solid %1;"
|
|
|
|
" border-bottom: 1px solid %1;"
|
|
|
|
" color: %2;"
|
|
|
|
// Try to approximate a subtle box shadow.
|
|
|
|
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1"
|
|
|
|
" stop: 0 %4, stop: 0.2 %3, stop: 0.8 %3, stop: 1 %4);"
|
|
|
|
"}")
|
|
|
|
.arg(border.name())
|
|
|
|
.arg(inactive_pal.highlightedText().color().name())
|
|
|
|
.arg(inactive_pal.highlight().color().name())
|
|
|
|
.arg(shadow.name())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-05 19:23:33 +00:00
|
|
|
connect(packet_list_model_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int)));
|
2015-09-23 00:18:33 +00:00
|
|
|
connect(packet_list_model_, SIGNAL(itemHeightChanged(const QModelIndex&)), this, SLOT(updateRowHeights(const QModelIndex&)));
|
2014-10-21 20:36:10 +00:00
|
|
|
connect(wsApp, SIGNAL(addressResolutionChanged()), this, SLOT(redrawVisiblePackets()));
|
2015-02-19 01:18:27 +00:00
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(header(), SIGNAL(customContextMenuRequested(QPoint)),
|
2015-05-13 22:46:51 +00:00
|
|
|
this, SLOT(showHeaderMenu(QPoint)));
|
|
|
|
connect(header(), SIGNAL(sectionResized(int,int,int)),
|
|
|
|
this, SLOT(sectionResized(int,int,int)));
|
2015-07-09 23:47:11 +00:00
|
|
|
connect(header(), SIGNAL(sectionMoved(int,int,int)),
|
|
|
|
this, SLOT(sectionMoved(int,int,int)));
|
2015-02-20 14:30:23 +00:00
|
|
|
|
|
|
|
connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vScrollBarActionTriggered(int)));
|
2015-06-17 00:24:19 +00:00
|
|
|
|
|
|
|
connect(&proto_prefs_menu_, SIGNAL(showProtocolPreferences(QString)),
|
|
|
|
this, SIGNAL(showProtocolPreferences(QString)));
|
2015-06-17 15:41:41 +00:00
|
|
|
connect(&proto_prefs_menu_, SIGNAL(editProtocolPreference(preference*,pref_module*)),
|
|
|
|
this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 12:30:06 +00:00
|
|
|
void PacketList::drawRow (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QTreeView::drawRow(painter, option, index);
|
|
|
|
|
|
|
|
if (prefs.gui_qt_packet_list_separator) {
|
|
|
|
QRect rect = visualRect(index);
|
|
|
|
|
|
|
|
painter->setPen(QColor(Qt::white));
|
|
|
|
painter->drawLine(0, rect.y() + rect.height() - 1, width(), rect.y() + rect.height() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 02:59:31 +00:00
|
|
|
void PacketList::setProtoTree (ProtoTree *proto_tree) {
|
|
|
|
proto_tree_ = proto_tree;
|
2012-08-19 23:52:08 +00:00
|
|
|
|
2015-02-13 16:36:53 +00:00
|
|
|
connect(proto_tree_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int)));
|
2015-02-24 01:56:14 +00:00
|
|
|
connect(proto_tree_, SIGNAL(relatedFrame(int,ft_framenum_type_t)),
|
|
|
|
&related_packet_delegate_, SLOT(addRelatedFrame(int,ft_framenum_type_t)));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 02:59:31 +00:00
|
|
|
void PacketList::setByteViewTab (ByteViewTab *byte_view_tab) {
|
|
|
|
byte_view_tab_ = byte_view_tab;
|
2012-11-06 23:20:07 +00:00
|
|
|
|
|
|
|
connect(proto_tree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
|
|
|
byte_view_tab_, SLOT(protoTreeItemChanged(QTreeWidgetItem*)));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketListModel *PacketList::packetListModel() const {
|
2012-08-19 23:52:08 +00:00
|
|
|
return packet_list_model_;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:18:27 +00:00
|
|
|
void PacketList::showEvent (QShowEvent *) {
|
2014-06-16 23:54:57 +00:00
|
|
|
setColumnVisibility();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) {
|
|
|
|
QTreeView::selectionChanged(selected, deselected);
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
if (!cap_file_) return;
|
|
|
|
|
2015-05-15 16:04:02 +00:00
|
|
|
if (selected.isEmpty()) {
|
|
|
|
cf_unselect_packet(cap_file_);
|
|
|
|
} else {
|
|
|
|
int row = selected.first().top();
|
|
|
|
cf_select_packet(cap_file_, row);
|
|
|
|
}
|
|
|
|
|
2013-07-08 16:54:18 +00:00
|
|
|
related_packet_delegate_.clear();
|
2015-05-15 16:04:02 +00:00
|
|
|
if (proto_tree_) proto_tree_->clear();
|
|
|
|
if (byte_view_tab_) byte_view_tab_->clear();
|
|
|
|
|
2013-11-22 17:59:15 +00:00
|
|
|
emit packetSelectionChanged();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-05-15 16:04:02 +00:00
|
|
|
if (!cap_file_->edt) {
|
|
|
|
viewport()->update();
|
|
|
|
return;
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2013-07-08 16:54:18 +00:00
|
|
|
if (proto_tree_ && cap_file_->edt->tree) {
|
|
|
|
packet_info *pi = &cap_file_->edt->pi;
|
2016-01-24 03:40:51 +00:00
|
|
|
related_packet_delegate_.setCurrentFrame(pi->num);
|
2015-02-24 01:56:14 +00:00
|
|
|
proto_tree_->fillProtocolTree(cap_file_->edt->tree);
|
2016-01-24 03:40:51 +00:00
|
|
|
conversation_t *conv = find_conversation(pi->num, &pi->src, &pi->dst, pi->ptype,
|
2013-07-08 16:54:18 +00:00
|
|
|
pi->srcport, pi->destport, 0);
|
|
|
|
if (conv) {
|
2015-02-24 01:56:14 +00:00
|
|
|
related_packet_delegate_.setConversation(conv);
|
2013-07-08 16:54:18 +00:00
|
|
|
}
|
|
|
|
viewport()->update();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 16:54:18 +00:00
|
|
|
if (byte_view_tab_) {
|
2012-01-04 22:13:01 +00:00
|
|
|
GSList *src_le;
|
2012-10-20 19:54:56 +00:00
|
|
|
struct data_source *source;
|
2015-01-18 02:17:24 +00:00
|
|
|
char* source_name;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
|
2012-10-20 19:54:56 +00:00
|
|
|
source = (struct data_source *)src_le->data;
|
2015-01-18 02:17:24 +00:00
|
|
|
source_name = get_data_source_name(source);
|
2015-11-27 10:34:51 +00:00
|
|
|
byte_view_tab_->addTab(source_name, get_data_source_tvb(source), cap_file_->edt->tree, proto_tree_, (packet_char_enc)cap_file_->current_frame->flags.encoding);
|
2015-01-18 02:17:24 +00:00
|
|
|
wmem_free(NULL, source_name);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
2012-11-06 21:49:16 +00:00
|
|
|
byte_view_tab_->setCurrentIndex(0);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
2016-02-23 08:30:48 +00:00
|
|
|
|
|
|
|
if (cap_file_->search_in_progress &&
|
|
|
|
(cap_file_->search_pos != 0 || (cap_file_->string && cap_file_->decode_data)))
|
|
|
|
{
|
|
|
|
match_data mdata;
|
|
|
|
field_info *fi = NULL;
|
|
|
|
|
|
|
|
if (cap_file_->string && cap_file_->decode_data) {
|
|
|
|
// The tree where the target string matched one of the labels was discarded in
|
|
|
|
// match_protocol_tree() so we have to search again in the latest tree.
|
|
|
|
if (cf_find_string_protocol_tree(cap_file_, cap_file_->edt->tree, &mdata)) {
|
|
|
|
fi = mdata.finfo;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Find the finfo that corresponds to our byte.
|
|
|
|
fi = proto_find_field_from_offset(cap_file_->edt->tree, cap_file_->search_pos,
|
|
|
|
cap_file_->edt->tvb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fi && proto_tree_) {
|
|
|
|
proto_tree_->selectField(fi);
|
|
|
|
}
|
2016-04-06 16:27:05 +00:00
|
|
|
} else if (!cap_file_->search_in_progress && proto_tree_) {
|
2016-03-29 22:47:12 +00:00
|
|
|
proto_tree_->restoreSelectedField();
|
2016-02-23 08:30:48 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
void PacketList::contextMenuEvent(QContextMenuEvent *event)
|
|
|
|
{
|
2015-06-17 00:24:19 +00:00
|
|
|
const char *module_name = NULL;
|
|
|
|
if (cap_file_ && cap_file_->edt && cap_file_->edt->tree) {
|
|
|
|
GPtrArray *finfo_array = proto_all_finfos(cap_file_->edt->tree);
|
|
|
|
|
|
|
|
for (guint i = finfo_array->len - 1; i > 0 ; i --) {
|
|
|
|
field_info *fi = (field_info *)g_ptr_array_index (finfo_array, i);
|
|
|
|
header_field_info *hfinfo = fi->hfinfo;
|
|
|
|
|
|
|
|
if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
|
|
|
|
!g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
|
|
|
|
!g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {
|
|
|
|
|
|
|
|
if (hfinfo->parent == -1) {
|
|
|
|
module_name = hfinfo->abbrev;
|
|
|
|
} else {
|
|
|
|
module_name = proto_registrar_get_abbrev(hfinfo->parent);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proto_prefs_menu_.setModule(module_name);
|
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
foreach (QAction *action, copy_actions_) {
|
|
|
|
action->setData(QVariant());
|
|
|
|
}
|
|
|
|
|
2013-12-10 21:07:26 +00:00
|
|
|
decode_as_->setData(qVariantFromValue(true));
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_column_ = columnAt(event->x());
|
2015-07-27 22:28:50 +00:00
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
// Set menu sensitivity for the current column and set action data.
|
2015-07-27 22:28:50 +00:00
|
|
|
emit packetSelectionChanged();
|
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
ctx_menu_.exec(event->globalPos());
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_column_ = -1;
|
2013-12-10 21:07:26 +00:00
|
|
|
decode_as_->setData(QVariant());
|
2015-07-27 22:28:50 +00:00
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 14:30:23 +00:00
|
|
|
// Auto scroll if:
|
|
|
|
// - We're not at the end
|
|
|
|
// - We are capturing
|
|
|
|
// - actionGoAutoScroll in the main UI is checked.
|
|
|
|
// - It's been more than tail_update_interval_ ms since we last scrolled
|
|
|
|
// - The last user-set vertical scrollbar position was at the end.
|
|
|
|
|
|
|
|
// Using a timer assumes that we can save CPU overhead by updating
|
|
|
|
// periodically. If that's not the case we can dispense with it and call
|
|
|
|
// scrollToBottom() from rowsInserted().
|
|
|
|
void PacketList::timerEvent(QTimerEvent *event)
|
|
|
|
{
|
2016-03-15 16:49:48 +00:00
|
|
|
if (event->timerId() == tail_timer_id_) {
|
|
|
|
if (rows_inserted_ && capture_in_progress_ && tail_at_end_) {
|
|
|
|
scrollToBottom();
|
|
|
|
rows_inserted_ = false;
|
|
|
|
}
|
|
|
|
} else if (event->timerId() == overlay_timer_id_) {
|
|
|
|
if (!capture_in_progress_) {
|
|
|
|
if (create_near_overlay_) drawNearOverlay();
|
|
|
|
if (create_far_overlay_) drawFarOverlay();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QTreeView::timerEvent(event);
|
2015-02-20 14:30:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
void PacketList::paintEvent(QPaintEvent *event)
|
|
|
|
{
|
|
|
|
// XXX This is overkill, but there are quite a few events that
|
|
|
|
// require a new overlay, e.g. page up/down, scrolling, column
|
|
|
|
// resizing, etc.
|
|
|
|
create_near_overlay_ = true;
|
|
|
|
QTreeView::paintEvent(event);
|
|
|
|
}
|
|
|
|
|
2015-11-27 23:06:56 +00:00
|
|
|
void PacketList::mousePressEvent (QMouseEvent *event)
|
|
|
|
{
|
|
|
|
setAutoScroll(false);
|
|
|
|
QTreeView::mousePressEvent(event);
|
|
|
|
setAutoScroll(true);
|
|
|
|
}
|
|
|
|
|
2016-02-10 00:38:43 +00:00
|
|
|
void PacketList::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
create_near_overlay_ = true;
|
|
|
|
create_far_overlay_ = true;
|
|
|
|
QTreeView::resizeEvent(event);
|
|
|
|
}
|
|
|
|
|
2014-06-16 23:54:57 +00:00
|
|
|
void PacketList::setColumnVisibility()
|
|
|
|
{
|
2015-11-24 19:42:50 +00:00
|
|
|
set_column_visibility_ = true;
|
2014-06-17 22:38:29 +00:00
|
|
|
for (int i = 0; i < prefs.num_cols; i++) {
|
2014-06-16 23:54:57 +00:00
|
|
|
setColumnHidden(i, get_column_visible(i) ? false : true);
|
|
|
|
}
|
2015-11-24 19:42:50 +00:00
|
|
|
set_column_visibility_ = false;
|
2014-06-16 23:54:57 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 23:49:39 +00:00
|
|
|
int PacketList::sizeHintForColumn(int column) const
|
|
|
|
{
|
2015-05-11 19:10:25 +00:00
|
|
|
int size_hint = 0;
|
2015-03-27 23:49:39 +00:00
|
|
|
|
|
|
|
// This is a bit hacky but Qt does a fine job of column sizing and
|
2015-05-11 19:10:25 +00:00
|
|
|
// reimplementing QTreeView::sizeHintForColumn seems like a worse idea.
|
|
|
|
if (itemDelegateForColumn(column)) {
|
|
|
|
// In my (gcc) testing this results in correct behavior on Windows but adds extra space
|
|
|
|
// on OS X and Linux. We might want to add Q_OS_... #ifdefs accordingly.
|
|
|
|
size_hint = itemDelegateForColumn(column)->sizeHint(viewOptions(), QModelIndex()).width();
|
|
|
|
}
|
2015-05-13 19:34:25 +00:00
|
|
|
size_hint += QTreeView::sizeHintForColumn(column); // Decoration padding
|
2015-03-27 23:49:39 +00:00
|
|
|
return size_hint;
|
|
|
|
}
|
|
|
|
|
2015-11-26 18:15:44 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
void PacketList::initHeaderContextMenu()
|
|
|
|
{
|
|
|
|
header_ctx_menu_.clear();
|
|
|
|
header_actions_.clear();
|
|
|
|
|
|
|
|
// Leave these out for now since Qt doesn't have a "no sort" option
|
|
|
|
// and the user can sort by left-clicking on the header.
|
|
|
|
// header_actions_[] = header_ctx_menu_.addAction(tr("Sort Ascending"));
|
|
|
|
// header_actions_[] = header_ctx_menu_.addAction(tr("Sort Descending"));
|
|
|
|
// header_actions_[] = header_ctx_menu_.addAction(tr("Do Not Sort"));
|
|
|
|
// header_ctx_menu_.addSeparator();
|
|
|
|
header_actions_[caAlignLeft] = header_ctx_menu_.addAction(tr("Align Left"));
|
|
|
|
header_actions_[caAlignCenter] = header_ctx_menu_.addAction(tr("Align Center"));
|
|
|
|
header_actions_[caAlignRight] = header_ctx_menu_.addAction(tr("Align Right"));
|
|
|
|
header_ctx_menu_.addSeparator();
|
|
|
|
header_actions_[caColumnPreferences] = header_ctx_menu_.addAction(tr("Column Preferences" UTF8_HORIZONTAL_ELLIPSIS));
|
|
|
|
header_actions_[caEditColumn] = header_ctx_menu_.addAction(tr("Edit Column")); // XXX Create frame instead of dialog
|
|
|
|
header_actions_[caResizeToContents] = header_ctx_menu_.addAction(tr("Resize To Contents"));
|
|
|
|
header_actions_[caResolveNames] = header_ctx_menu_.addAction(tr("Resolve Names"));
|
|
|
|
header_ctx_menu_.addSeparator();
|
|
|
|
// header_actions_[caDisplayedColumns] = header_ctx_menu_.addAction(tr("Displayed Columns"));
|
|
|
|
show_hide_separator_ = header_ctx_menu_.addSeparator();
|
|
|
|
// header_actions_[caHideColumn] = header_ctx_menu_.addAction(tr("Hide This Column"));
|
|
|
|
header_actions_[caRemoveColumn] = header_ctx_menu_.addAction(tr("Remove This Column"));
|
|
|
|
|
|
|
|
foreach (ColumnActions ca, header_actions_.keys()) {
|
|
|
|
header_actions_[ca]->setData(qVariantFromValue(ca));
|
|
|
|
connect(header_actions_[ca], SIGNAL(triggered()), this, SLOT(headerMenuTriggered()));
|
|
|
|
}
|
|
|
|
|
|
|
|
checkable_actions_ = QList<ColumnActions>() << caAlignLeft << caAlignCenter << caAlignRight << caResolveNames;
|
|
|
|
foreach (ColumnActions ca, checkable_actions_) {
|
|
|
|
header_actions_[ca]->setCheckable(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-15 21:14:10 +00:00
|
|
|
void PacketList::drawCurrentPacket()
|
|
|
|
{
|
|
|
|
QModelIndex current_index = currentIndex();
|
|
|
|
setCurrentIndex(QModelIndex());
|
|
|
|
if (current_index.isValid()) {
|
|
|
|
setCurrentIndex(current_index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-09 23:47:11 +00:00
|
|
|
// Redraw the packet list and detail. Called from many places.
|
2015-06-23 18:19:48 +00:00
|
|
|
// XXX We previously re-selected the packet here, but that seems to cause
|
|
|
|
// automatic scrolling problems.
|
2014-10-21 20:36:10 +00:00
|
|
|
void PacketList::redrawVisiblePackets() {
|
2015-07-09 23:47:11 +00:00
|
|
|
update();
|
|
|
|
header()->update();
|
2015-10-15 21:14:10 +00:00
|
|
|
drawCurrentPacket();
|
2015-07-09 23:47:11 +00:00
|
|
|
}
|
|
|
|
|
2015-12-12 22:28:26 +00:00
|
|
|
void PacketList::resetColumns()
|
|
|
|
{
|
|
|
|
packet_list_model_->resetColumns();
|
|
|
|
}
|
|
|
|
|
2015-07-09 23:47:11 +00:00
|
|
|
// prefs.col_list has changed.
|
|
|
|
void PacketList::columnsChanged()
|
|
|
|
{
|
2015-11-24 19:42:50 +00:00
|
|
|
columns_changed_ = true;
|
2015-11-23 13:06:59 +00:00
|
|
|
if (!cap_file_) {
|
2015-11-24 19:42:50 +00:00
|
|
|
// Keep columns_changed_ = true until we load a capture file.
|
2015-11-23 13:06:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-07-09 23:47:11 +00:00
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
prefs.num_cols = g_list_length(prefs.col_list);
|
2015-02-19 01:18:27 +00:00
|
|
|
col_cleanup(&cap_file_->cinfo);
|
2015-01-01 19:41:03 +00:00
|
|
|
build_column_format_array(&cap_file_->cinfo, prefs.num_cols, FALSE);
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2015-12-12 22:28:26 +00:00
|
|
|
resetColumns();
|
2015-12-12 20:12:47 +00:00
|
|
|
applyRecentColumnWidths();
|
2016-09-17 10:37:11 +00:00
|
|
|
setColumnVisibility();
|
2015-11-23 13:06:59 +00:00
|
|
|
columns_changed_ = false;
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
|
|
|
|
2015-08-17 19:39:41 +00:00
|
|
|
// Fields have changed, update custom columns
|
|
|
|
void PacketList::fieldsChanged(capture_file *cf)
|
|
|
|
{
|
|
|
|
prefs.num_cols = g_list_length(prefs.col_list);
|
|
|
|
col_cleanup(&cf->cinfo);
|
|
|
|
build_column_format_array(&cf->cinfo, prefs.num_cols, FALSE);
|
2015-09-11 21:20:06 +00:00
|
|
|
// call packet_list_model_->resetColumns() ?
|
2015-08-17 19:39:41 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:18:27 +00:00
|
|
|
// Column widths should
|
|
|
|
// - Load from recent when we load a new profile (including at starting up).
|
2015-12-12 22:28:26 +00:00
|
|
|
// - Reapply when changing columns.
|
2015-02-19 01:18:27 +00:00
|
|
|
// - Persist across freezes and thaws.
|
|
|
|
// - Persist across file closing and opening.
|
|
|
|
// - Save to recent when we save our profile (including shutting down).
|
2015-12-06 20:08:52 +00:00
|
|
|
// - Not be affected by the behavior of stretchLastSection.
|
2015-02-19 01:18:27 +00:00
|
|
|
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.
|
2015-12-06 20:08:52 +00:00
|
|
|
|
|
|
|
int column_width = 0;
|
|
|
|
|
2015-11-26 18:15:44 +00:00
|
|
|
for (int col = 0; col < prefs.num_cols; col++) {
|
|
|
|
setRecentColumnWidth(col);
|
2015-12-06 20:08:52 +00:00
|
|
|
column_width += columnWidth(col);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column_width > width()) {
|
|
|
|
resize(column_width, height());
|
2015-02-19 01:18:27 +00:00
|
|
|
}
|
2015-12-03 01:51:00 +00:00
|
|
|
|
2015-02-19 01:18:27 +00:00
|
|
|
column_state_ = header()->saveState();
|
|
|
|
}
|
|
|
|
|
2015-10-27 22:04:44 +00:00
|
|
|
void PacketList::preferencesChanged()
|
2015-08-06 19:31:21 +00:00
|
|
|
{
|
2015-10-27 22:04:44 +00:00
|
|
|
// Related packet delegate
|
|
|
|
if (prefs.gui_packet_list_show_related) {
|
|
|
|
setItemDelegateForColumn(0, &related_packet_delegate_);
|
|
|
|
} else {
|
|
|
|
setItemDelegateForColumn(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intelligent scroll bar (minimap)
|
|
|
|
if (prefs.gui_packet_list_show_minimap) {
|
|
|
|
if (overlay_timer_id_ == 0) {
|
|
|
|
overlay_timer_id_ = startTimer(overlay_update_interval_);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (overlay_timer_id_ != 0) {
|
|
|
|
killTimer(overlay_timer_id_);
|
|
|
|
overlay_timer_id_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Elide mode.
|
|
|
|
// This sets the mode for the entire view. If we want to make this setting
|
|
|
|
// per-column we'll either have to generalize RelatedPacketDelegate so that
|
|
|
|
// we can set it for entire rows or create another delegate.
|
2015-08-06 19:31:21 +00:00
|
|
|
Qt::TextElideMode elide_mode = Qt::ElideRight;
|
|
|
|
switch (prefs.gui_packet_list_elide_mode) {
|
|
|
|
case ELIDE_LEFT:
|
|
|
|
elide_mode = Qt::ElideLeft;
|
|
|
|
break;
|
|
|
|
case ELIDE_MIDDLE:
|
|
|
|
elide_mode = Qt::ElideMiddle;
|
|
|
|
break;
|
|
|
|
case ELIDE_NONE:
|
|
|
|
elide_mode = Qt::ElideNone;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setTextElideMode(elide_mode);
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:36:19 +00:00
|
|
|
void PacketList::recolorPackets()
|
|
|
|
{
|
|
|
|
packet_list_model_->resetColorized();
|
|
|
|
redrawVisiblePackets();
|
|
|
|
}
|
|
|
|
|
2015-03-07 16:45:00 +00:00
|
|
|
/* Enable autoscroll timer. Note: must be called after the capture is started,
|
|
|
|
* otherwise the timer will not be executed. */
|
2015-11-27 16:01:05 +00:00
|
|
|
void PacketList::setVerticalAutoScroll(bool enabled)
|
2015-02-20 14:30:23 +00:00
|
|
|
{
|
|
|
|
tail_at_end_ = enabled;
|
2015-03-01 17:18:34 +00:00
|
|
|
if (enabled && capture_in_progress_) {
|
2015-02-20 14:30:23 +00:00
|
|
|
scrollToBottom();
|
2015-03-15 17:35:47 +00:00
|
|
|
if (tail_timer_id_ == 0) tail_timer_id_ = startTimer(tail_update_interval_);
|
|
|
|
} else if (tail_timer_id_ != 0) {
|
2015-02-20 14:30:23 +00:00
|
|
|
killTimer(tail_timer_id_);
|
|
|
|
tail_timer_id_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-16 17:46:45 +00:00
|
|
|
// Called when we finish reading, reloading, rescanning, and retapping
|
|
|
|
// packets.
|
|
|
|
void PacketList::captureFileReadFinished()
|
|
|
|
{
|
|
|
|
packet_list_model_->flushVisibleRows();
|
2015-09-20 20:17:07 +00:00
|
|
|
packet_list_model_->dissectIdle(true);
|
2015-09-16 17:46:45 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 20:24:56 +00:00
|
|
|
void PacketList::freeze()
|
|
|
|
{
|
|
|
|
setUpdatesEnabled(false);
|
2015-11-20 23:24:30 +00:00
|
|
|
column_state_ = header()->saveState();
|
2016-06-21 22:13:30 +00:00
|
|
|
selectionModel()->clear();
|
2013-11-15 20:24:56 +00:00
|
|
|
setModel(NULL);
|
2015-01-27 17:25:29 +00:00
|
|
|
// It looks like GTK+ sends a cursor-changed signal at this point but Qt doesn't
|
|
|
|
// call selectionChanged.
|
|
|
|
related_packet_delegate_.clear();
|
|
|
|
proto_tree_->clear();
|
|
|
|
byte_view_tab_->clear();
|
2013-11-15 20:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::thaw()
|
|
|
|
{
|
2013-11-22 17:59:15 +00:00
|
|
|
setUpdatesEnabled(true);
|
2015-05-13 19:04:05 +00:00
|
|
|
setModel(packet_list_model_);
|
2015-02-19 01:18:27 +00:00
|
|
|
|
|
|
|
// Resetting the model resets our column widths so we restore them here.
|
|
|
|
// We don't reapply the recent settings because the user could have
|
|
|
|
// resized the columns manually since they were initially loaded.
|
|
|
|
header()->restoreState(column_state_);
|
|
|
|
|
2014-06-16 23:54:57 +00:00
|
|
|
setColumnVisibility();
|
2013-11-15 20:24:56 +00:00
|
|
|
}
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
void PacketList::clear() {
|
|
|
|
// packet_history_clear();
|
2013-07-08 16:54:18 +00:00
|
|
|
related_packet_delegate_.clear();
|
2016-06-21 22:13:30 +00:00
|
|
|
selectionModel()->clear();
|
2012-10-30 19:21:24 +00:00
|
|
|
packet_list_model_->clear();
|
2012-08-19 23:52:08 +00:00
|
|
|
proto_tree_->clear();
|
2012-11-06 21:49:16 +00:00
|
|
|
byte_view_tab_->clear();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
QImage overlay;
|
|
|
|
overlay_sb_->setNearOverlayImage(overlay);
|
2016-02-10 00:38:43 +00:00
|
|
|
overlay_sb_->setMarkedPacketImage(overlay);
|
2015-06-11 22:53:51 +00:00
|
|
|
create_near_overlay_ = true;
|
|
|
|
create_far_overlay_ = true;
|
|
|
|
|
2014-06-17 22:38:29 +00:00
|
|
|
setColumnVisibility();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::writeRecent(FILE *rf) {
|
|
|
|
gint col, width, col_fmt;
|
|
|
|
gchar xalign;
|
|
|
|
|
|
|
|
fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH);
|
2015-02-19 01:18:27 +00:00
|
|
|
for (col = 0; col < prefs.num_cols; col++) {
|
2012-01-04 22:13:01 +00:00
|
|
|
if (col > 0) {
|
|
|
|
fprintf (rf, ",");
|
|
|
|
}
|
|
|
|
col_fmt = get_column_format(col);
|
|
|
|
if (col_fmt == COL_CUSTOM) {
|
2015-12-11 08:34:08 +00:00
|
|
|
fprintf (rf, " %%Cus:%s,", get_column_custom_fields(col));
|
2012-01-04 22:13:01 +00:00
|
|
|
} else {
|
|
|
|
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
|
|
|
}
|
2015-05-13 22:46:51 +00:00
|
|
|
width = recent_get_column_width (col);
|
2012-01-04 22:13:01 +00:00
|
|
|
xalign = recent_get_column_xalign (col);
|
|
|
|
fprintf (rf, " %d", width);
|
|
|
|
if (xalign != COLUMN_XALIGN_DEFAULT) {
|
|
|
|
fprintf (rf, ":%c", xalign);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (rf, "\n");
|
|
|
|
|
|
|
|
}
|
2012-08-13 01:50:14 +00:00
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
bool PacketList::contextMenuActive()
|
|
|
|
{
|
2012-12-07 20:08:00 +00:00
|
|
|
return ctx_column_ >= 0 ? true : false;
|
|
|
|
}
|
|
|
|
|
2015-09-04 10:22:30 +00:00
|
|
|
QString PacketList::getFilterFromRowAndColumn()
|
2012-12-07 20:08:00 +00:00
|
|
|
{
|
|
|
|
frame_data *fdata;
|
2015-09-04 10:22:30 +00:00
|
|
|
QString filter;
|
2012-12-07 20:08:00 +00:00
|
|
|
int row = currentIndex().row();
|
|
|
|
|
|
|
|
if (!cap_file_ || !packet_list_model_ || ctx_column_ < 0 || ctx_column_ >= cap_file_->cinfo.num_cols) return filter;
|
|
|
|
|
2012-12-17 23:03:21 +00:00
|
|
|
fdata = packet_list_model_->getRowFdata(row);
|
2012-12-07 20:08:00 +00:00
|
|
|
|
|
|
|
if (fdata != NULL) {
|
|
|
|
epan_dissect_t edt;
|
|
|
|
|
2014-05-24 18:28:30 +00:00
|
|
|
if (!cf_read_record(cap_file_, fdata))
|
|
|
|
return filter; /* error reading the record */
|
2012-12-07 20:08:00 +00:00
|
|
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
|
2012-12-07 20:08:00 +00:00
|
|
|
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
|
|
|
|
2014-05-25 00:04:44 +00:00
|
|
|
epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->phdr, frame_tvbuff_new_buffer(fdata, &cap_file_->buf), fdata, &cap_file_->cinfo);
|
2012-12-07 20:08:00 +00:00
|
|
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
|
|
|
|
2015-06-27 03:00:33 +00:00
|
|
|
if ((cap_file_->cinfo.columns[ctx_column_].col_custom_occurrence) ||
|
2012-12-07 20:08:00 +00:00
|
|
|
(strchr (cap_file_->cinfo.col_expr.col_expr_val[ctx_column_], ',') == NULL))
|
|
|
|
{
|
|
|
|
/* Only construct the filter when a single occurrence is displayed
|
|
|
|
* otherwise we might end up with a filter like "ip.proto==1,6".
|
|
|
|
*
|
|
|
|
* Or do we want to be able to filter on multiple occurrences so that
|
|
|
|
* the filter might be calculated as "ip.proto==1 && ip.proto==6"
|
|
|
|
* instead?
|
|
|
|
*/
|
|
|
|
if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 &&
|
|
|
|
strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) {
|
2015-06-27 03:00:33 +00:00
|
|
|
if (cap_file_->cinfo.columns[ctx_column_].col_fmt == COL_CUSTOM) {
|
2015-12-11 08:34:08 +00:00
|
|
|
header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.columns[ctx_column_].col_custom_fields);
|
2015-11-04 12:57:50 +00:00
|
|
|
if (hfi && hfi->parent == -1) {
|
2012-12-07 20:08:00 +00:00
|
|
|
/* Protocol only */
|
|
|
|
filter.append(cap_file_->cinfo.col_expr.col_expr[ctx_column_]);
|
2015-11-04 12:57:50 +00:00
|
|
|
} else if (hfi && hfi->type == FT_STRING) {
|
2012-12-07 20:08:00 +00:00
|
|
|
/* Custom string, add quotes */
|
|
|
|
filter.append(QString("%1 == \"%2\"")
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_])
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.isEmpty()) {
|
|
|
|
filter.append(QString("%1 == %2")
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_])
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
epan_dissect_cleanup(&edt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return filter;
|
2012-12-07 01:46:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
void PacketList::resetColorized()
|
|
|
|
{
|
|
|
|
packet_list_model_->resetColorized();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2012-12-23 04:37:58 +00:00
|
|
|
QString PacketList::packetComment()
|
|
|
|
{
|
|
|
|
int row = currentIndex().row();
|
2014-10-05 19:23:33 +00:00
|
|
|
const frame_data *fdata;
|
2013-08-01 20:59:38 +00:00
|
|
|
char *pkt_comment;
|
2012-12-23 04:37:58 +00:00
|
|
|
|
|
|
|
if (!cap_file_ || !packet_list_model_) return NULL;
|
|
|
|
|
|
|
|
fdata = packet_list_model_->getRowFdata(row);
|
|
|
|
|
|
|
|
if (!fdata) return NULL;
|
|
|
|
|
2013-08-01 20:59:38 +00:00
|
|
|
pkt_comment = cf_get_comment(cap_file_, fdata);
|
|
|
|
|
|
|
|
return QString(pkt_comment);
|
|
|
|
|
|
|
|
/* XXX, g_free(pkt_comment) */
|
2012-12-23 04:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::setPacketComment(QString new_comment)
|
|
|
|
{
|
|
|
|
int row = currentIndex().row();
|
|
|
|
frame_data *fdata;
|
2015-09-05 17:39:51 +00:00
|
|
|
gchar *new_packet_comment;
|
2012-12-23 04:37:58 +00:00
|
|
|
|
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
|
|
|
|
fdata = packet_list_model_->getRowFdata(row);
|
|
|
|
|
|
|
|
if (!fdata) return;
|
|
|
|
|
|
|
|
/* Check if we are clearing the comment */
|
|
|
|
if(new_comment.isEmpty()) {
|
|
|
|
new_packet_comment = NULL;
|
2015-09-05 17:39:51 +00:00
|
|
|
} else {
|
|
|
|
new_packet_comment = qstring_strdup(new_comment);
|
2012-12-23 04:37:58 +00:00
|
|
|
}
|
|
|
|
|
2013-08-01 20:59:38 +00:00
|
|
|
cf_set_user_packet_comment(cap_file_, fdata, new_packet_comment);
|
2015-09-05 17:39:51 +00:00
|
|
|
g_free(new_packet_comment);
|
2012-12-23 04:37:58 +00:00
|
|
|
|
2014-10-21 20:36:10 +00:00
|
|
|
redrawVisiblePackets();
|
2012-12-23 04:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString PacketList::allPacketComments()
|
|
|
|
{
|
|
|
|
guint32 framenum;
|
|
|
|
frame_data *fdata;
|
|
|
|
QString buf_str;
|
|
|
|
|
|
|
|
if (!cap_file_) return buf_str;
|
|
|
|
|
|
|
|
for (framenum = 1; framenum <= cap_file_->count ; framenum++) {
|
|
|
|
fdata = frame_data_sequence_find(cap_file_->frames, framenum);
|
2013-08-01 20:59:38 +00:00
|
|
|
|
|
|
|
char *pkt_comment = cf_get_comment(cap_file_, fdata);
|
|
|
|
|
|
|
|
if (pkt_comment) {
|
2015-02-26 13:00:22 +00:00
|
|
|
buf_str.append(QString(tr("Frame %1: %2\n\n")).arg(framenum).arg(pkt_comment));
|
2013-08-01 20:59:38 +00:00
|
|
|
g_free(pkt_comment);
|
2012-12-23 04:37:58 +00:00
|
|
|
}
|
|
|
|
if (buf_str.length() > max_comments_to_fetch_) {
|
2013-01-20 18:33:06 +00:00
|
|
|
buf_str.append(QString(tr("[ Comment text exceeds %1. Stopping. ]"))
|
2012-12-23 04:37:58 +00:00
|
|
|
.arg(format_size(max_comments_to_fetch_, format_size_unit_bytes|format_size_prefix_si)));
|
|
|
|
return buf_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf_str;
|
|
|
|
}
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
// Slots
|
|
|
|
|
|
|
|
void PacketList::setCaptureFile(capture_file *cf)
|
|
|
|
{
|
2015-02-19 01:18:27 +00:00
|
|
|
if (cf) {
|
|
|
|
// We're opening. Restore our column widths.
|
|
|
|
header()->restoreState(column_state_);
|
|
|
|
}
|
2012-10-30 19:21:24 +00:00
|
|
|
cap_file_ = cf;
|
2015-11-23 13:06:59 +00:00
|
|
|
if (cap_file_ && columns_changed_) {
|
|
|
|
columnsChanged();
|
|
|
|
}
|
2012-10-30 19:21:24 +00:00
|
|
|
packet_list_model_->setCaptureFile(cf);
|
2015-06-11 22:53:51 +00:00
|
|
|
create_near_overlay_ = true;
|
2016-06-17 20:43:20 +00:00
|
|
|
sortByColumn(-1, Qt::AscendingOrder);
|
2012-10-30 19:21:24 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 20:35:10 +00:00
|
|
|
void PacketList::setMonospaceFont(const QFont &mono_font)
|
|
|
|
{
|
2015-05-14 17:25:56 +00:00
|
|
|
setFont(mono_font);
|
|
|
|
header()->setFont(wsApp->font());
|
2014-09-23 20:35:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goNextPacket(void) {
|
2015-06-28 18:18:26 +00:00
|
|
|
if (selectionModel()->hasSelection()) {
|
|
|
|
setCurrentIndex(moveCursor(MoveDown, Qt::NoModifier));
|
|
|
|
} else {
|
|
|
|
// First visible packet.
|
|
|
|
setCurrentIndex(indexAt(viewport()->rect().topLeft()));
|
|
|
|
}
|
2012-08-13 01:50:14 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goPreviousPacket(void) {
|
2015-06-28 18:18:26 +00:00
|
|
|
if (selectionModel()->hasSelection()) {
|
|
|
|
setCurrentIndex(moveCursor(MoveUp, Qt::NoModifier));
|
|
|
|
} else {
|
|
|
|
// Last visible packet.
|
|
|
|
QModelIndex last_idx = indexAt(viewport()->rect().bottomLeft());
|
|
|
|
if (last_idx.isValid()) {
|
|
|
|
setCurrentIndex(last_idx);
|
|
|
|
} else {
|
|
|
|
goLastPacket();
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 01:50:14 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goFirstPacket(void) {
|
2015-05-12 18:26:59 +00:00
|
|
|
if (packet_list_model_->rowCount() < 1) return;
|
|
|
|
setCurrentIndex(packet_list_model_->index(0, 0));
|
2015-06-28 18:18:26 +00:00
|
|
|
scrollTo(currentIndex());
|
2012-08-13 01:50:14 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goLastPacket(void) {
|
2015-05-12 18:26:59 +00:00
|
|
|
if (packet_list_model_->rowCount() < 1) return;
|
2015-06-28 18:18:26 +00:00
|
|
|
setCurrentIndex(packet_list_model_->index(packet_list_model_->rowCount() - 1, 0));
|
|
|
|
scrollTo(currentIndex());
|
2012-08-13 01:50:14 +00:00
|
|
|
}
|
2012-08-19 23:52:08 +00:00
|
|
|
|
2013-09-06 19:07:57 +00:00
|
|
|
// XXX We can jump to the wrong packet if a display filter is applied
|
2012-08-19 23:52:08 +00:00
|
|
|
void PacketList::goToPacket(int packet) {
|
2015-09-30 12:35:13 +00:00
|
|
|
if (!cf_goto_frame(cap_file_, packet)) return;
|
2013-09-07 00:33:41 +00:00
|
|
|
int row = packet_list_model_->packetNumberToRow(packet);
|
2015-02-22 22:56:38 +00:00
|
|
|
if (row >= 0) {
|
2013-09-07 00:33:41 +00:00
|
|
|
setCurrentIndex(packet_list_model_->index(row, 0));
|
2012-08-20 04:34:23 +00:00
|
|
|
}
|
2012-08-19 23:52:08 +00:00
|
|
|
}
|
2012-09-04 08:18:31 +00:00
|
|
|
|
2015-03-11 22:22:20 +00:00
|
|
|
void PacketList::goToPacket(int packet, int hf_id)
|
|
|
|
{
|
|
|
|
goToPacket(packet);
|
|
|
|
proto_tree_->goToField(hf_id);
|
|
|
|
}
|
|
|
|
|
2012-12-17 23:03:21 +00:00
|
|
|
void PacketList::markFrame()
|
|
|
|
{
|
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
|
2015-07-16 19:07:49 +00:00
|
|
|
packet_list_model_->toggleFrameMark(currentIndex());
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2015-07-16 19:07:49 +00:00
|
|
|
packets_bar_update();
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::markAllDisplayedFrames(bool set)
|
|
|
|
{
|
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
|
2015-07-16 19:07:49 +00:00
|
|
|
packet_list_model_->setDisplayedFrameMark(set);
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2015-07-16 19:07:49 +00:00
|
|
|
packets_bar_update();
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::ignoreFrame()
|
|
|
|
{
|
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
|
2015-07-16 19:07:49 +00:00
|
|
|
packet_list_model_->toggleFrameIgnore(currentIndex());
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2015-07-16 19:07:49 +00:00
|
|
|
int sb_val = verticalScrollBar()->value(); // Surely there's a better way to keep our position?
|
|
|
|
setUpdatesEnabled(false);
|
2013-01-18 00:50:14 +00:00
|
|
|
emit packetDissectionChanged();
|
2015-07-16 19:07:49 +00:00
|
|
|
setUpdatesEnabled(true);
|
|
|
|
verticalScrollBar()->setValue(sb_val);
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::ignoreAllDisplayedFrames(bool set)
|
|
|
|
{
|
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
|
2015-07-16 19:07:49 +00:00
|
|
|
packet_list_model_->setDisplayedFrameIgnore(set);
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2013-01-18 00:50:14 +00:00
|
|
|
emit packetDissectionChanged();
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::setTimeReference()
|
|
|
|
{
|
2015-07-16 19:07:49 +00:00
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
packet_list_model_->toggleFrameRefTime(currentIndex());
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::unsetAllTimeReferences()
|
|
|
|
{
|
2015-07-16 19:07:49 +00:00
|
|
|
if (!cap_file_ || !packet_list_model_) return;
|
|
|
|
packet_list_model_->unsetAllFrameRefTime();
|
2015-06-11 22:53:51 +00:00
|
|
|
create_far_overlay_ = true;
|
2012-12-17 23:03:21 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 21:14:10 +00:00
|
|
|
void PacketList::applyTimeShift()
|
|
|
|
{
|
|
|
|
packet_list_model_->applyTimeShift();
|
|
|
|
redrawVisiblePackets();
|
|
|
|
// XXX emit packetDissectionChanged(); ?
|
|
|
|
}
|
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
void PacketList::showHeaderMenu(QPoint pos)
|
|
|
|
{
|
|
|
|
header_ctx_column_ = header()->logicalIndexAt(pos);
|
|
|
|
foreach (ColumnActions ca, checkable_actions_) {
|
|
|
|
header_actions_[ca]->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (recent_get_column_xalign(header_ctx_column_)) {
|
|
|
|
case COLUMN_XALIGN_LEFT:
|
|
|
|
header_actions_[caAlignLeft]->setChecked(true);
|
|
|
|
break;
|
|
|
|
case COLUMN_XALIGN_CENTER:
|
2015-02-19 01:18:27 +00:00
|
|
|
header_actions_[caAlignCenter]->setChecked(true);
|
2015-01-01 19:41:03 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_XALIGN_RIGHT:
|
|
|
|
header_actions_[caAlignRight]->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool can_resolve = resolve_column(header_ctx_column_, cap_file_);
|
|
|
|
header_actions_[caResolveNames]->setChecked(can_resolve && get_column_resolved(header_ctx_column_));
|
|
|
|
header_actions_[caResolveNames]->setEnabled(can_resolve);
|
|
|
|
|
2015-07-09 23:47:11 +00:00
|
|
|
header_actions_[caRemoveColumn]->setEnabled(header_ctx_column_ >= 0 && header()->count() > 2);
|
|
|
|
|
2015-01-01 19:41:03 +00:00
|
|
|
foreach (QAction *action, show_hide_actions_) {
|
|
|
|
header_ctx_menu_.removeAction(action);
|
|
|
|
delete action;
|
|
|
|
}
|
|
|
|
show_hide_actions_.clear();
|
|
|
|
for (int i = 0; i < prefs.num_cols; i++) {
|
|
|
|
QAction *action = new QAction(get_column_title(i), &header_ctx_menu_);
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setChecked(get_column_visible(i));
|
|
|
|
action->setData(qVariantFromValue(i));
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(columnVisibilityTriggered()));
|
|
|
|
header_ctx_menu_.insertAction(show_hide_separator_, action);
|
|
|
|
show_hide_actions_ << action;
|
|
|
|
}
|
|
|
|
|
|
|
|
header_ctx_menu_.popup(header()->viewport()->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::headerMenuTriggered()
|
|
|
|
{
|
|
|
|
QAction *ha = qobject_cast<QAction*>(sender());
|
|
|
|
if (!ha) return;
|
|
|
|
|
|
|
|
bool checked = ha->isChecked();
|
|
|
|
bool redraw = false;
|
|
|
|
|
|
|
|
switch(ha->data().value<ColumnActions>()) {
|
|
|
|
case caAlignLeft:
|
|
|
|
recent_set_column_xalign(header_ctx_column_, checked ? COLUMN_XALIGN_LEFT : COLUMN_XALIGN_DEFAULT);
|
|
|
|
break;
|
|
|
|
case caAlignCenter:
|
|
|
|
recent_set_column_xalign(header_ctx_column_, checked ? COLUMN_XALIGN_CENTER : COLUMN_XALIGN_DEFAULT);
|
|
|
|
break;
|
|
|
|
case caAlignRight:
|
|
|
|
recent_set_column_xalign(header_ctx_column_, checked ? COLUMN_XALIGN_RIGHT : COLUMN_XALIGN_DEFAULT);
|
|
|
|
break;
|
|
|
|
case caColumnPreferences:
|
2015-06-17 00:24:19 +00:00
|
|
|
emit showColumnPreferences(PreferencesDialog::ppColumn);
|
2015-01-01 19:41:03 +00:00
|
|
|
break;
|
|
|
|
case caEditColumn:
|
|
|
|
emit editColumn(header_ctx_column_);
|
|
|
|
break;
|
|
|
|
case caResolveNames:
|
|
|
|
set_column_resolved(header_ctx_column_, checked);
|
2015-11-23 19:15:48 +00:00
|
|
|
packet_list_model_->resetColumns();
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
redraw = true;
|
2015-01-15 18:38:25 +00:00
|
|
|
break;
|
2015-01-01 19:41:03 +00:00
|
|
|
case caResizeToContents:
|
|
|
|
resizeColumnToContents(header_ctx_column_);
|
|
|
|
break;
|
|
|
|
case caDisplayedColumns:
|
|
|
|
// No-op
|
|
|
|
break;
|
|
|
|
case caHideColumn:
|
|
|
|
set_column_visible(header_ctx_column_, FALSE);
|
|
|
|
hideColumn(header_ctx_column_);
|
2015-11-24 19:06:00 +00:00
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
break;
|
|
|
|
case caRemoveColumn:
|
2015-07-09 23:47:11 +00:00
|
|
|
{
|
|
|
|
if (header()->count() > 2) {
|
|
|
|
column_prefs_remove_nth(header_ctx_column_);
|
|
|
|
columnsChanged();
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-07-09 23:47:11 +00:00
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (redraw) {
|
|
|
|
redrawVisiblePackets();
|
|
|
|
} else {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::columnVisibilityTriggered()
|
|
|
|
{
|
|
|
|
QAction *ha = qobject_cast<QAction*>(sender());
|
|
|
|
if (!ha) return;
|
|
|
|
|
2015-11-24 19:42:50 +00:00
|
|
|
int col = ha->data().toInt();
|
|
|
|
set_column_visible(col, ha->isChecked());
|
2015-01-01 19:41:03 +00:00
|
|
|
setColumnVisibility();
|
2015-11-24 19:42:50 +00:00
|
|
|
if (ha->isChecked()) {
|
2015-11-26 18:15:44 +00:00
|
|
|
setRecentColumnWidth(col);
|
2015-11-24 19:42:50 +00:00
|
|
|
}
|
2015-11-24 19:06:00 +00:00
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:46:51 +00:00
|
|
|
void PacketList::sectionResized(int col, int, int new_width)
|
2015-02-19 01:18:27 +00:00
|
|
|
{
|
2015-11-24 19:42:50 +00:00
|
|
|
if (isVisible() && !columns_changed_ && !set_column_visibility_ && new_width > 0) {
|
2015-05-13 22:46:51 +00:00
|
|
|
// Column 1 gets an invalid value (32 on OS X) when we're not yet
|
|
|
|
// visible.
|
2015-11-24 19:42:50 +00:00
|
|
|
//
|
|
|
|
// Don't set column width when columns changed or setting column
|
|
|
|
// visibility because we may get a sectionReized() from QTreeView
|
|
|
|
// with values from a old columns layout.
|
|
|
|
//
|
|
|
|
// Don't set column width when hiding a column.
|
|
|
|
|
2015-05-13 22:46:51 +00:00
|
|
|
recent_set_column_width(col, new_width);
|
2015-02-19 01:18:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-09 23:47:11 +00:00
|
|
|
// The user moved a column. Make sure prefs.col_list, the column format
|
|
|
|
// array, and the header's visual and logical indices all agree.
|
|
|
|
// gtk/packet_list.c:column_dnd_changed_cb
|
|
|
|
void PacketList::sectionMoved(int, int, int)
|
|
|
|
{
|
|
|
|
GList *new_col_list = NULL;
|
|
|
|
QList<int> saved_sizes;
|
|
|
|
|
|
|
|
// Build a new column list based on the header's logical order.
|
|
|
|
for (int vis_idx = 0; vis_idx < header()->count(); vis_idx++) {
|
|
|
|
int log_idx = header()->logicalIndex(vis_idx);
|
|
|
|
saved_sizes << header()->sectionSize(log_idx);
|
|
|
|
|
|
|
|
void *pref_data = g_list_nth_data(prefs.col_list, log_idx);
|
|
|
|
if (!pref_data) continue;
|
|
|
|
|
|
|
|
new_col_list = g_list_append(new_col_list, pref_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear and rebuild our (and the header's) model. There doesn't appear
|
|
|
|
// to be another way to reset the logical index.
|
|
|
|
freeze();
|
|
|
|
|
|
|
|
g_list_free(prefs.col_list);
|
|
|
|
prefs.col_list = new_col_list;
|
|
|
|
|
|
|
|
thaw();
|
|
|
|
|
|
|
|
for (int i = 0; i < saved_sizes.length(); i++) {
|
|
|
|
if (saved_sizes[i] < 1) continue;
|
|
|
|
header()->resizeSection(i, saved_sizes[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
wsApp->emitAppSignal(WiresharkApplication::ColumnsChanged);
|
|
|
|
}
|
|
|
|
|
2015-09-23 00:18:33 +00:00
|
|
|
void PacketList::updateRowHeights(const QModelIndex &ih_index)
|
2015-09-16 17:46:45 +00:00
|
|
|
{
|
2015-09-23 00:18:33 +00:00
|
|
|
QStyleOptionViewItem option = viewOptions();
|
|
|
|
int max_height = 0;
|
|
|
|
|
|
|
|
// One of our columns increased the maximum row height. Find out which one.
|
|
|
|
for (int col = 0; col < packet_list_model_->columnCount(); col++) {
|
|
|
|
QSize size_hint = itemDelegate()->sizeHint(option, packet_list_model_->index(ih_index.row(), col));
|
|
|
|
max_height = qMax(max_height, size_hint.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_height > 0) {
|
|
|
|
packet_list_model_->setMaximiumRowHeight(max_height);
|
|
|
|
}
|
2015-09-16 17:46:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 23:24:39 +00:00
|
|
|
void PacketList::copySummary()
|
|
|
|
{
|
|
|
|
if (!currentIndex().isValid()) return;
|
|
|
|
|
|
|
|
QAction *ca = qobject_cast<QAction*>(sender());
|
|
|
|
if (!ca) return;
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
int copy_type = ca->data().toInt(&ok);
|
|
|
|
if (!ok) return;
|
|
|
|
|
|
|
|
QStringList col_parts;
|
|
|
|
int row = currentIndex().row();
|
|
|
|
for (int col = 0; col < packet_list_model_->columnCount(); col++) {
|
2016-06-05 04:05:23 +00:00
|
|
|
if (get_column_visible(col)) {
|
|
|
|
col_parts << packet_list_model_->data(packet_list_model_->index(row, col), Qt::DisplayRole).toString();
|
|
|
|
}
|
2015-07-29 23:24:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString copy_text;
|
|
|
|
switch (copy_type) {
|
|
|
|
case copy_summary_csv_:
|
|
|
|
copy_text = "\"";
|
|
|
|
copy_text += col_parts.join("\",\"");
|
|
|
|
copy_text += "\"";
|
|
|
|
break;
|
|
|
|
case copy_summary_yaml_:
|
|
|
|
copy_text = "----\n";
|
|
|
|
copy_text += QString("# Packet %1 from %2\n").arg(row).arg(cap_file_->filename);
|
|
|
|
copy_text += "- ";
|
|
|
|
copy_text += col_parts.join("\n- ");
|
|
|
|
copy_text += "\n";
|
|
|
|
break;
|
|
|
|
case copy_summary_text_:
|
|
|
|
default:
|
|
|
|
copy_text = col_parts.join("\t");
|
|
|
|
}
|
|
|
|
wsApp->clipboard()->setText(copy_text);
|
|
|
|
}
|
|
|
|
|
2015-02-20 14:30:23 +00:00
|
|
|
// We need to tell when the user has scrolled the packet list, either to
|
|
|
|
// the end or anywhere other than the end.
|
|
|
|
void PacketList::vScrollBarActionTriggered(int)
|
|
|
|
{
|
|
|
|
// If we're scrolling with a mouse wheel or trackpad sliderPosition can end up
|
|
|
|
// past the end.
|
|
|
|
tail_at_end_ = (verticalScrollBar()->sliderPosition() >= verticalScrollBar()->maximum());
|
|
|
|
|
|
|
|
if (capture_in_progress_ && prefs.capture_auto_scroll) {
|
|
|
|
emit packetListScrolled(tail_at_end_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
// Goal: Overlay the packet list scroll bar with the colors of all of the
|
|
|
|
// packets.
|
|
|
|
// Try 1: Average packet colors in each scroll bar raster line. This has
|
|
|
|
// two problems: It's easy to wash out colors and we dissect every packet.
|
|
|
|
// Try 2: Color across a 5000 or 10000 packet window. We still end up washing
|
|
|
|
// out colors.
|
|
|
|
// Try 3: One packet per vertical scroll bar pixel. This seems to work best
|
|
|
|
// but has the smallest window.
|
|
|
|
// Try 4: Use a multiple of the scroll bar heigh and scale the image down
|
|
|
|
// using Qt::SmoothTransformation. This gives us more packets per raster
|
|
|
|
// line.
|
|
|
|
|
|
|
|
// Odd (prime?) numbers resulted in fewer scaling artifacts. A multiplier
|
|
|
|
// of 9 washed out colors a little too much.
|
2016-02-10 00:38:43 +00:00
|
|
|
//const int height_multiplier_ = 7;
|
2015-06-11 22:53:51 +00:00
|
|
|
void PacketList::drawNearOverlay()
|
|
|
|
{
|
|
|
|
if (create_near_overlay_) {
|
|
|
|
create_near_overlay_ = false;
|
|
|
|
}
|
|
|
|
|
2015-10-27 22:04:44 +00:00
|
|
|
if (!cap_file_ || cap_file_->state != FILE_READ_DONE) return;
|
|
|
|
|
|
|
|
if (!prefs.gui_packet_list_show_minimap) return;
|
|
|
|
|
2015-06-11 22:53:51 +00:00
|
|
|
qreal dp_ratio = 1.0;
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
|
|
|
dp_ratio = overlay_sb_->devicePixelRatio();
|
|
|
|
#endif
|
2016-02-10 00:38:43 +00:00
|
|
|
int o_height = overlay_sb_->height() * dp_ratio;
|
2015-06-11 22:53:51 +00:00
|
|
|
int o_rows = qMin(packet_list_model_->rowCount(), o_height);
|
2016-02-10 00:38:43 +00:00
|
|
|
int o_width = (wsApp->fontMetrics().height() * 2 * dp_ratio) + 2; // 2ems + 1-pixel border on either side.
|
2015-07-22 17:28:04 +00:00
|
|
|
int selected_pos = -1;
|
2015-06-11 22:53:51 +00:00
|
|
|
|
|
|
|
if (recent.packet_list_colorize && o_rows > 0) {
|
2016-02-10 00:38:43 +00:00
|
|
|
QImage overlay(o_width, o_height, QImage::Format_ARGB32_Premultiplied);
|
2015-06-11 22:53:51 +00:00
|
|
|
|
|
|
|
QPainter painter(&overlay);
|
|
|
|
|
|
|
|
overlay.fill(Qt::transparent);
|
|
|
|
|
|
|
|
int cur_line = 0;
|
|
|
|
int start = 0;
|
|
|
|
|
2015-08-02 13:12:23 +00:00
|
|
|
if (packet_list_model_->rowCount() > o_height && overlay_sb_->maximum() > 0) {
|
2015-06-11 22:53:51 +00:00
|
|
|
start += ((double) overlay_sb_->value() / overlay_sb_->maximum()) * (packet_list_model_->rowCount() - o_rows);
|
|
|
|
}
|
|
|
|
int end = start + o_rows;
|
|
|
|
for (int row = start; row < end; row++) {
|
|
|
|
packet_list_model_->ensureRowColorized(row);
|
|
|
|
|
|
|
|
frame_data *fdata = packet_list_model_->getRowFdata(row);
|
|
|
|
const color_t *bgcolor = NULL;
|
|
|
|
if (fdata->color_filter) {
|
|
|
|
const color_filter_t *color_filter = (const color_filter_t *) fdata->color_filter;
|
|
|
|
bgcolor = &color_filter->bg_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
int next_line = (row - start) * o_height / o_rows;
|
|
|
|
if (bgcolor) {
|
|
|
|
QColor color(ColorUtils::fromColorT(bgcolor));
|
2016-02-10 00:38:43 +00:00
|
|
|
painter.fillRect(0, cur_line, o_width, next_line - cur_line, color);
|
2015-06-11 22:53:51 +00:00
|
|
|
}
|
|
|
|
cur_line = next_line;
|
|
|
|
}
|
|
|
|
|
2015-07-23 18:19:38 +00:00
|
|
|
// If the selected packet is in the overlay set selected_pos
|
|
|
|
// accordingly. Otherwise, pin it to either the top or bottom.
|
2015-07-22 17:28:04 +00:00
|
|
|
if (selectionModel()->hasSelection()) {
|
|
|
|
int sel_row = selectionModel()->currentIndex().row();
|
|
|
|
if (sel_row < start) {
|
|
|
|
selected_pos = 0;
|
|
|
|
} else if (sel_row >= end) {
|
|
|
|
selected_pos = overlay.height() - 1;
|
|
|
|
} else {
|
2015-07-23 18:19:38 +00:00
|
|
|
selected_pos = (sel_row - start) * o_height / o_rows;
|
2015-07-22 17:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 03:13:35 +00:00
|
|
|
overlay_sb_->setNearOverlayImage(overlay, packet_list_model_->rowCount(), start, end, selected_pos);
|
2015-06-11 22:53:51 +00:00
|
|
|
} else {
|
|
|
|
QImage overlay;
|
|
|
|
overlay_sb_->setNearOverlayImage(overlay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::drawFarOverlay()
|
|
|
|
{
|
|
|
|
if (create_far_overlay_) {
|
|
|
|
create_far_overlay_ = false;
|
|
|
|
}
|
|
|
|
|
2015-10-27 22:04:44 +00:00
|
|
|
if (!cap_file_ || cap_file_->state != FILE_READ_DONE) return;
|
|
|
|
|
|
|
|
if (!prefs.gui_packet_list_show_minimap) return;
|
|
|
|
|
2016-02-10 00:38:43 +00:00
|
|
|
QSize groove_size = overlay_sb_->grooveRect().size();
|
2015-06-11 22:53:51 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
2016-04-30 14:42:08 +00:00
|
|
|
qreal dp_ratio = 1.0;
|
2015-06-11 22:53:51 +00:00
|
|
|
dp_ratio = overlay_sb_->devicePixelRatio();
|
2016-02-10 00:38:43 +00:00
|
|
|
groove_size *= dp_ratio;
|
2015-06-11 22:53:51 +00:00
|
|
|
#endif
|
2016-02-10 00:38:43 +00:00
|
|
|
int o_width = groove_size.width();
|
|
|
|
int o_height = groove_size.height();
|
2015-06-11 22:53:51 +00:00
|
|
|
int pl_rows = packet_list_model_->rowCount();
|
2016-02-10 00:38:43 +00:00
|
|
|
QImage overlay(o_width, o_height, QImage::Format_ARGB32_Premultiplied);
|
2016-05-04 20:46:02 +00:00
|
|
|
bool have_marked_image = false;
|
2015-06-11 22:53:51 +00:00
|
|
|
|
2016-02-10 00:38:43 +00:00
|
|
|
// If only there were references from popular culture about getting into
|
|
|
|
// some sort of groove.
|
|
|
|
if (!overlay.isNull() && recent.packet_list_colorize && pl_rows > 0) {
|
2015-06-11 22:53:51 +00:00
|
|
|
|
|
|
|
QPainter painter(&overlay);
|
|
|
|
|
2016-02-10 00:38:43 +00:00
|
|
|
// Draw text-colored tick marks on a transparent background.
|
|
|
|
// Hopefully no themes use the text color for the groove color.
|
|
|
|
overlay.fill(Qt::transparent);
|
|
|
|
|
|
|
|
QColor tick_color = palette().text().color();
|
|
|
|
tick_color.setAlphaF(0.3);
|
|
|
|
painter.setPen(tick_color);
|
2015-06-11 22:53:51 +00:00
|
|
|
|
|
|
|
for (int row = 0; row < pl_rows; row++) {
|
|
|
|
|
|
|
|
frame_data *fdata = packet_list_model_->getRowFdata(row);
|
|
|
|
if (fdata->flags.marked || fdata->flags.ref_time || fdata->flags.ignored) {
|
2016-02-10 00:38:43 +00:00
|
|
|
int new_line = row * o_height / pl_rows;
|
|
|
|
int tick_width = o_width / 3;
|
|
|
|
// Marked or ignored: left side, time refs: right side.
|
|
|
|
// XXX Draw ignored ticks in the middle?
|
|
|
|
int x1 = fdata->flags.ref_time ? o_width - tick_width : 1;
|
|
|
|
int x2 = fdata->flags.ref_time ? o_width - 1 : tick_width;
|
|
|
|
|
|
|
|
painter.drawLine(x1, new_line, x2, new_line);
|
2016-05-04 20:46:02 +00:00
|
|
|
have_marked_image = true;
|
2015-06-11 22:53:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 20:46:02 +00:00
|
|
|
if (have_marked_image) {
|
2016-02-10 00:38:43 +00:00
|
|
|
overlay_sb_->setMarkedPacketImage(overlay);
|
2015-06-11 22:53:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-05-04 20:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!have_marked_image) {
|
2015-06-11 22:53:51 +00:00
|
|
|
QImage null_overlay;
|
2016-02-10 00:38:43 +00:00
|
|
|
overlay_sb_->setMarkedPacketImage(null_overlay);
|
2015-06-11 22:53:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 14:30:23 +00:00
|
|
|
void PacketList::rowsInserted(const QModelIndex &parent, int start, int end)
|
|
|
|
{
|
|
|
|
QTreeView::rowsInserted(parent, start, end);
|
|
|
|
rows_inserted_ = true;
|
|
|
|
}
|
|
|
|
|
2012-09-04 08:18:31 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|