fix: clear value history clears subtree, add Copy Line and Search to context menu

- Clear Value History now removes history for all descendant nodes too
- Add "Copy Line" right-click menu item
- Add "Search..." right-click menu item (opens Ctrl+F find bar)
- Move showFindBar() to public in editor.h
This commit is contained in:
IChooseYou
2026-03-02 15:34:37 -07:00
parent d43e989992
commit e6529052b3
2 changed files with 25 additions and 5 deletions

View File

@@ -1637,9 +1637,11 @@ void RcxController::showContextMenu(RcxEditor* editor, int line, int nodeIdx,
connect(act, &QAction::triggered, this, [this, ids]() { connect(act, &QAction::triggered, this, [this, ids]() {
for (uint64_t id : ids) { for (uint64_t id : ids) {
m_valueHistory.remove(id); m_valueHistory.remove(id);
for (auto& lm : m_lastResult.meta) for (int ci : m_doc->tree.subtreeIndices(id))
if (lm.nodeId == id) lm.heatLevel = 0; m_valueHistory.remove(m_doc->tree.nodes[ci].id);
} }
for (auto& lm : m_lastResult.meta)
if (!m_valueHistory.contains(lm.nodeId)) lm.heatLevel = 0;
refresh(); refresh();
}); });
} }
@@ -1833,11 +1835,12 @@ void RcxController::showContextMenu(RcxEditor* editor, int line, int nodeIdx,
{ {
auto* act = menu.addAction("Clear Value History"); auto* act = menu.addAction("Clear Value History");
act->setToolTip(QStringLiteral("Reset change tracking for this node")); act->setToolTip(QStringLiteral("Reset change tracking for this node"));
act->setEnabled(m_valueHistory.contains(nodeId) && m_valueHistory[nodeId].uniqueCount() > 0);
connect(act, &QAction::triggered, this, [this, nodeId]() { connect(act, &QAction::triggered, this, [this, nodeId]() {
m_valueHistory.remove(nodeId); m_valueHistory.remove(nodeId);
for (int ci : m_doc->tree.subtreeIndices(nodeId))
m_valueHistory.remove(m_doc->tree.nodes[ci].id);
for (auto& lm : m_lastResult.meta) for (auto& lm : m_lastResult.meta)
if (lm.nodeId == nodeId) lm.heatLevel = 0; if (!m_valueHistory.contains(lm.nodeId)) lm.heatLevel = 0;
refresh(); refresh();
}); });
} }
@@ -2091,6 +2094,23 @@ void RcxController::showContextMenu(RcxEditor* editor, int line, int nodeIdx,
menu.addAction(icon("clippy.svg"), "Copy All as Text", [editor]() { menu.addAction(icon("clippy.svg"), "Copy All as Text", [editor]() {
QApplication::clipboard()->setText(editor->textWithMargins()); QApplication::clipboard()->setText(editor->textWithMargins());
}); });
menu.addAction(icon("clippy.svg"), "Copy Line", [editor, line]() {
auto* sci = editor->scintilla();
int len = (int)sci->SendScintilla(QsciScintillaBase::SCI_LINELENGTH, (unsigned long)line);
if (len > 0) {
QByteArray buf(len + 1, '\0');
sci->SendScintilla(QsciScintillaBase::SCI_GETLINE, (unsigned long)line, (void*)buf.data());
QString text = QString::fromUtf8(buf.data(), len).trimmed();
if (!text.isEmpty())
QApplication::clipboard()->setText(text);
}
});
menu.addSeparator();
menu.addAction(icon("search.svg"), "Search...", [editor]() {
editor->showFindBar();
});
menu.exec(globalPos); menu.exec(globalPos);
} }

View File

@@ -33,6 +33,7 @@ public:
const LineMeta* metaForLine(int line) const; const LineMeta* metaForLine(int line) const;
int currentNodeIndex() const; int currentNodeIndex() const;
void scrollToNodeId(uint64_t nodeId); void scrollToNodeId(uint64_t nodeId);
void showFindBar();
// ── Column span computation ── // ── Column span computation ──
static ColumnSpan typeSpan(const LineMeta& lm, int typeW = kColType); static ColumnSpan typeSpan(const LineMeta& lm, int typeW = kColType);
@@ -159,7 +160,6 @@ private:
QWidget* m_findBarContainer = nullptr; QWidget* m_findBarContainer = nullptr;
QLineEdit* m_findBar = nullptr; QLineEdit* m_findBar = nullptr;
long m_findPos = 0; long m_findPos = 0;
void showFindBar();
void hideFindBar(); void hideFindBar();
// ── Reentrancy guards ── // ── Reentrancy guards ──