16#include <QAbstractScrollArea>
64 QWidget *parent =
nullptr);
80 void setAnnotations(
const QVector<ByteViewAnnotation> &annotations);
125 Q_ASSERT(
data_.size() <= std::numeric_limits<int>::max());
126 return static_cast<int>(
data_.size());
192 selected_field_is_protocol_ = is_protocol;
200 selected_field_use_own_range_ = use_own_range;
264 void markField(
int start,
int length,
bool scroll_to =
true,
bool hover =
false);
298 virtual void showEvent(QShowEvent *event);
354 QTextLayout *layout_;
359 void updateLayoutMetrics();
366 int stringWidth(
const QString &line);
375 void drawLine(QPainter *painter,
const int offset,
const int row_y);
386 bool addFormatRange(QList<QTextLayout::FormatRange> &fmt_list,
387 int start,
int length, HighlightMode mode);
400 bool addHexFormatRange(QList<QTextLayout::FormatRange> &fmt_list,
401 int mark_start,
int mark_length,
402 int tvb_offset,
int max_tvb_pos,
416 bool addAsciiFormatRange(QList<QTextLayout::FormatRange> &fmt_list,
417 int mark_start,
int mark_length,
418 int tvb_offset,
int max_tvb_pos,
433 bool addHexCustomRange(QList<QTextLayout::FormatRange> &fmt_list,
434 int mark_start,
int mark_length,
435 int tvb_offset,
int max_tvb_pos,
436 const QColor &bg,
const QColor &fg);
450 bool addAsciiCustomRange(QList<QTextLayout::FormatRange> &fmt_list,
451 int mark_start,
int mark_length,
452 int tvb_offset,
int max_tvb_pos,
453 const QColor &bg,
const QColor &fg);
461 int annotationIndexAt(
int byte_offset)
const;
470 int annotationIndexIntersecting(
int start,
int length)
const;
479 void updateSelection(
int byte_offset,
bool extend,
bool emit_signal);
487 void updateAnnotationToolTip(
int byte_offset,
const QPoint &global_pos);
494 void scrollToByte(
int byte);
499 void updateScrollbars();
510 int byteOffsetAtPixel(QPoint pos,
bool allow_fuzzy =
false);
515 void createContextMenu();
520 void updateContextMenu();
529 int offsetChars(
bool include_pad =
true);
547 const QByteArray printableData() {
return data_; }
552 static const int separator_interval_;
558 QColor offset_normal_fg_;
559 QColor offset_field_fg_;
566 int hovered_byte_offset_;
573 int field_hover_start_;
574 int field_hover_len_;
585 QList<QRect> hover_outlines_;
587 bool allow_hover_selection_;
589 QVector<ByteViewAnnotation> annotations_;
592 int selection_anchor_;
593 int selection_start_;
596 int context_byte_offset_;
598 int hovered_annotation_index_;
599 int offset_start_byte_;
600 int offset_end_byte_;
601 bool selected_field_is_protocol_;
602 bool selected_field_use_own_range_;
612 QVector<int> x_pos_to_column_;
615 QAction *action_allow_hover_selection_;
616 QAction *action_add_annotation_;
617 QAction *action_edit_annotation_;
618 QAction *action_remove_annotation_;
619 QAction *action_set_offset_start_;
620 QAction *action_set_offset_end_;
621 QAction *action_clear_offset_markers_;
622 QAction *action_bytes_hex_;
623 QAction *action_bytes_dec_;
624 QAction *action_bytes_oct_;
625 QAction *action_bytes_bits_;
626 QAction *action_bytes_enc_from_packet_;
627 QAction *action_bytes_enc_ascii_;
628 QAction *action_bytes_enc_ebcdic_;
635 void copyBytes(
bool unused);
641 void setHexDisplayFormat(QAction *action);
647 void setCharacterEncoding(QAction *action);
653 void toggleHoverAllowed(
bool allowed);
656 void requestAddAnnotation();
659 void requestEditAnnotation();
662 void requestRemoveAnnotation();
665 void requestSetOffsetStart();
668 void requestSetOffsetEnd();
671 void requestClearOffsetMarkers();
Abstract base class for widgets that display raw packet byte data.
Definition base_data_source_view.h:20
QByteArray data_
The raw packet bytes displayed by this view.
Definition base_data_source_view.h:141
A fully custom-painted hex dump view for a single packet data source.
Definition hex_data_source_view.h:39
virtual void showEvent(QShowEvent *event)
Ensure the layout is up to date when the widget first becomes visible.
Definition hex_data_source_view.cpp:521
void markField(int start, int length, bool scroll_to=true, bool hover=false)
Highlight a specific dissected field byte range.
Definition hex_data_source_view.cpp:377
virtual void paintEvent(QPaintEvent *event)
Paint all visible rows of the hex dump.
Definition hex_data_source_view.cpp:438
int selectionEnd() const
Return the byte offset at the end of the current selection.
Definition hex_data_source_view.cpp:152
bool selectedFieldIsProtocol() const
Return whether the selected field is itself a protocol layer.
Definition hex_data_source_view.h:179
void setFormat(bytes_view_type format)
Set the numeric base used to render hex-panel byte values.
void addAnnotationRequested()
Emitted when the user triggers "Add annotation" from the context menu.
int offsetEnd() const
Return the current offset-end marker byte position.
Definition hex_data_source_view.h:141
void offsetMarkersCleared()
Emitted when the user requests that both offset markers be cleared.
void byteViewSettingsChanged()
Emitted when any byte-view display setting changes.
int selectedProtocolStart() const
Definition hex_data_source_view.h:169
virtual void mouseMoveEvent(QMouseEvent *event)
Extend the selection during a mouse drag.
Definition hex_data_source_view.cpp:553
void updateByteViewSettings()
Reload byte-view display preferences and repaint.
Definition hex_data_source_view.cpp:429
void markAppendix(int start, int length)
Highlight the appendix (trailing) bytes of the selected field.
Definition hex_data_source_view.cpp:392
int dataSize() const
Return the number of bytes in the data buffer.
Definition hex_data_source_view.h:124
virtual void leaveEvent(QEvent *event)
Clear hover highlights when the pointer leaves the widget.
Definition hex_data_source_view.cpp:597
virtual void resizeEvent(QResizeEvent *event)
Recalculate scrollbar ranges and repaint after a resize.
Definition hex_data_source_view.cpp:516
int selectionAnchor() const
Return the selection anchor byte offset.
Definition hex_data_source_view.cpp:147
void removeAnnotationRequested()
Emitted when the user triggers "Remove annotation" from the context menu.
void clearOffsetMarkers()
Clear both offset markers and repaint.
Definition hex_data_source_view.cpp:183
void offsetEndRequested(int byte)
Emitted when the user requests a new offset-end marker.
void editAnnotationRequested()
Emitted when the user triggers "Edit annotation" from the context menu.
virtual void mousePressEvent(QMouseEvent *event)
Begin a byte selection or move the cursor on mouse press.
Definition hex_data_source_view.cpp:531
int selectedFieldStart() const
Definition hex_data_source_view.h:163
bool selectedFieldUsesOwnRange() const
Return whether the selected field defines its own byte range.
Definition hex_data_source_view.h:185
~HexDataSourceView()
Destroy the view and its QTextLayout.
Definition hex_data_source_view.cpp:118
void markProtocol(int start, int length)
Highlight the enclosing protocol layer byte range.
Definition hex_data_source_view.cpp:370
int offsetStart() const
Return the current offset-start marker byte position.
Definition hex_data_source_view.h:135
virtual void contextMenuEvent(QContextMenuEvent *event)
Show the byte-view context menu.
Definition hex_data_source_view.cpp:610
void unmarkField()
Clear field, appendix, and hover highlights.
Definition hex_data_source_view.cpp:399
int contextByteOffset() const
Return the byte offset at which the context menu was invoked.
Definition hex_data_source_view.cpp:157
int selectedProtocolLength() const
Definition hex_data_source_view.h:172
int selectedFieldLength() const
Definition hex_data_source_view.h:166
bool selectionRange(int *start, int *length) const
Return the current byte selection range.
Definition hex_data_source_view.cpp:131
void setMonospaceFont(const QFont &mono_font)
Update the monospace font and recalculate layout metrics.
Definition hex_data_source_view.cpp:412
void setOffsetEnd(int byte)
Set the offset-end marker to the given byte.
Definition hex_data_source_view.cpp:171
void setSelectedFieldIsProtocol(bool is_protocol)
Set whether the selected field is a protocol-level item.
Definition hex_data_source_view.h:191
void setSelectedFieldUsesOwnRange(bool use_own_range)
Set whether the selected field uses its own independent range.
Definition hex_data_source_view.h:199
void setAnnotations(const QVector< ByteViewAnnotation > &annotations)
Replace the current set of user annotations.
Definition hex_data_source_view.cpp:124
virtual void mouseReleaseEvent(QMouseEvent *event)
Finalise a drag selection on mouse release.
Definition hex_data_source_view.cpp:583
virtual void keyPressEvent(QKeyEvent *event)
Handle keyboard navigation and copy commands.
Definition hex_data_source_view.cpp:620
void offsetStartRequested(int byte)
Emitted when the user requests a new offset-start marker.
void setOffsetStart(int byte)
Set the offset-start marker to the given byte.
Definition hex_data_source_view.cpp:162
An interface for objects that can provide a printable data representation.
Definition idata_printable.h:26
packet_char_enc
Types of character encodings.
Definition frame_data.h:39
@ PACKET_CHAR_ENC_CHAR_ASCII
Definition frame_data.h:40
bytes_view_type
Numeric base used to render byte values in the Packet Bytes pane.
Definition recent.h:57
A user-defined color annotation over a byte range.
Definition hex_data_source_view.h:47
QString comment
Definition hex_data_source_view.h:51
int length
Definition hex_data_source_view.h:49
QColor color
Definition hex_data_source_view.h:50
int start
Definition hex_data_source_view.h:48