summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-06-30 09:24:57 -0700
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2016-07-01 06:02:31 +0000
commit250f248fd917eb556f6e6838cf9a45385e00e358 (patch)
tree3059104a8fa18ebc114907d930230b6a11e51ecc
parent5cf7fcdf0f62cf0d8617428141a26e6f280a45d0 (diff)
downloadwireshark-250f248fd917eb556f6e6838cf9a45385e00e358.tar.gz
Qt: Add ASCII+EBCDIC actions to the byte view context menu.
Add actions to switch between ASCII and EBCDIC, similar to the hex and bits items. Bug: 5298 Change-Id: Ib601ac6e89411e6482f3e4172726e16a08fdbd2b Reviewed-on: https://code.wireshark.org/review/16225 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
-rw-r--r--docbook/release-notes.asciidoc1
-rw-r--r--ui/qt/byte_view_text.cpp38
-rw-r--r--ui/qt/byte_view_text.h6
3 files changed, 35 insertions, 10 deletions
diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc
index 43a09df9ed..c472fb7a79 100644
--- a/docbook/release-notes.asciidoc
+++ b/docbook/release-notes.asciidoc
@@ -36,6 +36,7 @@ since version 2.1.0:
* The Conversations and Endpoints dialogs are more responsive when
viewing large numbers of items.
* The RTP player now allows up to 30 minutes of silence frames.
+* Packet bytes can now be displayed as EBCDIC.
The following features are new (or have been significantly updated)
since version 2.0.0:
diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp
index eca8360482..bcbd1bbdac 100644
--- a/ui/qt/byte_view_text.cpp
+++ b/ui/qt/byte_view_text.cpp
@@ -46,6 +46,7 @@
// QPainter::drawText for each individual character.
Q_DECLARE_METATYPE(bytes_view_type)
+Q_DECLARE_METATYPE(packet_char_enc)
ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *tree_widget, packet_char_enc encoding) :
QAbstractScrollArea(parent),
@@ -53,8 +54,9 @@ ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTr
proto_tree_(tree),
tree_widget_(tree_widget),
bold_highlight_(false),
- encoding_(encoding),
format_actions_(new QActionGroup(this)),
+ encoding_actions_(new QActionGroup(this)),
+ encoding_(encoding),
hovered_byte_offset(-1),
p_bound_(0, 0),
f_bound_(0, 0),
@@ -80,9 +82,25 @@ ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTr
}
ctx_menu_.addActions(format_actions_->actions());
+ connect(format_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setHexDisplayFormat(QAction*)));
+
ctx_menu_.addSeparator();
- connect(format_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setHexDisplayFormat(QAction*)));
+ action = encoding_actions_->addAction(tr("Show bytes as ASCII"));
+ action->setData(qVariantFromValue(PACKET_CHAR_ENC_CHAR_ASCII));
+ action->setCheckable(true);
+ if (encoding_ == PACKET_CHAR_ENC_CHAR_ASCII) {
+ action->setChecked(true);
+ }
+ action = encoding_actions_->addAction(tr("Show bytes as EBCDIC"));
+ action->setData(qVariantFromValue(PACKET_CHAR_ENC_CHAR_EBCDIC));
+ action->setCheckable(true);
+ if (encoding_ == PACKET_CHAR_ENC_CHAR_EBCDIC) {
+ action->setChecked(true);
+ }
+
+ ctx_menu_.addActions(encoding_actions_->actions());
+ connect(encoding_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setCharacterEncoding(QAction*)));
setMouseTracking(true);
@@ -96,12 +114,6 @@ ByteViewText::~ByteViewText()
ctx_menu_.clear();
}
-void ByteViewText::setEncoding(packet_char_enc encoding)
-{
- encoding_ = encoding;
- viewport()->update();
-}
-
bool ByteViewText::hasDataSource(const tvbuff_t *ds_tvb) {
if (ds_tvb != NULL && ds_tvb == tvb_)
return true;
@@ -579,6 +591,16 @@ void ByteViewText::setHexDisplayFormat(QAction *action)
viewport()->update();
}
+void ByteViewText::setCharacterEncoding(QAction *action)
+{
+ if (!action) {
+ return;
+ }
+
+ encoding_ = action->data().value<packet_char_enc>();
+ viewport()->update();
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/byte_view_text.h b/ui/qt/byte_view_text.h
index 917813d19e..29ddc2372c 100644
--- a/ui/qt/byte_view_text.h
+++ b/ui/qt/byte_view_text.h
@@ -46,7 +46,6 @@ public:
~ByteViewText();
bool hasDataSource(const tvbuff_t *ds_tvb = NULL);
- void setEncoding(packet_char_enc encoding);
void setFormat(bytes_view_type format);
void setHighlightStyle(bool bold) { bold_highlight_ = bold; }
void setProtocolHighlight(int start, int end);
@@ -104,8 +103,9 @@ private:
gboolean bold_highlight_;
// Data
- packet_char_enc encoding_; // ASCII or EBCDIC
QActionGroup *format_actions_;
+ QActionGroup *encoding_actions_;
+ packet_char_enc encoding_; // ASCII or EBCDIC
QMenu ctx_menu_;
// Data highlight
@@ -131,6 +131,8 @@ private:
private slots:
void setHexDisplayFormat(QAction *action);
+ void setCharacterEncoding(QAction *action);
+
};
#endif // BYTE_VIEW_TEXT_H