mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-05 13:39:58 +01:00
Terminal strip item can be added to diagram
Initial commit about graphics item of a terminal strip, Work in progress.
This commit is contained in:
@@ -64,6 +64,10 @@ void QetGraphicsItem::setPos(qreal x, qreal y) {
|
||||
setPos(QPointF(x, y));
|
||||
}
|
||||
|
||||
bool QetGraphicsItem::isHovered() const {
|
||||
return m_hovered;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::state
|
||||
@return the current state of this item
|
||||
@@ -155,3 +159,15 @@ void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QetGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_hovered = true;
|
||||
QGraphicsObject::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void QetGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_hovered = false;
|
||||
QGraphicsObject::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
@@ -42,6 +42,8 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
{return is_movable_;}
|
||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||
|
||||
bool isHovered() const;
|
||||
|
||||
virtual void editProperty () {}
|
||||
virtual QString name ()const
|
||||
{return QString("");}
|
||||
@@ -54,6 +56,8 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
protected:
|
||||
bool is_movable_;
|
||||
@@ -62,6 +66,9 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||
|
||||
private:
|
||||
bool m_hovered{false};
|
||||
|
||||
};
|
||||
|
||||
#endif // QETGRAPHICSITEM_H
|
||||
|
||||
@@ -90,5 +90,19 @@ bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_f
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void drawBoundingRectSelection(QGraphicsItem *item, QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
QPen t;
|
||||
t.setColor(Qt::gray);
|
||||
t.setStyle(Qt::DashDotLine);
|
||||
t.setCosmetic(true);
|
||||
|
||||
painter->setPen(t);
|
||||
painter->drawRoundedRect(item->boundingRect(),10,10);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,13 @@
|
||||
|
||||
class QGraphicsItem;
|
||||
class Element;
|
||||
class QPainter;
|
||||
|
||||
namespace QGIUtility
|
||||
{
|
||||
bool centerToParentBottom (QGraphicsItem *item);
|
||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
||||
void drawBoundingRectSelection(QGraphicsItem *item, QPainter *painter);
|
||||
}
|
||||
|
||||
#endif // QGRAPHICSITEMUTILITY_H
|
||||
|
||||
Reference in New Issue
Block a user