Files
qelectrotech-source-mirror/sources/TerminalStrip/GraphicsItem/terminalstripitem.h
T
Laurent Trinques fed204eb78 Terminal strip: clickable terminals in the realistic styles
The realistic styles don't write the xrefs, so each terminal becomes a
clickable zone, like the xref text of the schematic style:
- double-click on a terminal goes to its element on the folio
- the terminal under the mouse is outlined in blue, and a tool tip
  shows its label and its xref
- the zones are exported as clickable links in the PDF

A terminal with one level is clickable on its whole body; a terminal
with levels is clickable on the rows of wire entries of each level.
Only the terminals with an xref (element placed on a folio) are
clickable. The zones use the same physical / real indexes as the
schematic style, so the double-click and the PDF export need no
other change.
2026-10-17 20:41:25 +02:00

87 lines
2.7 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 TERMINALSTRIPITEM_H
#define TERMINALSTRIPITEM_H
#include <QGraphicsObject>
#include <QList>
#include <QRectF>
#include <QUuid>
#include "terminalstripdrawer.h"
#include "../../qetgraphicsitem/qetgraphicsitem.h"
class Diagram;
class TerminalStrip;
class TerminalStripItem : public QetGraphicsItem
{
friend class TerminalStripItemXml;
Q_OBJECT
public:
TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr);
TerminalStripItem(QGraphicsItem *parent = nullptr);
void setTerminalStrip(TerminalStrip *strip);
QPointer<TerminalStrip> terminalStrip() const;
enum {Type = UserType + 1011};
int type() const override {return Type;}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
QRectF boundingRect() const override;
QString name() const override;
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
void refreshPending();
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
void setDrawStyle(TerminalStripLayoutPattern::DrawStyle style);
TerminalStripLayoutPattern::DrawStyle drawStyle() const;
/**
* @brief The PdfRef struct
* One xref of the plan which leads to an element: used to make
* it a clickable link in an exported PDF.
*/
struct PdfRef
{
///The folio of the element the xref points at
Diagram *diagram = nullptr;
///Where the text of the xref stands on the folio of this item
QRectF here;
///Where the element stands on its folio
QRectF there;
};
QList<PdfRef> pdfRefs() const;
private:
void setDefaultLayout();
QString xrefToolTip(const TerminalStripDrawer::hoverTerminal &terminal) const;
private:
QPointer<TerminalStrip> m_strip;
TerminalStripDrawer::TerminalStripDrawer m_drawer;
QUuid m_pending_strip_uuid;
};
#endif // TERMINALSTRIPITEM_H