Add Ctrl+G "jump to element" type-ahead popup (#574)

Implements the third pillar of #574: a lightweight quick-open popup
for jumping straight to an element on the current diagram, rather
than scrolling/scanning visually.

New JumpToElementDialog (sources/ui/): a small QDialog with a filter
QLineEdit and a live-filtered QListWidget beneath it. Built from
every Element on the diagram, searchable against its label
(elementInformations().value("label")), type name (Element::name()),
and every other element information value, joined into one
lowercased search string per candidate. Up/Down move through the
filtered list, Enter selects the highlighted element on the diagram
(clearing the rest of the selection) and scrolls it into view via
ensureVisible(), Escape cancels without changing the current
selection. All three are handled via an event filter on the line
edit, so the user never has to leave the text field to navigate or
confirm.

Triggered by a new Ctrl+G action in QETDiagramEditor, added next to
the existing Ctrl+F "search and replace" action and to the Edit
menu. Confirmed free: not used anywhere in qetdiagrameditor.cpp or
qetmainwindow.cpp today.

Explicitly not a duplicate of the existing SearchAndReplace module
(also on this menu, via Ctrl+F): that's a bulk property search/replace
tool across whole diagrams; this is a single-item navigational
popup with no editing capability.

Verified end-to-end in a real running session (Xvfb + xdotool)
against a multi-transistor schematic: Ctrl+G opens the popup listing
every element; typing "Q16" live-filters down to the one match;
arrow keys move the highlighted row through the filtered list;
Enter selects the highlighted element (confirmed via the properties
panel showing its label) and closes the popup; Escape closes it
without changing the selection.

See discussion #574.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-08-01 01:02:41 +12:00
parent 031441884a
commit 80fcd4283d
5 changed files with 284 additions and 1 deletions
+15
View File
@@ -39,6 +39,7 @@
#include "qetmessagebox.h"
#include "recentfiles.h"
#include "ui/bomexportdialog.h"
#include "ui/jumptoelementdialog.h"
#include "ui/diagrampropertieseditordockwidget.h"
#include "ui/backupdialog.h"
#include "ui/dialogwaiting.h"
@@ -747,6 +748,19 @@ void QETDiagramEditor::setUpActions()
this->m_search_and_replace_widget.setHidden(!m_search_and_replace_widget.isHidden());
}
});
m_jump_to_element = new QAction(tr("Atteindre un élément"), this);
m_jump_to_element->setShortcut(Qt::CTRL | Qt::Key_G);
m_jump_to_element->setStatusTip(tr("Recherche et sélectionne rapidement un élément du folio", "status bar tip"));
connect(m_jump_to_element, &QAction::triggered, [this]()
{
DiagramView *diagram_view = this->currentDiagramView();
if (!diagram_view || !diagram_view->diagram()) {
return;
}
JumpToElementDialog dialog(diagram_view->diagram(), this);
dialog.exec();
});
}
/**
@@ -861,6 +875,7 @@ void QETDiagramEditor::setUpMenu()
menu_edition -> addActions(m_depth_action_group->actions());
menu_edition -> addSeparator();
menu_edition -> addAction(m_find);
menu_edition -> addAction(m_jump_to_element);
// menu Projet
menu_project -> addAction(m_project_edit_properties);