summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-12-23 04:37:58 +0000
committerGerald Combs <gerald@wireshark.org>2012-12-23 04:37:58 +0000
commita5d5162826b0349b0a7846d8336afdd77ab07a65 (patch)
tree1b47592d5aeb6b4cfcab86bf9264242446fc99b4 /ui/qt
parentaa347d504f65d3c8650c02a3b2cd839d11d0936b (diff)
downloadwireshark-a5d5162826b0349b0a7846d8336afdd77ab07a65.tar.gz
Qt: Implement packet comments. Fix packet detail updates.
GTK+: Shorten the packet comment menu item name. Remove a couple of unneeded includes. Both: Add an arbitrary 20 MB limit when fetching all packet comments. Use a color from the Tango palette for comments. svn path=/trunk/; revision=46709
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/CMakeLists.txt3
-rw-r--r--ui/qt/Makefile.am5
-rw-r--r--ui/qt/QtShark.pro3
-rw-r--r--ui/qt/main_window.h1
-rw-r--r--ui/qt/main_window_slots.cpp14
-rw-r--r--ui/qt/packet_comment_dialog.cpp65
-rw-r--r--ui/qt/packet_comment_dialog.h49
-rw-r--r--ui/qt/packet_comment_dialog.ui70
-rw-r--r--ui/qt/packet_list.cpp81
-rw-r--r--ui/qt/packet_list.h3
-rw-r--r--ui/qt/proto_tree.cpp2
-rw-r--r--ui/qt/time_shift_dialog.cpp1
12 files changed, 290 insertions, 7 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 922f745ac8..8dbcb09685 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -44,6 +44,7 @@ set(QTSHARK_H_SRC
main_welcome.h
main_window.h
monospace_font.h
+ packet_comment_dialog.h
packet_format_group_box.h
packet_list.h
packet_list_model.h
@@ -88,6 +89,7 @@ set(QTSHARK_CPP_SRC
main_window.cpp
main_window_slots.cpp
monospace_font.cpp
+ packet_comment_dialog.cpp
packet_format_group_box.cpp
packet_list.cpp
packet_list_model.cpp
@@ -117,6 +119,7 @@ set(QTSHARK_UI
import_text_dialog.ui
main_welcome.ui
main_window.ui
+ packet_comment_dialog.ui
packet_format_group_box.ui
packet_range_group_box.ui
print_dialog.ui
diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am
index 13d6a982e8..5d6b661447 100644
--- a/ui/qt/Makefile.am
+++ b/ui/qt/Makefile.am
@@ -101,6 +101,11 @@ main_window.h: ui_main_window.h
ui_main_window.h: main_window.ui
uic $< -o $@
+packet_comment_dialog.h: ui_packet_comment_dialog.h
+
+ui_packet_comment_dialog.h: packet_comment_dialog.ui
+ uic $< -o $@
+
packet_format_group_box.h: ui_packet_format_group_box.h
ui_packet_format_group_box.h: packet_format_group_box.ui
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro
index 5381644fae..56a48f0f2b 100644
--- a/ui/qt/QtShark.pro
+++ b/ui/qt/QtShark.pro
@@ -186,6 +186,7 @@ FORMS += main_window.ui \
file_set_dialog.ui \
import_text_dialog.ui \
main_welcome.ui \
+ packet_comment_dialog.ui \
packet_format_group_box.ui \
packet_range_group_box.ui \
print_dialog.ui \
@@ -218,6 +219,7 @@ HEADERS += $$HEADERS_WS_C \
accordion_frame.h \
export_dissection_dialog.h \
export_object_dialog.h \
+ packet_comment_dialog.h \
packet_format_group_box.h \
print_dialog.h \
search_frame.h \
@@ -423,6 +425,7 @@ SOURCES += \
main_window.cpp \
main_window_slots.cpp \
monospace_font.cpp \
+ packet_comment_dialog.cpp \
packet_format_group_box.cpp \
packet_list.cpp \
packet_list_model.cpp \
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 0082616ab0..447664b907 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -220,6 +220,7 @@ private slots:
void on_actionEditNextTimeReference_triggered();
void on_actionEditPreviousTimeReference_triggered();
void on_actionEditTimeShift_triggered();
+ void on_actionEditPacketComment_triggered();
void on_actionGoGoToPacket_triggered();
void resetPreviousFocus();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 18de80f023..eca548976c 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -63,6 +63,7 @@
#include "export_object_dialog.h"
#include "print_dialog.h"
#include "time_shift_dialog.h"
+#include "packet_comment_dialog.h"
#include <QMessageBox>
#include <QClipboard>
@@ -622,8 +623,7 @@ void MainWindow::setMenusForSelectedPacket()
// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket",
// frame_selected);
//#endif /* WANT_PACKET_EDITOR */
-// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/AddEditPktComment",
-// frame_selected);
+ main_ui_->actionEditPacketComment->setEnabled(frame_selected);
main_ui_->actionEditIgnorePacket->setEnabled(frame_selected);
main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered);
@@ -1266,10 +1266,18 @@ void MainWindow::on_actionEditTimeShift_triggered()
TimeShiftDialog ts_dialog(this, cap_file_);
connect(this, SIGNAL(setCaptureFile(capture_file*)),
&ts_dialog, SLOT(setCaptureFile(capture_file*)));
-
ts_dialog.exec();
}
+void MainWindow::on_actionEditPacketComment_triggered()
+{
+ PacketCommentDialog pc_dialog(this, packet_list_->packetComment());
+ if (pc_dialog.exec() == QDialog::Accepted) {
+ packet_list_->setPacketComment(pc_dialog.text());
+ updateForUnsavedChanges();
+ }
+}
+
// View Menu
// Expand / collapse slots in proto_tree
diff --git a/ui/qt/packet_comment_dialog.cpp b/ui/qt/packet_comment_dialog.cpp
new file mode 100644
index 0000000000..4ae6073581
--- /dev/null
+++ b/ui/qt/packet_comment_dialog.cpp
@@ -0,0 +1,65 @@
+/* packet_comment_dialog.cpp
+ *
+ * $Id$
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "packet_comment_dialog.h"
+#include "ui_packet_comment_dialog.h"
+
+#include "wireshark_application.h"
+
+PacketCommentDialog::PacketCommentDialog(QWidget *parent, QString comment) :
+ QDialog(parent),
+ pc_ui_(new Ui::PacketCommentDialog)
+{
+ pc_ui_->setupUi(this);
+
+ pc_ui_->commentTextEdit->setPlainText(comment);
+}
+
+PacketCommentDialog::~PacketCommentDialog()
+{
+ delete pc_ui_;
+}
+
+QString PacketCommentDialog::text()
+{
+ return pc_ui_->commentTextEdit->toPlainText();
+}
+
+void PacketCommentDialog::on_buttonBox_helpRequested()
+{
+// wsApp->helpTopicAction(HELP_PACKET_COMMENT_DIALOG);
+}
+
+/*
+ * 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:
+ */
+
diff --git a/ui/qt/packet_comment_dialog.h b/ui/qt/packet_comment_dialog.h
new file mode 100644
index 0000000000..2822841e0b
--- /dev/null
+++ b/ui/qt/packet_comment_dialog.h
@@ -0,0 +1,49 @@
+/* packet_comment_dialog.h
+ *
+ * $Id$
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef PACKET_COMMENT_DIALOG_H
+#define PACKET_COMMENT_DIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class PacketCommentDialog;
+}
+
+class PacketCommentDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit PacketCommentDialog(QWidget *parent = 0, QString comment = QString());
+ ~PacketCommentDialog();
+ QString text();
+
+private slots:
+ void on_buttonBox_helpRequested();
+
+private:
+ Ui::PacketCommentDialog *pc_ui_;
+};
+
+#endif // PACKET_COMMENT_DIALOG_H
diff --git a/ui/qt/packet_comment_dialog.ui b/ui/qt/packet_comment_dialog.ui
new file mode 100644
index 0000000000..b886daa1de
--- /dev/null
+++ b/ui/qt/packet_comment_dialog.ui
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PacketCommentDialog</class>
+ <widget class="QDialog" name="PacketCommentDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Wireshark: Packet Comment</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPlainTextEdit" name="commentTextEdit"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>PacketCommentDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>PacketCommentDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 9510055aff..f2d5b6c7d6 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -43,6 +43,8 @@
#include "ui/recent_utils.h"
#include "ui/ui_util.h"
+#include "wsutil/str_util.h"
+
#include <QTreeWidget>
#include <QTabWidget>
#include <QTextEdit>
@@ -55,6 +57,8 @@
// capture files against packet lists and models.
static PacketList *gbl_cur_packet_list = NULL;
+const int max_comments_to_fetch_ = 20000000; // Arbitrary
+
guint
packet_list_append(column_info *cinfo, frame_data *fdata, packet_info *pinfo)
{
@@ -238,7 +242,8 @@ PacketList::PacketList(QWidget *parent) :
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket"));
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference"));
ctx_menu_.addAction(window()->findChild<QAction *>("actionEditTimeShift"));
-// " <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n"
+ ctx_menu_.addAction(window()->findChild<QAction *>("actionEditPacketComment"));
+
ctx_menu_.addSeparator();
// " <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n"
ctx_menu_.addSeparator();
@@ -488,9 +493,15 @@ void PacketList::setFrameReftime(gboolean set, frame_data *fdata)
void PacketList::updateAll() {
update();
- if (cap_file_ && selectedIndexes().length() > 0) {
+ if (!cap_file_) return;
+
+ if (selectedIndexes().length() > 0) {
cf_select_packet(cap_file_, selectedIndexes()[0].row());
}
+
+ if (cap_file_->edt && cap_file_->edt->tree) {
+ proto_tree_->fillProtocolTree(cap_file_->edt->tree);
+ }
}
void PacketList::clear() {
@@ -601,6 +612,72 @@ QString &PacketList::getFilterFromRowAndColumn()
return filter;
}
+QString PacketList::packetComment()
+{
+ int row = currentIndex().row();
+ frame_data *fdata;
+
+ if (!cap_file_ || !packet_list_model_) return NULL;
+
+ fdata = packet_list_model_->getRowFdata(row);
+
+ if (!fdata) return NULL;
+
+ return QString(fdata->opt_comment);
+}
+
+void PacketList::setPacketComment(QString new_comment)
+{
+ int row = currentIndex().row();
+ frame_data *fdata;
+ gchar *new_packet_comment = new_comment.toUtf8().data();
+
+ if (!cap_file_ || !packet_list_model_) return;
+
+ fdata = packet_list_model_->getRowFdata(row);
+
+ if (!fdata) return;
+
+ /* Check if the comment has changed */
+ if (fdata->opt_comment) {
+ if (strcmp(fdata->opt_comment, new_packet_comment) == 0) {
+ return;
+ }
+ }
+
+ /* Check if we are clearing the comment */
+ if(new_comment.isEmpty()) {
+ new_packet_comment = NULL;
+ }
+
+ /* The comment has changed, let's update it */
+ cf_update_packet_comment(cap_file_, fdata, g_strdup(new_packet_comment));
+
+ updateAll();
+}
+
+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);
+ if (fdata->opt_comment) {
+ buf_str.append(QString("Frame %1: %2 \n\n").arg(framenum).arg(fdata->opt_comment));
+ }
+ if (buf_str.length() > max_comments_to_fetch_) {
+ buf_str.append(QString("[ Comment text exceeds %1. Stopping. ]")
+ .arg(format_size(max_comments_to_fetch_, format_size_unit_bytes|format_size_prefix_si)));
+ return buf_str;
+ }
+ }
+ return buf_str;
+}
+
// Slots
void PacketList::setCaptureFile(capture_file *cf)
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index 7257b1fa50..739c8116cc 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -46,6 +46,9 @@ public:
void writeRecent(FILE *rf);
bool contextMenuActive();
QString &getFilterFromRowAndColumn();
+ QString packetComment();
+ void setPacketComment(QString new_comment);
+ QString allPacketComments();
protected:
void showEvent (QShowEvent *event);
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index c4592041c2..c63b26a149 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -36,7 +36,7 @@
#include <QContextMenuEvent>
#include <QMainWindow>
-QColor expert_color_comment ( 0x00, 0xff, 0x00 ); /* Green */
+QColor expert_color_comment ( 0xb7, 0xf7, 0x74 ); /* Green */
QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */
QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */
QColor expert_color_warn ( 0xf7, 0xf2, 0x53 ); /* yellow */
diff --git a/ui/qt/time_shift_dialog.cpp b/ui/qt/time_shift_dialog.cpp
index beb3190dda..02127d125b 100644
--- a/ui/qt/time_shift_dialog.cpp
+++ b/ui/qt/time_shift_dialog.cpp
@@ -31,7 +31,6 @@
#include <QMessageBox>
-#include <QDebug>
TimeShiftDialog::TimeShiftDialog(QWidget *parent, capture_file *cf) :
QDialog(parent),
ts_ui_(new Ui::TimeShiftDialog),