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)
override;
285 virtual void paintEvent(QPaintEvent *event)
override;
291 virtual void resizeEvent(QResizeEvent *event)
override;
298 virtual void showEvent(QShowEvent *event)
override;
324 virtual void leaveEvent(QEvent *event)
override;
344 struct RowPaintContext {
345 bool has_selection =
false;
351 QColor marker_start_bg;
352 QColor marker_end_bg;
353 int hover_start = -1;
354 int hover_length = 0;
373 QVector<ByteStyle> styles;
374 QVector<ByteStyle> gaps;
380 void updateLayoutMetrics();
387 int stringWidth(
const QString &line);
396 void drawLine(QPainter *painter,
const Row &row,
const RowPaintContext &ctx);
403 void drawOffsetColumn(QPainter *painter,
const Row &row);
414 void drawHexPanel(QPainter *painter,
const Row &row,
const RowPaintContext &ctx);
427 void drawTextPanel(QPainter *painter,
const Row &row,
const RowPaintContext &ctx);
439 void drawMultiByteCell(QPainter *painter,
const ByteViewTextCells::Cell &cell,
int first,
int last,
const Row &row,
const RowPaintContext &ctx);
448 QColor cellTextColor(
const ByteViewTextCells::Cell &cell,
const ByteStyle &style,
const RowPaintContext &ctx);
463 ByteStyle byteStyle(
int offset,
const RowPaintContext &ctx,
int length = 1);
469 QColor annotationBackground(
const ByteViewAnnotation &ann,
const RowPaintContext &ctx);
474 void ensureTextCells();
487 QRect textCellRect(
int col,
int row_y);
495 QRect textSpanRect(
int first_col,
int last_col,
int row_y);
498 int hexCharsPerByte();
504 QString byteText(uint8_t c);
514 QRect hexCellRect(
int col,
int row_y);
522 int hexColumnAtX(
int x,
bool allow_fuzzy);
530 int textColumnAtX(
int x,
bool allow_fuzzy);
538 int annotationIndexAt(
int byte_offset)
const;
547 int annotationIndexIntersecting(
int start,
int length)
const;
556 void updateSelection(
int byte_offset,
bool extend,
bool emit_signal);
564 void updateAnnotationToolTip(
int byte_offset,
const QPoint &global_pos);
571 void scrollToByte(
int byte);
576 void updateScrollbars();
587 int byteOffsetAtPixel(QPoint pos,
bool allow_fuzzy =
false);
592 void createContextMenu();
597 void updateContextMenu();
606 int offsetChars(
bool include_pad =
true);
629 static const int separator_interval_;
635 QColor offset_normal_fg_;
636 QColor offset_field_fg_;
643 int hovered_byte_offset_;
650 int field_hover_start_;
651 int field_hover_len_;
662 QList<QRect> hover_outlines_;
664 bool allow_hover_selection_;
666 QVector<ByteViewAnnotation> annotations_;
669 int selection_anchor_;
670 int selection_start_;
673 int context_byte_offset_;
675 int hovered_annotation_index_;
676 int offset_start_byte_;
677 int offset_end_byte_;
678 bool selected_field_is_protocol_;
679 bool selected_field_use_own_range_;
681 ByteViewTextCells text_cells_;
682 bool text_cells_dirty_;
685 QAction *action_allow_hover_selection_;
686 QAction *action_add_annotation_;
687 QAction *action_edit_annotation_;
688 QAction *action_remove_annotation_;
689 QAction *action_set_offset_start_;
690 QAction *action_set_offset_end_;
691 QAction *action_clear_offset_markers_;
692 QAction *action_bytes_hex_;
693 QAction *action_bytes_dec_;
694 QAction *action_bytes_oct_;
695 QAction *action_bytes_bits_;
696 QAction *action_bytes_enc_from_packet_;
697 QAction *action_bytes_enc_ascii_;
698 QAction *action_bytes_enc_ebcdic_;
699 QAction *action_bytes_enc_utf8_;
706 void copyBytes(
bool unused);
712 void setHexDisplayFormat(QAction *action);
718 void setCharacterEncoding(QAction *action);
724 void toggleHoverAllowed(
bool allowed);
727 void requestAddAnnotation();
730 void requestEditAnnotation();
733 void requestRemoveAnnotation();
736 void requestSetOffsetStart();
739 void requestSetOffsetEnd();
742 void requestClearOffsetMarkers();
QByteArray data_
The raw packet bytes displayed by this view.
Definition base_data_source_view.h:141
BaseDataSourceView(const QByteArray &data, QWidget *parent=nullptr)
Construct a BaseDataSourceView.
Definition base_data_source_view.h:31
Encoding
Character encoding of the data.
Definition byte_view_text_cells.h:39
virtual void mousePressEvent(QMouseEvent *event) override
Begin a byte selection or move the cursor on mouse press.
Definition hex_data_source_view.cpp:582
void markAppendix(int start, int length) override
Highlight the appendix (trailing) bytes of the selected field.
Definition hex_data_source_view.cpp:404
void setMonospaceFont(const QFont &mono_font) override
Update the monospace font and recalculate layout metrics.
Definition hex_data_source_view.cpp:424
int selectionEnd() const
Return the byte offset at the end of the current selection.
Definition hex_data_source_view.cpp:159
virtual void leaveEvent(QEvent *event) override
Clear hover highlights when the pointer leaves the widget.
Definition hex_data_source_view.cpp:648
bool selectedFieldIsProtocol() const
Return whether the selected field is itself a protocol layer.
Definition hex_data_source_view.h:179
virtual void showEvent(QShowEvent *event) override
Ensure the layout is up to date when the widget first becomes visible.
Definition hex_data_source_view.cpp:572
void setFormat(bytes_view_type format)
Set the numeric base used to render hex-panel byte values.
virtual void contextMenuEvent(QContextMenuEvent *event) override
Show the byte-view context menu.
Definition hex_data_source_view.cpp:661
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
void updateByteViewSettings()
Reload byte-view display preferences and repaint.
Definition hex_data_source_view.cpp:440
int dataSize() const
Return the number of bytes in the data buffer.
Definition hex_data_source_view.h:124
int selectionAnchor() const
Return the selection anchor byte offset.
Definition hex_data_source_view.cpp:154
void removeAnnotationRequested()
Emitted when the user triggers "Remove annotation" from the context menu.
virtual void paintEvent(QPaintEvent *event) override
Paint all visible rows of the hex dump.
Definition hex_data_source_view.cpp:450
void clearOffsetMarkers()
Clear both offset markers and repaint.
Definition hex_data_source_view.cpp:190
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.
HexDataSourceView(const QByteArray &data, packet_char_enc encoding=PACKET_CHAR_ENC_CHAR_ASCII, QWidget *parent=nullptr)
Construct a HexDataSourceView.
Definition hex_data_source_view.cpp:70
virtual void resizeEvent(QResizeEvent *event) override
Recalculate scrollbar ranges and repaint after a resize.
Definition hex_data_source_view.cpp:567
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.
Definition hex_data_source_view.cpp:126
int offsetStart() const
Return the current offset-start marker byte position.
Definition hex_data_source_view.h:135
void markProtocol(int start, int length) override
Highlight the enclosing protocol layer byte range.
Definition hex_data_source_view.cpp:382
int contextByteOffset() const
Return the byte offset at which the context menu was invoked.
Definition hex_data_source_view.cpp:164
int selectedProtocolLength() const
Definition hex_data_source_view.h:172
int selectedFieldLength() const
Definition hex_data_source_view.h:166
virtual void mouseReleaseEvent(QMouseEvent *event) override
Finalise a drag selection on mouse release.
Definition hex_data_source_view.cpp:634
void unmarkField() override
Clear field, appendix, and hover highlights.
Definition hex_data_source_view.cpp:411
bool selectionRange(int *start, int *length) const
Return the current byte selection range.
Definition hex_data_source_view.cpp:138
virtual void keyPressEvent(QKeyEvent *event) override
Handle keyboard navigation and copy commands.
Definition hex_data_source_view.cpp:671
void setOffsetEnd(int byte)
Set the offset-end marker to the given byte.
Definition hex_data_source_view.cpp:178
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:131
virtual void mouseMoveEvent(QMouseEvent *event) override
Extend the selection during a mouse drag.
Definition hex_data_source_view.cpp:604
void offsetStartRequested(int byte)
Emitted when the user requests a new offset-start marker.
void markField(int start, int length, bool scroll_to=true, bool hover=false) override
Highlight a specific dissected field byte range.
Definition hex_data_source_view.cpp:389
void setOffsetStart(int byte)
Set the offset-start marker to the given byte.
Definition hex_data_source_view.cpp:169
An interface for objects that can provide a printable data representation.
Definition idata_printable.h:26
virtual const QByteArray printableData()=0
Retrieves the printable data representation of the object.
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:61
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