25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
980 B

  1. #ifndef ITEM_H
  2. #define ITEM_H
  3. #include <QGraphicsObject>
  4. #include <QColor>
  5. #include <QList>
  6. class Connection;
  7. class Item : public QGraphicsObject
  8. {
  9. Q_OBJECT
  10. public:
  11. enum AnchorType { Left, Right };
  12. explicit Item(const QString &type, QGraphicsItem *parent = nullptr);
  13. QRectF boundingRect() const override;
  14. void paint(QPainter *painter,
  15. const QStyleOptionGraphicsItem *option,
  16. QWidget *widget) override;
  17. QPointF anchorPos(AnchorType type) const;
  18. void addConnection(Connection* conn);
  19. void removeConnection(Connection* conn);
  20. QList<Connection*> connections();
  21. QString itemType();
  22. signals:
  23. void requestCopy(Item*);
  24. void requestDelete(Item*);
  25. protected:
  26. QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
  27. void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
  28. private:
  29. QString type_;
  30. QList<Connection*> connections_;
  31. };
  32. #endif // ITEM_H