Array element offset display, fold arrow UX, type picker popup, and provider cleanup

- Show relative hex offset on array element separators ([N] +0x...)
- Dim fold arrows and add hover highlight for better visibility
- Extend fold/chevron click areas for easier interaction
- Add type picker popup for array element type and pointer target editing
- Remove process_provider.h in favor of plugin-based provider system
- Expand compose/format to handle struct-of-array type names and widths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
IChooseYou
2026-02-11 09:13:17 -07:00
committed by sysadmin
parent 3db051f4ba
commit df07b61144
16 changed files with 373 additions and 184 deletions

View File

@@ -172,16 +172,19 @@ void composeLeaf(ComposeState& state, const NodeTree& tree,
void composeNode(ComposeState& state, const NodeTree& tree,
const Provider& prov, int nodeIdx, int depth,
uint64_t base = 0, uint64_t rootId = 0, bool isArrayChild = false,
uint64_t scopeId = 0, int arrayElementIdx = -1);
uint64_t scopeId = 0, int arrayElementIdx = -1,
uint64_t arrayContainerAddr = 0);
void composeParent(ComposeState& state, const NodeTree& tree,
const Provider& prov, int nodeIdx, int depth,
uint64_t base = 0, uint64_t rootId = 0, bool isArrayChild = false,
uint64_t scopeId = 0, int arrayElementIdx = -1);
uint64_t scopeId = 0, int arrayElementIdx = -1,
uint64_t arrayContainerAddr = 0);
void composeParent(ComposeState& state, const NodeTree& tree,
const Provider& prov, int nodeIdx, int depth,
uint64_t base, uint64_t rootId, bool isArrayChild,
uint64_t scopeId, int arrayElementIdx) {
uint64_t scopeId, int arrayElementIdx,
uint64_t arrayContainerAddr) {
const Node& node = tree.nodes[nodeIdx];
uint64_t absAddr = resolveAddr(state, tree, nodeIdx, base, rootId);
@@ -214,7 +217,9 @@ void composeParent(ComposeState& state, const NodeTree& tree,
lm.foldLevel = computeFoldLevel(depth, false);
lm.markerMask = 0;
lm.arrayElementIdx = arrayElementIdx;
state.emitLine(fmt::indent(depth) + QStringLiteral("[%1]").arg(arrayElementIdx), lm);
uint64_t relOff = absAddr - arrayContainerAddr;
QString relOffHex = QString::number(relOff, 16).toUpper();
state.emitLine(fmt::indent(depth) + QStringLiteral("[%1] +0x%2").arg(arrayElementIdx).arg(relOffHex), lm);
}
// Detect root header: first root-level struct — suppressed from display
@@ -252,7 +257,9 @@ void composeParent(ComposeState& state, const NodeTree& tree,
lm.elementKind = node.elementKind;
lm.arrayViewIdx = node.viewIndex;
lm.arrayCount = node.arrayLen;
headerText = fmt::fmtArrayHeader(node, depth, node.viewIndex, node.collapsed, typeW, nameW);
QString elemStructName = (node.elementKind == NodeKind::Struct)
? resolvePointerTarget(tree, node.refId) : QString();
headerText = fmt::fmtArrayHeader(node, depth, node.viewIndex, node.collapsed, typeW, nameW, elemStructName);
} else {
// All structs (root and nested) use the same header format
headerText = fmt::fmtStructHeader(node, depth, node.collapsed, typeW, nameW);
@@ -268,6 +275,61 @@ void composeParent(ComposeState& state, const NodeTree& tree,
int childDepth = depth + 1;
// Primitive arrays with no child nodes: synthesize element lines dynamically
if (node.kind == NodeKind::Array && children.isEmpty()
&& node.elementKind != NodeKind::Struct && node.elementKind != NodeKind::Array) {
int elemSize = sizeForKind(node.elementKind);
int eTW = state.effectiveTypeW(node.id);
int eNW = state.effectiveNameW(node.id);
for (int i = 0; i < node.arrayLen; i++) {
uint64_t elemAddr = absAddr + i * elemSize;
// Type override: "float[0]", "uint32_t[1]", etc.
QString elemTypeStr = fmt::typeNameRaw(node.elementKind)
+ QStringLiteral("[%1]").arg(i);
Node elem;
elem.kind = node.elementKind;
elem.name = QString(); // no name for array elements
elem.offset = node.offset + i * elemSize;
elem.parentId = node.id;
elem.id = 0;
LineMeta lm;
lm.nodeIdx = nodeIdx;
lm.nodeId = node.id;
lm.depth = childDepth;
lm.lineKind = LineKind::Field;
lm.nodeKind = node.elementKind;
lm.isArrayElement = true;
lm.offsetText = fmt::fmtOffsetMargin(tree.baseAddress + elemAddr, false, state.offsetHexDigits);
lm.markerMask = computeMarkers(elem, prov, elemAddr, false, childDepth);
lm.foldLevel = computeFoldLevel(childDepth, false);
lm.effectiveTypeW = eTW;
lm.effectiveNameW = eNW;
state.emitLine(fmt::fmtNodeLine(elem, prov, elemAddr, childDepth, 0,
{}, eTW, eNW, elemTypeStr), lm);
}
}
// Struct arrays with refId but no child nodes: synthesize by expanding the
// referenced struct for each element (like repeated pointer deref)
if (node.kind == NodeKind::Array && children.isEmpty()
&& node.elementKind == NodeKind::Struct && node.refId != 0) {
int refIdx = tree.indexOfId(node.refId);
if (refIdx >= 0) {
int elemSize = tree.structSpan(node.refId, &state.childMap);
if (elemSize <= 0) elemSize = 1;
for (int i = 0; i < node.arrayLen; i++) {
uint64_t elemBase = absAddr + (uint64_t)i * elemSize;
// Use base offset that maps refStruct's children to the right provider address
composeParent(state, tree, prov, refIdx, childDepth, elemBase, node.refId,
/*isArrayChild=*/true, node.id, i, absAddr);
}
}
}
// For arrays, render children as condensed (no header/footer for struct elements)
bool childrenAreArrayElements = (node.kind == NodeKind::Array);
int elementIdx = 0;
@@ -276,7 +338,8 @@ void composeParent(ComposeState& state, const NodeTree& tree,
// For array elements, also pass the element index for [N] separator
composeNode(state, tree, prov, childIdx, childDepth, base, rootId,
childrenAreArrayElements, node.id,
childrenAreArrayElements ? elementIdx++ : -1);
childrenAreArrayElements ? elementIdx++ : -1,
childrenAreArrayElements ? absAddr : 0);
}
}
@@ -302,7 +365,8 @@ void composeParent(ComposeState& state, const NodeTree& tree,
void composeNode(ComposeState& state, const NodeTree& tree,
const Provider& prov, int nodeIdx, int depth,
uint64_t base, uint64_t rootId, bool isArrayChild,
uint64_t scopeId, int arrayElementIdx) {
uint64_t scopeId, int arrayElementIdx,
uint64_t arrayContainerAddr) {
const Node& node = tree.nodes[nodeIdx];
uint64_t absAddr = resolveAddr(state, tree, nodeIdx, base, rootId);
@@ -392,7 +456,7 @@ void composeNode(ComposeState& state, const NodeTree& tree,
}
if (node.kind == NodeKind::Struct || node.kind == NodeKind::Array) {
composeParent(state, tree, prov, nodeIdx, depth, base, rootId, isArrayChild, scopeId, arrayElementIdx);
composeParent(state, tree, prov, nodeIdx, depth, base, rootId, isArrayChild, scopeId, arrayElementIdx, arrayContainerAddr);
} else {
composeLeaf(state, tree, prov, nodeIdx, depth, absAddr, scopeId);
}
@@ -427,8 +491,11 @@ ComposeResult compose(const NodeTree& tree, const Provider& prov, uint64_t viewR
// Helper: compute the display type string for a node (for width calculation)
auto nodeTypeName = [&](const Node& n) -> QString {
if (n.kind == NodeKind::Array)
return fmt::arrayTypeName(n.elementKind, n.arrayLen);
if (n.kind == NodeKind::Array) {
QString sn = (n.elementKind == NodeKind::Struct)
? resolvePointerTarget(tree, n.refId) : QString();
return fmt::arrayTypeName(n.elementKind, n.arrayLen, sn);
}
if (n.kind == NodeKind::Struct)
return fmt::structTypeName(n);
if (n.kind == NodeKind::Pointer32 || n.kind == NodeKind::Pointer64)
@@ -473,6 +540,19 @@ ComposeResult compose(const NodeTree& tree, const Provider& prov, uint64_t viewR
}
}
// Primitive arrays with no tree children: account for synthesized element types
// e.g. "uint32_t[0]", "uint32_t[99]" — longest index determines width
if (container.kind == NodeKind::Array
&& state.childMap.value(container.id).isEmpty()
&& container.elementKind != NodeKind::Struct
&& container.elementKind != NodeKind::Array
&& container.arrayLen > 0) {
int maxIdx = container.arrayLen - 1;
QString longestElemType = fmt::typeNameRaw(container.elementKind)
+ QStringLiteral("[%1]").arg(maxIdx);
scopeMaxType = qMax(scopeMaxType, (int)longestElemType.size());
}
state.scopeTypeW[container.id] = qBound(kMinTypeW, scopeMaxType, kMaxTypeW);
state.scopeNameW[container.id] = qBound(kMinNameW, scopeMaxName, kMaxNameW);
}

View File

@@ -61,11 +61,10 @@ private:
// ── Saved source entry ──
struct SavedSourceEntry {
QString kind; // "File" or "Process"
QString kind; // "File" or provider identifier (e.g. "processmemory")
QString displayName; // filename or process name
QString filePath; // for File sources
uint32_t pid = 0; // for Process sources
QString processName; // for Process sources
QString providerTarget; // for plugin providers (e.g. "pid:name")
uint64_t baseAddress = 0;
};
@@ -112,7 +111,7 @@ public:
// MCP bridge accessors
void setSuppressRefresh(bool v) { m_suppressRefresh = v; }
void attachToProcess(uint32_t pid, const QString& processName);
void attachViaPlugin(const QString& providerIdentifier, const QString& target);
const QVector<SavedSourceEntry>& savedSources() const { return m_savedSources; }
int activeSourceIndex() const { return m_activeSourceIdx; }
void switchSource(int idx) { switchToSavedSource(idx); }
@@ -151,6 +150,8 @@ private:
void switchToSavedSource(int idx);
void pushSavedSourcesToEditors();
void showTypeSelectorPopup(RcxEditor* editor);
void showTypePickerPopup(RcxEditor* editor, EditTarget target, int nodeIdx, QPoint globalPos);
void applyTypePickerResult(EditTarget target, int nodeIdx, uint64_t selectedId, const QString& displayName);
// ── Auto-refresh methods ──
void setupAutoRefresh();

View File

@@ -650,7 +650,7 @@ inline ColumnSpan commandRowRootNameSpan(const QString& lineText) {
inline ColumnSpan commandRowChevronSpan(const QString& lineText) {
if (lineText.size() < 3) return {};
if (lineText[0] == '[' && lineText[1] == QChar(0x25B8) && lineText[2] == ']')
return {0, 3, true};
return {0, qMin(4, (int)lineText.size()), true}; // include trailing space for easier clicking
return {};
}

View File

@@ -466,6 +466,10 @@ void RcxEditor::fillIndicatorCols(int indic, int line, int colA, int colB) {
void RcxEditor::applyHexDimming(const QVector<LineMeta>& meta) {
m_sci->SendScintilla(QsciScintillaBase::SCI_SETINDICATORCURRENT, IND_HEX_DIM);
for (int i = 0; i < meta.size(); i++) {
// Dim fold arrows (▸/▾) on fold head lines
if (meta[i].foldHead && meta[i].lineKind != LineKind::CommandRow)
fillIndicatorCols(IND_HEX_DIM, i, 0, kFoldCol);
if (isHexPreview(meta[i].nodeKind)) {
long pos, len; lineRangeNoEol(m_sci, i, pos, len);
if (len > 0)
@@ -979,7 +983,7 @@ RcxEditor::HitInfo RcxEditor::hitTest(const QPoint& vp) const {
if (h.line >= 0 && h.line < m_meta.size()) {
h.nodeId = m_meta[h.line].nodeId;
h.inFoldCol = (h.col >= 0 && h.col < kFoldCol && m_meta[h.line].foldHead);
h.inFoldCol = (h.col >= 0 && h.col < kFoldCol + 1 && m_meta[h.line].foldHead);
}
return h;
}
@@ -1044,11 +1048,12 @@ static bool hitTestTarget(QsciScintilla* sci,
}
// Array headers: check element type and count sub-spans first
// Count click area includes brackets [N] so clicking [ or ] edits the count
if (lm.isArrayHeader) {
ColumnSpan elemCountClick = arrayElemCountClickSpanFor(lm, lineText);
ColumnSpan elemType = arrayElemTypeSpanFor(lm, lineText);
ColumnSpan elemCount = arrayElemCountSpanFor(lm, lineText);
if (inSpan(elemCount)) { outTarget = EditTarget::ArrayElementCount; outLine = line; return true; }
if (inSpan(elemType)) { outTarget = EditTarget::ArrayElementType; outLine = line; return true; }
if (inSpan(elemCountClick)) { outTarget = EditTarget::ArrayElementCount; outLine = line; return true; }
if (inSpan(elemType)) { outTarget = EditTarget::ArrayElementType; outLine = line; return true; }
}
// Fallback spans for header lines
@@ -1065,6 +1070,26 @@ static bool hitTestTarget(QsciScintilla* sci,
else if (inSpan(vs)) outTarget = EditTarget::Value;
else return false;
// Array headers: redirect generic Type hit to ArrayElementType (uses popup, not inline edit)
if (lm.isArrayHeader && outTarget == EditTarget::Type) {
outTarget = EditTarget::ArrayElementType;
outLine = line;
return true;
}
// Array element lines: type/name click opens element type picker on the parent array header
if (lm.isArrayElement && (outTarget == EditTarget::Type || outTarget == EditTarget::Name)) {
outTarget = EditTarget::ArrayElementType;
// Find the array header line (previous line with isArrayHeader and same nodeIdx)
for (int l = line - 1; l >= 0; l--) {
if (l >= meta.size()) continue;
const LineMeta& hdr = meta[l];
if (hdr.isArrayHeader && hdr.nodeIdx == lm.nodeIdx) {
outLine = l;
return true;
}
}
return false;
}
// Padding nodes: hex bytes are display-only, not editable
if (outTarget == EditTarget::Value && lm.nodeKind == NodeKind::Padding)
return false;
@@ -1446,6 +1471,24 @@ bool RcxEditor::handleEditKey(QKeyEvent* ke) {
bool RcxEditor::beginInlineEdit(EditTarget target, int line) {
if (target == EditTarget::TypeSelector) return false; // handled by popup, not inline edit
// Array element type and pointer target: handled by TypeSelectorPopup, not inline edit
if (target == EditTarget::ArrayElementType || target == EditTarget::PointerTarget) {
if (line < 0) {
int col;
m_sci->getCursorPosition(&line, &col);
}
auto* lm = metaForLine(line);
if (!lm) return false;
long lineStart = m_sci->SendScintilla(QsciScintillaBase::SCI_POSITIONFROMLINE, (unsigned long)line);
int lineH = (int)m_sci->SendScintilla(QsciScintillaBase::SCI_TEXTHEIGHT, (unsigned long)line);
int x = (int)m_sci->SendScintilla(QsciScintillaBase::SCI_POINTXFROMPOSITION, (unsigned long)0, lineStart);
int y = (int)m_sci->SendScintilla(QsciScintillaBase::SCI_POINTYFROMPOSITION, (unsigned long)0, lineStart);
QPoint pos = m_sci->viewport()->mapToGlobal(QPoint(x, y + lineH));
emit typePickerRequested(target, lm->nodeIdx, pos);
return true;
}
if (m_editState.active) return false;
m_hoveredNodeId = 0;
m_hoveredLine = -1;
@@ -1759,7 +1802,6 @@ void RcxEditor::showSourcePicker() {
menuFont.setPointSize(menuFont.pointSize() + zoom);
menu.setFont(menuFont);
menu.addAction("file");
menu.addAction("process");
// Add all registered providers from global registry
const auto& providers = ProviderRegistry::instance().providers();
@@ -2015,6 +2057,12 @@ void RcxEditor::applyHoverCursor() {
}
}
// Apply hover span on fold arrows (▸/▾) — same visual feedback as editable tokens
if (h.inFoldCol && h.line >= 0 && h.line < m_meta.size()) {
fillIndicatorCols(IND_HOVER_SPAN, h.line, 0, kFoldCol);
m_hoverSpanLines.append(h.line);
}
// Determine cursor shape based on interaction type
Qt::CursorShape desired = Qt::ArrowCursor;

View File

@@ -65,6 +65,7 @@ signals:
EditTarget target, const QString& text);
void inlineEditCancelled();
void typeSelectorRequested();
void typePickerRequested(EditTarget target, int nodeIdx, QPoint globalPos);
protected:
bool eventFilter(QObject* obj, QEvent* event) override;

View File

@@ -317,27 +317,27 @@
"strLen": 64
},
{
"arrayLen": 1,
"arrayLen": 4,
"collapsed": false,
"elementKind": "UInt8",
"elementKind": "Float",
"id": "27",
"kind": "Hex64",
"name": "field_70",
"kind": "Array",
"name": "scores",
"offset": 112,
"parentId": "1",
"refId": "0",
"strLen": 64
},
{
"arrayLen": 1,
"arrayLen": 2,
"collapsed": false,
"elementKind": "UInt8",
"elementKind": "Struct",
"id": "28",
"kind": "Hex64",
"name": "field_78",
"offset": 120,
"kind": "Array",
"name": "materials",
"offset": 128,
"parentId": "1",
"refId": "0",
"refId": "20",
"strLen": 64
}
]

View File

@@ -41,13 +41,15 @@ QString typeName(NodeKind kind, int colType) {
return fit(m ? QString::fromLatin1(m->typeName) : QStringLiteral("???"), colType);
}
// Array type string: "uint32_t[16]" or "char[64]"
QString arrayTypeName(NodeKind elemKind, int count) {
auto* m = kindMeta(elemKind);
QString elem = m ? QString::fromLatin1(m->typeName) : QStringLiteral("???");
// char[] for UInt8, wchar_t[] for UInt16
if (elemKind == NodeKind::UInt8) elem = QStringLiteral("char");
else if (elemKind == NodeKind::UInt16) elem = QStringLiteral("wchar_t");
// Array type string: "uint32_t[16]" or "Material[2]"
QString arrayTypeName(NodeKind elemKind, int count, const QString& structName) {
QString elem;
if (elemKind == NodeKind::Struct && !structName.isEmpty())
elem = structName;
else {
auto* m = kindMeta(elemKind);
elem = m ? QString::fromLatin1(m->typeName) : QStringLiteral("???");
}
return elem + QStringLiteral("[") + QString::number(count) + QStringLiteral("]");
}
@@ -143,9 +145,9 @@ QString fmtStructFooter(const Node& /*node*/, int depth, int /*totalSize*/) {
// ── Array header ──
// Columnar format: <type[count]> <name> { (or no brace when collapsed)
QString fmtArrayHeader(const Node& node, int depth, int /*viewIdx*/, bool collapsed, int colType, int colName) {
QString fmtArrayHeader(const Node& node, int depth, int /*viewIdx*/, bool collapsed, int colType, int colName, const QString& elemStructName) {
QString ind = indent(depth);
QString type = fit(arrayTypeName(node.elementKind, node.arrayLen), colType);
QString type = fit(arrayTypeName(node.elementKind, node.arrayLen, elemStructName), colType);
QString suffix = collapsed ? QString() : QStringLiteral("{");
return ind + type + SEP + node.name + SEP + suffix;
}

View File

@@ -597,8 +597,12 @@ static void buildBallDemo(NodeTree& tree) {
// Pointer to Material in Ball struct
{ Node n; n.kind = NodeKind::Pointer64; n.name = "material"; n.parentId = ballId; n.offset = 104; n.refId = matId; n.collapsed = true; tree.addNode(n); }
{ Node n; n.kind = NodeKind::Hex64; n.name = "field_70"; n.parentId = ballId; n.offset = 112; tree.addNode(n); }
{ Node n; n.kind = NodeKind::Hex64; n.name = "field_78"; n.parentId = ballId; n.offset = 120; tree.addNode(n); }
// float[4] scores at offset 112
{ Node n; n.kind = NodeKind::Array; n.name = "scores"; n.parentId = ballId; n.offset = 112; n.elementKind = NodeKind::Float; n.arrayLen = 4; tree.addNode(n); }
// Material[2] materials at offset 128 (112 + 16 for float[4])
{ Node n; n.kind = NodeKind::Array; n.name = "materials"; n.parentId = ballId; n.offset = 128; n.elementKind = NodeKind::Struct; n.arrayLen = 2; n.refId = matId; tree.addNode(n); }
}
void MainWindow::newFile() {

View File

@@ -796,7 +796,8 @@ QJsonObject McpBridge::toolSourceSwitch(const QJsonObject& args) {
uint32_t pid = (uint32_t)args.value("pid").toInteger();
QString name = args.value("processName").toString();
if (name.isEmpty()) name = QString("PID %1").arg(pid);
ctrl->attachToProcess(pid, name);
QString target = QString("%1:%2").arg(pid).arg(name);
ctrl->attachViaPlugin(QStringLiteral("processmemory"), target);
return makeTextResult("Attached to process " + name + " (PID " + QString::number(pid) + ")");
}

View File

@@ -1,109 +0,0 @@
#pragma once
#include "provider.h"
#ifdef _WIN32
#include <windows.h>
#include <psapi.h>
namespace rcx {
class ProcessProvider : public Provider {
HANDLE m_handle = nullptr;
uint64_t m_base = 0;
int m_size = 0;
QString m_name;
struct ModuleInfo {
QString name;
uint64_t base;
uint64_t size;
};
QVector<ModuleInfo> m_modules;
public:
ProcessProvider(HANDLE proc, uint64_t base, int regionSize, const QString& name)
: m_handle(proc), m_base(base), m_size(regionSize), m_name(name)
{
cacheModules();
}
~ProcessProvider() override {
if (m_handle) CloseHandle(m_handle);
}
ProcessProvider(const ProcessProvider&) = delete;
ProcessProvider& operator=(const ProcessProvider&) = delete;
int size() const override { return m_size; }
bool isReadable(uint64_t, int len) const override { return len >= 0; }
bool read(uint64_t addr, void* buf, int len) const override {
if (!m_handle || len <= 0) return false;
SIZE_T got = 0;
ReadProcessMemory(m_handle,
(LPCVOID)(m_base + addr), buf, len, &got);
if ((int)got < len)
memset((char*)buf + got, 0, len - got);
return got > 0;
}
bool isWritable() const override { return true; }
bool write(uint64_t addr, const void* buf, int len) override {
SIZE_T got = 0;
BOOL ok = WriteProcessMemory(m_handle,
(LPVOID)(m_base + addr), buf, len, &got);
return ok && (int)got == len;
}
QString name() const override { return m_name; }
QString kind() const override { return QStringLiteral("Process"); }
bool isLive() const override { return true; }
// getSymbol takes an absolute virtual address and resolves it to
// "module.dll+0xOFFSET" using the cached module list.
QString getSymbol(uint64_t absAddr) const override {
for (const auto& mod : m_modules) {
if (absAddr >= mod.base && absAddr < mod.base + mod.size) {
uint64_t offset = absAddr - mod.base;
return QStringLiteral("%1+0x%2")
.arg(mod.name)
.arg(offset, 0, 16, QChar('0'));
}
}
return {};
}
HANDLE handle() const { return m_handle; }
uint64_t baseAddress() const { return m_base; }
uint64_t base() const override { return m_base; }
void setBase(uint64_t b) override { m_base = b; }
void refreshModules() { m_modules.clear(); cacheModules(); }
private:
void cacheModules() {
HMODULE mods[1024];
DWORD needed = 0;
if (!EnumProcessModulesEx(m_handle, mods, sizeof(mods),
&needed, LIST_MODULES_ALL))
return;
int count = qMin((int)(needed / sizeof(HMODULE)), 1024);
m_modules.reserve(count);
for (int i = 0; i < count; ++i) {
MODULEINFO mi{};
WCHAR modName[MAX_PATH];
if (GetModuleInformation(m_handle, mods[i], &mi, sizeof(mi))
&& GetModuleBaseNameW(m_handle, mods[i], modName, MAX_PATH))
{
m_modules.append({
QString::fromWCharArray(modName),
(uint64_t)mi.lpBaseOfDll,
(uint64_t)mi.SizeOfImage
});
}
}
}
};
} // namespace rcx
#endif // _WIN32

View File

@@ -40,7 +40,7 @@ public:
// Resolve an absolute address to a symbol name.
// Returns empty string if no symbol is known.
// ProcessProvider: "ntdll.dll+0x1A30"
// Example: "ntdll.dll+0x1A30"
// BufferProvider: "" (no symbols in flat files)
virtual QString getSymbol(uint64_t addr) const {
Q_UNUSED(addr);

View File

@@ -58,10 +58,14 @@ public:
}
x += 18;
// Icon 16x16
static QIcon structIcon(QStringLiteral(":/vsicons/symbol-structure.svg"));
structIcon.paint(painter, x, y + (h - 16) / 2, 16, 16);
x += 20;
// Icon 16x16 — only for struct/class/enum entries (non-empty classKeyword)
bool hasIcon = (m_filtered && row >= 0 && row < m_filtered->size()
&& !(*m_filtered)[row].classKeyword.isEmpty());
if (hasIcon) {
static QIcon structIcon(QStringLiteral(":/vsicons/symbol-structure.svg"));
structIcon.paint(painter, x, y + (h - 16) / 2, 16, 16);
}
x += 20; // reserve space for alignment
// Text
painter->setPen(option.state & QStyle::State_Selected
@@ -122,7 +126,7 @@ TypeSelectorPopup::TypeSelectorPopup(QWidget* parent)
{
auto* row = new QHBoxLayout;
row->setContentsMargins(0, 0, 0, 0);
m_titleLabel = new QLabel(QStringLiteral("View as type"));
m_titleLabel = new QLabel(QStringLiteral("Change root"));
m_titleLabel->setPalette(pal);
QFont bold = m_titleLabel->font();
bold.setBold(true);
@@ -236,7 +240,7 @@ void TypeSelectorPopup::setTypes(const QVector<TypeEntry>& types, uint64_t curre
void TypeSelectorPopup::popup(const QPoint& globalPos) {
// Size: width based on longest entry, height based on count
QFontMetrics fm(m_font);
int maxTextW = fm.horizontalAdvance(QStringLiteral("View as type Esc"));
int maxTextW = fm.horizontalAdvance(QStringLiteral("Choose element type Esc"));
for (const auto& t : m_allTypes) {
QString text = t.classKeyword + QStringLiteral(" ") + t.displayName;
int w = 18 + 20 + fm.horizontalAdvance(text) + 16; // gutter + icon + text + pad
@@ -283,7 +287,10 @@ void TypeSelectorPopup::applyFilter(const QString& text) {
|| t.displayName.contains(text, Qt::CaseInsensitive)
|| t.classKeyword.contains(text, Qt::CaseInsensitive)) {
m_filteredTypes.append(t);
displayStrings << (t.classKeyword + QStringLiteral(" ") + t.displayName);
if (t.classKeyword.isEmpty())
displayStrings << t.displayName;
else
displayStrings << (t.classKeyword + QStringLiteral(" ") + t.displayName);
}
}
@@ -305,9 +312,13 @@ void TypeSelectorPopup::acceptCurrent() {
acceptIndex(idx.row());
}
void TypeSelectorPopup::setTitle(const QString& title) {
m_titleLabel->setText(title);
}
void TypeSelectorPopup::acceptIndex(int row) {
if (row < 0 || row >= m_filteredTypes.size()) return;
emit typeSelected(m_filteredTypes[row].id);
emit typeSelected(m_filteredTypes[row].id, m_filteredTypes[row].displayName);
hide();
}

View File

@@ -25,11 +25,12 @@ public:
explicit TypeSelectorPopup(QWidget* parent = nullptr);
void setFont(const QFont& font);
void setTitle(const QString& title);
void setTypes(const QVector<TypeEntry>& types, uint64_t currentId);
void popup(const QPoint& globalPos);
signals:
void typeSelected(uint64_t structId);
void typeSelected(uint64_t id, const QString& displayName);
void createNewTypeRequested();
void dismissed();