mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-29 15:10:52 +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:
@@ -24,12 +24,31 @@
|
||||
Default constructor
|
||||
@param parent : Parent Item
|
||||
*/
|
||||
void QetGraphicsItem::showItem(QetGraphicsItem *item)
|
||||
{
|
||||
if (item && item->diagram())
|
||||
{
|
||||
item->diagram()->showMe();
|
||||
item->setSelected(true);
|
||||
|
||||
//Zoom to the item
|
||||
for(QGraphicsView *view : item->scene()->views())
|
||||
{
|
||||
QRectF fit = item->sceneBoundingRect();
|
||||
fit.adjust(-200, -200, 200, 200);
|
||||
view->fitInView(fit, Qt::KeepAspectRatioByExpanding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||
QGraphicsObject(parent),
|
||||
is_movable_(true),
|
||||
m_first_move(true),
|
||||
snap_to_grid_(true)
|
||||
{}
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
QetGraphicsItem::~QetGraphicsItem()
|
||||
{}
|
||||
@@ -68,6 +87,11 @@ bool QetGraphicsItem::isHovered() const {
|
||||
return m_hovered;
|
||||
}
|
||||
|
||||
QPointF QetGraphicsItem::hoverMousePos() const
|
||||
{
|
||||
return m_mouse_hover_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::state
|
||||
@return the current state of this item
|
||||
@@ -166,6 +190,12 @@ void QetGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
QGraphicsObject::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void QetGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGraphicsObject::hoverMoveEvent(event);
|
||||
m_mouse_hover_pos = event->pos();
|
||||
}
|
||||
|
||||
void QetGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_hovered = false;
|
||||
|
||||
@@ -28,6 +28,9 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public :
|
||||
static void showItem (QetGraphicsItem *item);
|
||||
|
||||
public:
|
||||
//constructor destructor
|
||||
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
||||
@@ -43,6 +46,7 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||
|
||||
bool isHovered() const;
|
||||
QPointF hoverMousePos() const;
|
||||
|
||||
virtual void editProperty () {}
|
||||
virtual QString name ()const
|
||||
@@ -57,6 +61,7 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
protected:
|
||||
@@ -68,6 +73,7 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
|
||||
private:
|
||||
bool m_hovered{false};
|
||||
QPointF m_mouse_hover_pos;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user