CRectItem.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef CRECTITEM_H
  2. #define CRECTITEM_H
  3. #include "CPathItem.h"
  4. class QMenu;
  5. class QAction;
  6. class CRectItem : public CPathItem
  7. {
  8. public:
  9. explicit CRectItem(QGraphicsItem *parent = nullptr);
  10. explicit CRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr);
  11. QRectF rect() const;
  12. void setRect(const QRectF &rect);
  13. QPointF centerLeft() const;
  14. QPointF centerRight() const;
  15. int cornerRadius() const;
  16. void setCornerRadius(qreal radius);
  17. void updatePath() override;
  18. void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
  19. void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
  20. QAction *selectAction() const;
  21. QAction *subNodeAction() const;
  22. QAction *removeAction() const;
  23. private slots:
  24. void slotSelect();
  25. private:
  26. QRectF m_rect;
  27. qreal m_cornerRadius = 5;
  28. QMenu *m_menu = nullptr;
  29. QAction *m_select = nullptr;
  30. QAction *m_subNode = nullptr;
  31. QAction *m_remove = nullptr;
  32. };
  33. #endif // CRECTITEM_H