all repos — mgba @ 3d4faa41e281ff042451032190b3191af2737d5a

mGBA Game Boy Advance Emulator

src/platform/qt/MemoryView.h (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#pragma once
 7
 8#include <QValidator>
 9
10#include "MemoryModel.h"
11
12#include "ui_MemoryView.h"
13
14namespace QGBA {
15
16class CoreController;
17
18class IntValidator : public QValidator {
19Q_OBJECT
20
21public:
22	IntValidator(bool isSigned, QObject* parent = nullptr);
23
24	virtual QValidator::State validate(QString& input, int& pos) const override;
25	void setWidth(int bytes) { m_width = bytes; }
26
27private:
28	int m_width = 1;
29	bool m_signed;
30};
31
32class MemoryView : public QWidget {
33Q_OBJECT
34
35public:
36	MemoryView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
37
38public slots:
39	void update();
40	void jumpToAddress(uint32_t address);
41
42private slots:
43	void setIndex(int);
44	void setSegment(int);
45	void updateSelection(uint32_t start, uint32_t end);
46	void updateStatus();
47	void saveRange();
48
49private:
50	Ui::MemoryView m_ui;
51	IntValidator m_sintValidator{true};
52	IntValidator m_uintValidator{false};
53
54	std::shared_ptr<CoreController> m_controller;
55	QPair<uint32_t, uint32_t> m_region;
56	QPair<uint32_t, uint32_t> m_selection;
57};
58
59}