1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#pragma once
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
#include <QtWidgets/QGridLayout>
#include <QtCore/QTimer>
#include <QtGui/QScreen>
#include <QtGui/QWindow>
#include <QtGui/QGuiApplication>
#include <functional>
#include "uitypes.h"
#include "copyablelabel.h"
#include "uicontext.h"
// Responsive layout breakpoints (logical pixels)
namespace TriageBreakpoints {
constexpr int NARROW = 1000;
constexpr int MEDIUM = 1400;
}
class NavigationLabel : public QLabel
{
std::function<void()> m_func;
public:
NavigationLabel(const QString& text, QColor color, const std::function<void()>& func);
protected:
virtual void mousePressEvent(QMouseEvent* event) override;
};
class NavigationAddressLabel : public NavigationLabel
{
void clickEvent();
public:
NavigationAddressLabel(const QString& text);
};
class NavigationCodeLabel : public NavigationLabel
{
void clickEvent();
public:
NavigationCodeLabel(const QString& text);
};
enum HeaderFieldType
{
TextHeaderField,
AddressHeaderField,
CodeHeaderField
};
struct HeaderField
{
QString title;
std::vector<QString> values;
HeaderFieldType type;
};
class Headers
{
std::vector<HeaderField> m_fields;
size_t m_columns, m_rowsPerColumn;
public:
Headers();
void AddField(const QString& title, const QString& value, HeaderFieldType type = TextHeaderField);
void AddField(const QString& title, const std::vector<QString>& values, HeaderFieldType type = TextHeaderField);
const std::vector<HeaderField>& GetFields() const { return m_fields; }
void SetColumns(size_t cols) { m_columns = cols; }
void SetRowsPerColumn(size_t rows) { m_rowsPerColumn = rows; }
size_t GetColumns() const { return m_columns; }
size_t GetRowsPerColumn() const { return m_rowsPerColumn; }
};
class GenericHeaders : public Headers
{
public:
GenericHeaders(BinaryViewRef data);
};
class PEHeaders : public Headers
{
uint64_t GetValueOfStructMember(
BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName);
uint64_t GetAddressAfterStruct(BinaryViewRef data, const std::string& structName, uint64_t structStart);
QString GetNameOfEnumerationMember(BinaryViewRef data, const std::string& enumName, uint64_t value);
public:
PEHeaders(BinaryViewRef data);
};
class HeaderWidget : public QWidget
{
Q_OBJECT
Headers m_headers;
QGridLayout* m_layout;
int m_currentColumns;
int m_pendingWidth;
QTimer* m_resizeTimer;
void rebuildLayout();
public:
HeaderWidget(QWidget* parent, const Headers& headers);
void updateColumns(int width);
protected:
virtual void resizeEvent(QResizeEvent* event) override;
private slots:
void performDelayedResize();
};
|