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

59 lines
1.5 KiB
C
Raw 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
2019-12-21 18:05:47 +00:00
class CQtMemoryViewModel : 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;
typedef std::string (CQtMemoryViewModel::*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;
};
CQtMemoryViewModel(QObject*, getByteProto = nullptr, int = 0);
2020-02-06 14:12:26 +00:00
~CQtMemoryViewModel() = 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 DoubleClicked(const QModelIndex& index, QWidget* parent = nullptr);
void Redraw();
unsigned int BytesForCurrentLine() const;
2020-12-25 03:13:53 +00:00
void SetColumnCount(unsigned int);
2019-12-19 11:58:52 +00:00
unsigned int CharsPerUnit() const;
void SetActiveUnit(int);
int GetActiveUnit();
2020-12-25 03:13:53 +00:00
unsigned int GetBytesPerUnit() const;
2019-12-19 11:58:52 +00:00
2019-12-21 18:48:44 +00:00
void SetData(getByteProto, int);
2019-12-19 11:58:52 +00:00
static std::vector<UNITINFO> g_units;
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;
getByteProto m_getByte = nullptr;
2019-12-19 11:58:52 +00:00
int m_activeUnit;
unsigned int m_size;
2020-12-25 03:13:53 +00:00
std::atomic<unsigned int> m_columnCount = 0x2;
2019-12-19 11:58:52 +00:00
};