12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef CRECTITEM_H
- #define CRECTITEM_H
- #include "CPathItem.h"
- class RoundMenu;
- class QMenu;
- class QAction;
- class CRectItem : public CPathItem
- {
- public:
- explicit CRectItem(QGraphicsItem *parent = nullptr);
- explicit CRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr);
- QRectF rect() const;
- void setRect(const QRectF &rect);
- QPointF centerLeft() const;
- QPointF centerRight() const;
- int cornerRadius() const;
- void setCornerRadius(qreal radius);
- void updatePath() override;
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
- void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
- QAction *selectAction() const;
- QAction *subNodeAction() const;
- QAction *removeAction() const;
- QAction *editAction() const;
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- void setAllowEdit(bool allow);
- private slots:
- void slotSelect();
- private:
- QRectF m_rect;
- qreal m_cornerRadius = 5;
- RoundMenu *m_menu = nullptr;
- QAction *m_select = nullptr;
- QAction *m_subNode = nullptr;
- QAction *m_remove = nullptr;
- QAction *m_edit = nullptr;
- bool m_allowEdit = true;
- };
- #endif // CRECTITEM_H
|