File indexing completed on 2024-05-12 17:11:40
0001 #ifndef CANVASFIELD_H 0002 #define CANVASFIELD_H 0003 #include <QGraphicsObject> 0004 #include <QMenu> 0005 #include <QPointer> 0006 // 0007 class FieldController; 0008 /** 0009 * @brief The CanvasField class is the representation of the field into GraphicsScene. 0010 */ 0011 class CanvasField : public QGraphicsObject 0012 { 0013 Q_OBJECT 0014 Q_PROPERTY(FieldController* controller READ controller CONSTANT) 0015 public: 0016 enum 0017 { 0018 Type= UserType + 1 0019 }; 0020 CanvasField(FieldController* field); 0021 0022 int type() const override { return Type; } 0023 0024 FieldController* controller() const; 0025 0026 QRectF boundingRect() const override; 0027 virtual QPainterPath shape() const override; 0028 0029 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget= nullptr) override; 0030 void setNewEnd(QPointF nend); 0031 0032 static bool getShowImageField(); 0033 static void setShowImageField(bool showImageField); 0034 virtual void setMenu(QMenu& menu); 0035 0036 protected: 0037 QPointer<FieldController> m_ctrl; 0038 QPixmap m_pix; 0039 int m_currentType; 0040 0041 // static members 0042 static QHash<int, QString> m_pictureMap; 0043 static bool m_showImageField; 0044 }; 0045 0046 #endif // CANVASFIELD_H