Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
json_data_source_view.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <config.h>
13
15
17
18#include <QAbstractScrollArea>
19#include <QTextLayout>
20
21class QTextLayout;
22
23struct TextLine {
24 QString line;
25#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
26 QList<QTextLayout::FormatRange> fmt_list;
27#else
28 QVector<QTextLayout::FormatRange> fmt_list;
29#endif
30 int highlight_start;
31 int highlight_length;
32 int field_start;
33 int field_length;
34};
35
36struct TextBlock {
37 QList<TextLine> text_lines;
38};
39
41{
42 Q_OBJECT
43public:
44 explicit JsonDataSourceView(const QByteArray &data, proto_node *root_node, QWidget *parent = nullptr);
46
47signals:
48 void fieldSelected(FieldInformation *);
49 void fieldHighlight(FieldInformation *);
50
51public slots:
52 void setMonospaceFont(const QFont &mono_font);
53
54 void markField(int start, int length, bool scroll_to = true);
55 void unmarkField();
56 // We're assuming that we have a 1:1 correspondence between the view and a single protocol.
57 void markProtocol(int start, int length) {Q_UNUSED(start) Q_UNUSED(length)}
58 void markAppendix(int start, int length) {Q_UNUSED(start) Q_UNUSED(length)}
59
60protected:
61 // virtual bool event(QEvent *event);
62 virtual void paintEvent(QPaintEvent *);
63 virtual void resizeEvent(QResizeEvent *);
64 virtual void keyPressEvent(QKeyEvent *event);
65 virtual void mousePressEvent (QMouseEvent *event);
66 virtual void mouseMoveEvent (QMouseEvent * event);
67 virtual void leaveEvent(QEvent *event);
68
69private:
70 void updateLayoutMetrics();
71 int stringWidth(const QString &line);
72 void updateScrollbars();
73
74 void addTextLine(TextBlock &text_block, TextLine &text_line, const QString &next_line = QString());
75 bool prettyPrintPlain(const char *in_buf, QString &out_str);
76 bool addJsonObject();
77
78 int offsetChars(bool include_pad = true);
79 int offsetPixels();
80 const TextLine *findTextLine(int line);
81
82 QTextLayout *layout_;
83 QList<TextBlock> text_blocks_;
84
85 bool show_offset_; // Should we show the byte offset?
86 int em_width_; // Single character width and text margin. NOTE: Use fontMetrics::width for multiple characters.
87 int line_height_; // Font line spacing
88 qsizetype max_line_length_; // In characters
89
90 proto_node *root_node_;
91 const TextLine *selected_line_;
92 const TextLine *hovered_line_;
93};
Definition base_data_source_view.h:17
Definition field_information.h:23
Definition json_data_source_view.h:41
Definition proto.h:906
Definition json_data_source_view.h:36
Definition json_data_source_view.h:23