| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
#include <mutex> |
| 6 |
|
| 7 |
#include <QStyledItemDelegate> |
| 8 |
#include <QWidget> |
| 9 |
|
| 10 |
#include "Common/CommonTypes.h" |
| 11 |
|
| 12 |
class QFont; |
| 13 |
class QPoint; |
| 14 |
class QScrollBar; |
| 15 |
|
| 16 |
namespace AddressSpace |
| 17 |
{ |
| 18 |
enum class Type; |
| 19 |
} |
| 20 |
|
| 21 |
namespace Core |
| 22 |
{ |
| 23 |
class CPUThreadGuard; |
| 24 |
class System; |
| 25 |
} |
| 26 |
|
| 27 |
class PPCSymbolDB; |
| 28 |
|
| 29 |
|
| 30 |
class TableEditDelegate : public QStyledItemDelegate |
| 31 |
{ |
| 32 |
Q_OBJECT |
| 33 |
|
| 34 |
public: |
| 35 |
explicit TableEditDelegate(QObject* parent) : QStyledItemDelegate(parent) {} |
| 36 |
|
| 37 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
| 38 |
const QModelIndex& index) const override; |
| 39 |
|
| 40 |
signals: |
| 41 |
void editFinished(const int row, const int column, const QString& text) const; |
| 42 |
}; |
| 43 |
|
| 44 |
class MemoryViewTable; |
| 45 |
|
| 46 |
class MemoryViewWidget final : public QWidget |
| 47 |
{ |
| 48 |
Q_OBJECT |
| 49 |
public: |
| 50 |
enum class Type : int |
| 51 |
{ |
| 52 |
Null = 0, |
| 53 |
Hex8 = 1, |
| 54 |
Hex16, |
| 55 |
Hex32, |
| 56 |
Hex64, |
| 57 |
HexString, |
| 58 |
Unsigned8, |
| 59 |
Unsigned16, |
| 60 |
Unsigned32, |
| 61 |
Signed8, |
| 62 |
Signed16, |
| 63 |
Signed32, |
| 64 |
ASCII, |
| 65 |
Float32, |
| 66 |
Double |
| 67 |
}; |
| 68 |
|
| 69 |
enum class BPType |
| 70 |
{ |
| 71 |
ReadWrite, |
| 72 |
ReadOnly, |
| 73 |
WriteOnly |
| 74 |
}; |
| 75 |
|
| 76 |
enum class UpdateType |
| 77 |
{ |
| 78 |
Full, |
| 79 |
Addresses, |
| 80 |
Values, |
| 81 |
Symbols, |
| 82 |
Auto, |
| 83 |
}; |
| 84 |
|
| 85 |
enum class EditSymbolType |
| 86 |
{ |
| 87 |
AddNote, |
| 88 |
EditNote, |
| 89 |
EditRegion, |
| 90 |
}; |
| 91 |
|
| 92 |
explicit MemoryViewWidget(Core::System& system, QWidget* parent = nullptr); |
| 93 |
|
| 94 |
void CreateTable(); |
| 95 |
void UpdateDispatcher(UpdateType type = UpdateType::Addresses); |
| 96 |
void Update(); |
| 97 |
void UpdateSymbols(); |
| 98 |
void UpdateOnFrameEnd(); |
| 99 |
void GetValues(); |
| 100 |
void UpdateFont(const QFont& font); |
| 101 |
void ToggleBreakpoint(u32 addr, bool row); |
| 102 |
|
| 103 |
std::vector<u8> ConvertTextToBytes(Type type, QStringView input_text) const; |
| 104 |
void SetAddressSpace(AddressSpace::Type address_space); |
| 105 |
AddressSpace::Type GetAddressSpace() const; |
| 106 |
void SetDisplay(Type type, int bytes_per_row, int alignment, bool dual_view); |
| 107 |
void ToggleHighlights(bool enabled); |
| 108 |
void SetHighlightColor(); |
| 109 |
void SetBPType(BPType type); |
| 110 |
void SetAddress(u32 address); |
| 111 |
void SetFocus() const; |
| 112 |
void ShowSymbols(bool enable); |
| 113 |
|
| 114 |
void SetBPLoggingEnabled(bool enabled); |
| 115 |
|
| 116 |
signals: |
| 117 |
void AutoUpdate(); |
| 118 |
void ShowCode(u32 address); |
| 119 |
void RequestWatch(QString name, u32 address); |
| 120 |
void ActivateSearch(); |
| 121 |
|
| 122 |
private: |
| 123 |
void OnEditSymbol(EditSymbolType type, u32 addr); |
| 124 |
void OnContextMenu(const QPoint& pos); |
| 125 |
void OnCopyAddress(u32 addr); |
| 126 |
void OnCopyHex(u32 addr); |
| 127 |
void UpdateBreakpointTags(); |
| 128 |
void TriggerActivateSearch(); |
| 129 |
void UpdateColumns(); |
| 130 |
void ScrollbarActionTriggered(int action); |
| 131 |
void ScrollbarSliderReleased(); |
| 132 |
|
| 133 |
std::optional<QString> ValueToString(const Core::CPUThreadGuard& guard, u32 address, Type type); |
| 134 |
|
| 135 |
Core::System& m_system; |
| 136 |
PPCSymbolDB& m_ppc_symbol_db; |
| 137 |
|
| 138 |
MemoryViewTable* m_table; |
| 139 |
QScrollBar* m_scrollbar; |
| 140 |
AddressSpace::Type m_address_space{}; |
| 141 |
Type m_type = Type::Hex32; |
| 142 |
BPType m_bp_type = BPType::ReadWrite; |
| 143 |
bool m_do_log = true; |
| 144 |
u32 m_address = 0x80000000; |
| 145 |
std::pair<u32, u32> m_address_range; |
| 146 |
std::map<u32, std::optional<QString>> m_values; |
| 147 |
std::map<u32, std::optional<QString>> m_values_dual_view; |
| 148 |
u32 m_address_highlight = 0; |
| 149 |
int m_font_width = 0; |
| 150 |
int m_font_vspace = 0; |
| 151 |
int m_bytes_per_row = 16; |
| 152 |
int m_alignment = 16; |
| 153 |
int m_data_columns; |
| 154 |
bool m_dual_view = false; |
| 155 |
bool m_show_symbols = true; |
| 156 |
std::mutex m_updating; |
| 157 |
QColor m_highlight_color = QColor(120, 255, 255, 100); |
| 158 |
|
| 159 |
friend class MemoryViewTable; |
| 160 |
}; |