mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-03 18:44:13 +02:00
80fcd4283d
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>
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef JUMPTOELEMENTDIALOG_H
|
|
#define JUMPTOELEMENTDIALOG_H
|
|
|
|
#include <QDialog>
|
|
#include <QPointer>
|
|
|
|
class Diagram;
|
|
class Element;
|
|
class QLineEdit;
|
|
class QListWidget;
|
|
|
|
/**
|
|
@brief The JumpToElementDialog class
|
|
A lightweight, transient "quick open" popup: type part of an element's
|
|
label or other information to live-filter the elements on a diagram,
|
|
then Enter to select the chosen element on the diagram and scroll it
|
|
into view. Up/Down move through the filtered list, Escape cancels
|
|
without changing the current selection.
|
|
*/
|
|
class JumpToElementDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit JumpToElementDialog(Diagram *diagram, QWidget *parent = nullptr);
|
|
~JumpToElementDialog() override;
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
private slots:
|
|
void updateFilteredList(const QString &filter_text);
|
|
void activateCurrentItem();
|
|
|
|
private:
|
|
void buildCandidates();
|
|
|
|
struct Candidate {
|
|
QPointer<Element> element;
|
|
QString display_text;
|
|
QString search_text;
|
|
};
|
|
|
|
QPointer<Diagram> m_diagram;
|
|
QList<Candidate> m_candidates;
|
|
QLineEdit *m_filter_edit;
|
|
QListWidget *m_result_list;
|
|
};
|
|
|
|
#endif // JUMPTOELEMENTDIALOG_H
|