mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-07 22:22:33 +01:00
Terminal strip Xref is clickable
When user hover the Xref string of a terminal, the string color change to blue to advise user the xref is clickable. Double click on the blue Xref go the folio of the terminal and zoom the view to the terminal.
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include "../../project/projectpropertieshandler.h"
|
||||
#include "../../qetgraphicsitem/qgraphicsitemutility.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "../physicalterminal.h"
|
||||
#include "../realterminal.h"
|
||||
#include "../ui/terminalstripeditorwindow.h"
|
||||
#include "trueterminalstrip.h"
|
||||
|
||||
@@ -94,13 +96,53 @@ QString TerminalStripItem::name() const {
|
||||
return tr("plan de bornes");
|
||||
}
|
||||
|
||||
void TerminalStripItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QetGraphicsItem::hoverMoveEvent(event);
|
||||
m_drawer.setMouseHoverPos(hoverMousePos());
|
||||
if (m_drawer.needUpdate()) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QetGraphicsItem::hoverLeaveEvent(event);
|
||||
m_drawer.setMouseHoverPos(QPointF{});
|
||||
}
|
||||
|
||||
void TerminalStripItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED (event);
|
||||
|
||||
if (m_strip) {
|
||||
TerminalStripEditorWindow::edit(m_strip);
|
||||
}
|
||||
const auto hovered = m_drawer.hoveredXref();
|
||||
|
||||
if (m_strip) {
|
||||
if (hovered.physical >= 0 &&
|
||||
hovered.real >= 0)
|
||||
{
|
||||
if (const auto physical_terminal = m_strip->physicalTerminal(hovered.physical);
|
||||
!physical_terminal.isNull())
|
||||
{
|
||||
if (const auto real_terminal = physical_terminal->realTerminal(hovered.real);
|
||||
!real_terminal.isNull() &&
|
||||
real_terminal->isElement())
|
||||
{
|
||||
if (QPointer<Element> element = real_terminal->element();
|
||||
!element.isNull())
|
||||
{
|
||||
//Unselect and ungrab mouse to prevent unwanted
|
||||
//move when element is in the same scene of this.
|
||||
setSelected(false);
|
||||
ungrabMouse();
|
||||
QetGraphicsItem::showItem(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TerminalStripEditorWindow::edit(m_strip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripItem::refreshPending()
|
||||
|
||||
Reference in New Issue
Block a user