CRectItem.h 1.2 KB

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