diff options
Diffstat (limited to 'ui/qt/byte_view_text.cpp')
-rw-r--r-- | ui/qt/byte_view_text.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
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 * |