Play-/Source/ui_qt/DebugSupport/MemoryViewModel.h

64 lines
1.6 KiB
C
Raw Permalink Normal View History

2019-12-19 11:58:52 +00:00
#pragma once
#include <QAbstractTableModel>
2019-12-21 18:05:47 +00:00
#include <functional>
2019-12-19 11:58:52 +00:00
2019-12-21 18:05:47 +00:00
#include "Types.h"
2019-12-19 11:58:52 +00:00
2024-03-21 14:24:08 -04:00
class CMemoryViewModel : public QAbstractTableModel
2019-12-19 11:58:52 +00:00
{
Q_OBJECT
public:
2019-12-21 18:05:47 +00:00
typedef std::function<uint8(uint32)> getByteProto;
2024-03-21 14:24:08 -04:00
typedef std::string (CMemoryViewModel::*UnitRenderer)(uint32) const;
2019-12-19 11:58:52 +00:00
struct UNITINFO
{
unsigned int bytesPerUnit = 0;
unsigned int charsPerUnit = 0;
UnitRenderer renderer = nullptr;
const char* description = nullptr;
};
2024-03-21 14:24:08 -04:00
CMemoryViewModel(QObject*);
~CMemoryViewModel() = default;
2019-12-19 11:58:52 +00:00
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
void Redraw();
2024-03-19 16:29:42 -04:00
unsigned int GetBytesPerRow() const;
void SetBytesPerRow(unsigned int);
2019-12-19 11:58:52 +00:00
void SetActiveUnit(int);
2024-03-19 16:29:42 -04:00
int GetActiveUnit() const;
2020-12-25 03:13:53 +00:00
unsigned int GetBytesPerUnit() const;
2024-03-19 16:29:42 -04:00
unsigned int CharsPerUnit() const;
2019-12-19 11:58:52 +00:00
void SetData(getByteProto, uint64, uint32 = 0);
void SetWindowCenter(uint32);
2024-03-19 16:29:42 -04:00
uint32 TranslateModelIndexToAddress(const QModelIndex&) const;
QModelIndex TranslateAddressToModelIndex(uint32) const;
2024-03-13 07:23:42 -04:00
static const std::vector<UNITINFO> g_units;
2019-12-19 11:58:52 +00:00
protected:
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
private:
uint8 GetByte(uint32) const;
std::string RenderByteUnit(uint32) const;
std::string RenderWordUnit(uint32) const;
std::string RenderSingleUnit(uint32) const;
2024-03-19 16:29:42 -04:00
getByteProto m_getByte;
int m_activeUnit = 0;
uint32 m_windowStart = 0;
uint32 m_windowSize = 0;
uint64 m_size = 0;
2024-03-19 16:29:42 -04:00
unsigned int m_bytesPerRow = 0x2;
2019-12-19 11:58:52 +00:00
};