Files
qelectrotech-source-mirror/sources/ui/jumptoelementdialog.h
T
ispyisail 2807771200 Jump to a cell on another folio from Ctrl+G, typed as 3-B13
The popup now also takes a folio position before the cell, the way
cross references and folio reports write it by default (%f-%l%c): 3-B13
offers "Folio 3 (<title>), case B13", and Enter shows that folio and
zooms onto the cell. Case and a leading "p" are ignored, and the
separator is optional: 3-b13, 3b13, P3B13 and p3-b13 all work. A plain
B13 still means the current folio, and P3 alone is still row P,
column 3: a folio always needs a cell after it. A folio position past
the last folio, or a cell outside that folio's border, offers nothing.

The zoom on another folio is queued, so it runs once the tab switch
has been handled. Checked on the ATS example: jumping to 1-C5 from
folio 3 gives the same view, pixel for pixel, as C5 typed on folio 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
2026-09-26 08:36:53 +12:00

73 lines
2.1 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;
class QListWidgetItem;
/**
@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. Typing a cell of the border instead (ex : B13, or 3-B13 for
the third folio of the project) offers to zoom on that cell. 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();
QListWidgetItem *cellItem(const QString &needle) const;
void zoomToCell(Diagram *diagram, const QRectF &cell_rect);
struct Candidate {
QPointer<Element> element;
QString label;
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