Qt/MemoryWidget: Allow operating on columns
This commit is contained in:
parent
390fb37a29
commit
5f5b05f3dc
|
@ -86,12 +86,6 @@ void MemoryViewWidget::Update()
|
||||||
bp_item->setFlags(Qt::ItemIsEnabled);
|
bp_item->setFlags(Qt::ItemIsEnabled);
|
||||||
bp_item->setData(Qt::UserRole, addr);
|
bp_item->setData(Qt::UserRole, addr);
|
||||||
|
|
||||||
if (PowerPC::memchecks.OverlapsMemcheck(addr, 16))
|
|
||||||
{
|
|
||||||
bp_item->setData(Qt::DecorationRole,
|
|
||||||
Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(24, 24)));
|
|
||||||
}
|
|
||||||
|
|
||||||
setItem(i, 0, bp_item);
|
setItem(i, 0, bp_item);
|
||||||
|
|
||||||
auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')));
|
auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')));
|
||||||
|
@ -126,23 +120,32 @@ void MemoryViewWidget::Update()
|
||||||
|
|
||||||
setItem(i, columnCount() - 1, description_item);
|
setItem(i, columnCount() - 1, description_item);
|
||||||
|
|
||||||
auto update_values = [this, i, addr](auto value_to_string) {
|
bool row_breakpoint = true;
|
||||||
|
|
||||||
|
auto update_values = [&](auto value_to_string) {
|
||||||
for (int c = 0; c < GetColumnCount(m_type); c++)
|
for (int c = 0; c < GetColumnCount(m_type); c++)
|
||||||
{
|
{
|
||||||
auto* hex_item = new QTableWidgetItem;
|
auto* hex_item = new QTableWidgetItem;
|
||||||
|
hex_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
const u32 address = addr + c * (16 / GetColumnCount(m_type));
|
const u32 address = addr + c * (16 / GetColumnCount(m_type));
|
||||||
|
|
||||||
|
if (PowerPC::memchecks.OverlapsMemcheck(address, 16 / GetColumnCount(m_type)))
|
||||||
|
hex_item->setBackground(Qt::red);
|
||||||
|
else
|
||||||
|
row_breakpoint = false;
|
||||||
|
|
||||||
|
setItem(i, 2 + c, hex_item);
|
||||||
|
|
||||||
if (PowerPC::HostIsRAMAddress(address))
|
if (PowerPC::HostIsRAMAddress(address))
|
||||||
{
|
{
|
||||||
hex_item->setText(value_to_string(address));
|
hex_item->setText(value_to_string(address));
|
||||||
hex_item->setFlags(Qt::ItemIsEnabled);
|
hex_item->setData(Qt::UserRole, address);
|
||||||
hex_item->setData(Qt::UserRole, addr);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hex_item->setFlags(0);
|
hex_item->setFlags(0);
|
||||||
hex_item->setText(QStringLiteral("-"));
|
hex_item->setText(QStringLiteral("-"));
|
||||||
}
|
}
|
||||||
setItem(i, 2 + c, hex_item);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,6 +179,12 @@ void MemoryViewWidget::Update()
|
||||||
update_values([](u32 address) { return QString::number(PowerPC::HostRead_F32(address)); });
|
update_values([](u32 address) { return QString::number(PowerPC::HostRead_F32(address)); });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (row_breakpoint)
|
||||||
|
{
|
||||||
|
bp_item->setData(Qt::DecorationRole,
|
||||||
|
Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(24, 24)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setColumnWidth(0, 24 + 5);
|
setColumnWidth(0, 24 + 5);
|
||||||
|
@ -254,17 +263,18 @@ u32 MemoryViewWidget::GetContextAddress() const
|
||||||
return m_context_address;
|
return m_context_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryViewWidget::ToggleBreakpoint()
|
void MemoryViewWidget::ToggleRowBreakpoint(bool row)
|
||||||
{
|
{
|
||||||
u32 addr = GetContextAddress();
|
TMemCheck check;
|
||||||
|
|
||||||
if (!PowerPC::memchecks.OverlapsMemcheck(addr, 16))
|
const u32 addr = row ? GetContextAddress() & 0xFFFFFFF0 : GetContextAddress();
|
||||||
|
const auto length = row ? 16 : (16 / GetColumnCount(m_type));
|
||||||
|
|
||||||
|
if (!PowerPC::memchecks.OverlapsMemcheck(addr, length))
|
||||||
{
|
{
|
||||||
TMemCheck check;
|
|
||||||
|
|
||||||
check.start_address = addr;
|
check.start_address = addr;
|
||||||
check.end_address = check.start_address + 15;
|
check.end_address = check.start_address + length - 1;
|
||||||
check.is_ranged = true;
|
check.is_ranged = length > 0;
|
||||||
check.is_break_on_read = (m_bp_type == BPType::ReadOnly || m_bp_type == BPType::ReadWrite);
|
check.is_break_on_read = (m_bp_type == BPType::ReadOnly || m_bp_type == BPType::ReadWrite);
|
||||||
check.is_break_on_write = (m_bp_type == BPType::WriteOnly || m_bp_type == BPType::ReadWrite);
|
check.is_break_on_write = (m_bp_type == BPType::WriteOnly || m_bp_type == BPType::ReadWrite);
|
||||||
check.log_on_hit = m_do_log;
|
check.log_on_hit = m_do_log;
|
||||||
|
@ -281,6 +291,11 @@ void MemoryViewWidget::ToggleBreakpoint()
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryViewWidget::ToggleBreakpoint()
|
||||||
|
{
|
||||||
|
ToggleRowBreakpoint(false);
|
||||||
|
}
|
||||||
|
|
||||||
void MemoryViewWidget::wheelEvent(QWheelEvent* event)
|
void MemoryViewWidget::wheelEvent(QWheelEvent* event)
|
||||||
{
|
{
|
||||||
int delta = event->delta() > 0 ? -1 : 1;
|
int delta = event->delta() > 0 ? -1 : 1;
|
||||||
|
@ -303,9 +318,9 @@ void MemoryViewWidget::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
case Qt::LeftButton:
|
case Qt::LeftButton:
|
||||||
if (column(item) == 0)
|
if (column(item) == 0)
|
||||||
ToggleBreakpoint();
|
ToggleRowBreakpoint(true);
|
||||||
else
|
else
|
||||||
SetAddress(addr);
|
SetAddress(addr & 0xFFFFFFF0);
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
break;
|
break;
|
||||||
|
@ -324,11 +339,12 @@ void MemoryViewWidget::OnCopyHex()
|
||||||
{
|
{
|
||||||
u32 addr = GetContextAddress();
|
u32 addr = GetContextAddress();
|
||||||
|
|
||||||
u64 a = PowerPC::HostRead_U64(addr);
|
const auto length = 16 / GetColumnCount(m_type);
|
||||||
u64 b = PowerPC::HostRead_U64(addr + sizeof(u64));
|
|
||||||
|
u64 value = PowerPC::HostRead_U64(addr);
|
||||||
|
|
||||||
QApplication::clipboard()->setText(
|
QApplication::clipboard()->setText(
|
||||||
QStringLiteral("%1%2").arg(a, 16, 16, QLatin1Char('0')).arg(b, 16, 16, QLatin1Char('0')));
|
QStringLiteral("%1").arg(value, length * 2, 16, QLatin1Char('0')).left(length * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryViewWidget::OnContextMenu()
|
void MemoryViewWidget::OnContextMenu()
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
void ToggleBreakpoint();
|
void ToggleBreakpoint();
|
||||||
|
void ToggleRowBreakpoint(bool row);
|
||||||
|
|
||||||
void SetType(Type type);
|
void SetType(Type type);
|
||||||
void SetBPType(BPType type);
|
void SetBPType(BPType type);
|
||||||
|
|
Loading…
Reference in New Issue