summaryrefslogtreecommitdiff
path: root/examples/triage/sections.h
blob: d4cdb29e685c7b8613f6670bdc75f69d95fb0cc3 (plain)
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
#pragma once

#include <QtWidgets/QWidget>
#include "uitypes.h"


class SegmentsWidget : public QWidget
{
	std::vector<SegmentRef> m_segments;

  public:
	SegmentsWidget(QWidget* parent, BinaryViewRef data);
	const std::vector<SegmentRef>& GetSegments() const { return m_segments; }
};


class SectionsModel : public QObject, public BinaryNinja::BinaryDataNotification
{
	Q_OBJECT

	BinaryViewRef m_data;
	std::vector<SectionRef> m_sections;

	void updateSections();

signals:
	void sectionsChanged();

  public:
	SectionsModel(QObject* parent, BinaryViewRef data);
	virtual ~SectionsModel();

	const std::vector<SectionRef>& GetSections() const { return m_sections; }

	virtual void OnSectionAdded(BinaryNinja::BinaryView* data, BinaryNinja::Section* section) override;
	virtual void OnSectionRemoved(BinaryNinja::BinaryView* data, BinaryNinja::Section* section) override;
	virtual void OnSectionUpdated(BinaryNinja::BinaryView* data, BinaryNinja::Section* section) override;
};


class SectionsWidget : public QWidget
{
	Q_OBJECT

	BinaryViewRef m_data;
	SectionsModel* m_model;
	QGridLayout* m_layout;
	bool m_isRebuilding;

	void rebuildLayout();

  public:
	SectionsWidget(QWidget* parent, BinaryViewRef data);
	virtual ~SectionsWidget();
	const std::vector<SectionRef>& GetSections() const { return m_model->GetSections(); }
};