mirror of https://github.com/PCSX2/pcsx2.git
Debugger: Humanise CSV exporting
An oversight of the old system was that all integers were converted to hexadecimal
This commit is contained in:
parent
e1bfd95f63
commit
582c23bae8
|
@ -246,7 +246,7 @@ void CpuWidget::onBPListDoubleClicked(const QModelIndex& index)
|
|||
{
|
||||
if (index.column() == BreakpointModel::OFFSET)
|
||||
{
|
||||
m_ui.disassemblyWidget->gotoAddress(m_bpModel.data(index, Qt::UserRole).toUInt());
|
||||
m_ui.disassemblyWidget->gotoAddress(m_bpModel.data(index, BreakpointModel::DataRole).toUInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ void CpuWidget::onBPListContextMenu(QPoint pos)
|
|||
contextMenu->addSeparator();
|
||||
QAction* actionExport = new QAction(tr("Copy all as CSV"), m_ui.breakpointList);
|
||||
connect(actionExport, &QAction::triggered, [this]() {
|
||||
// It's important to use the User Role here to allow pasting to be translation agnostic
|
||||
QGuiApplication::clipboard()->setText(QtUtils::AbstractItemModelToCSV(m_ui.breakpointList->model(), Qt::UserRole));
|
||||
// It's important to use the Export Role here to allow pasting to be translation agnostic
|
||||
QGuiApplication::clipboard()->setText(QtUtils::AbstractItemModelToCSV(m_ui.breakpointList->model(), BreakpointModel::ExportRole));
|
||||
});
|
||||
contextMenu->addAction(actionExport);
|
||||
|
||||
|
@ -429,7 +429,7 @@ void CpuWidget::contextBPListPasteCSV()
|
|||
}
|
||||
|
||||
// Size
|
||||
mc.end = fields[2].toUInt(&ok, 16) + mc.start;
|
||||
mc.end = fields[2].toUInt(&ok) + mc.start;
|
||||
if (!ok)
|
||||
{
|
||||
Console.WriteLn("Debugger CSV Import: Failed to parse length '%s', skipping", fields[1].toUtf8().constData());
|
||||
|
|
|
@ -98,7 +98,7 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
else if (role == BreakpointModel::DataRole)
|
||||
{
|
||||
auto bp_mc = m_breakpoints.at(index.row());
|
||||
|
||||
|
@ -144,6 +144,52 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (role == BreakpointModel::ExportRole)
|
||||
{
|
||||
auto bp_mc = m_breakpoints.at(index.row());
|
||||
|
||||
if (const auto* bp = std::get_if<BreakPoint>(&bp_mc))
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case BreakpointColumns::TYPE:
|
||||
return MEMCHECK_INVALID;
|
||||
case BreakpointColumns::OFFSET:
|
||||
return QtUtils::FilledQStringFromValue(bp->addr, 16);
|
||||
case BreakpointColumns::SIZE_LABEL:
|
||||
return m_cpu.GetSymbolMap().GetLabelString(bp->addr).c_str();
|
||||
case BreakpointColumns::OPCODE:
|
||||
// Note: Fix up the disassemblymanager so we can use it here, instead of calling a function through the disassemblyview (yuck)
|
||||
return m_cpu.disasm(bp->addr, true).c_str();
|
||||
case BreakpointColumns::CONDITION:
|
||||
return bp->hasCond ? QString::fromLocal8Bit(bp->cond.expressionString) : tr("");
|
||||
case BreakpointColumns::HITS:
|
||||
return 0;
|
||||
case BreakpointColumns::ENABLED:
|
||||
return static_cast<int>(bp->enabled);
|
||||
}
|
||||
}
|
||||
else if (const auto* mc = std::get_if<MemCheck>(&bp_mc))
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case BreakpointColumns::TYPE:
|
||||
return mc->cond;
|
||||
case BreakpointColumns::OFFSET:
|
||||
return QtUtils::FilledQStringFromValue(mc->start, 16);
|
||||
case BreakpointColumns::SIZE_LABEL:
|
||||
return mc->end - mc->start;
|
||||
case BreakpointColumns::OPCODE:
|
||||
return "";
|
||||
case BreakpointColumns::CONDITION:
|
||||
return "";
|
||||
case BreakpointColumns::HITS:
|
||||
return mc->numHits;
|
||||
case BreakpointColumns::ENABLED:
|
||||
return (mc->result & MEMCHECK_BREAK);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (index.column() == 6)
|
||||
|
|
|
@ -38,6 +38,12 @@ public:
|
|||
COLUMN_COUNT
|
||||
};
|
||||
|
||||
enum BreakpointRoles : int
|
||||
{
|
||||
DataRole = Qt::UserRole,
|
||||
ExportRole = Qt::UserRole + 1,
|
||||
};
|
||||
|
||||
explicit BreakpointModel(DebugInterface& cpu, QObject* parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
|
|
@ -287,16 +287,7 @@ namespace QtUtils
|
|||
{
|
||||
for (int col = 0; col < model->columnCount(); col++)
|
||||
{
|
||||
switch(model->data(model->index(row, col), role).metaType().id())
|
||||
{
|
||||
case QMetaType::Int:
|
||||
case QMetaType::UInt:
|
||||
csv += QString::number(model->data(model->index(row, col), role).toUInt(nullptr), 16);
|
||||
break;
|
||||
default:
|
||||
csv += model->data(model->index(row, col), role).toString();
|
||||
break;
|
||||
}
|
||||
|
||||
if (col < model->columnCount() - 1)
|
||||
csv += ",";
|
||||
|
|
Loading…
Reference in New Issue