Cute Chess 0.1
graphicspiece.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef GRAPHICSPIECE_H
20#define GRAPHICSPIECE_H
21
22#include <QGraphicsObject>
23#include <board/piece.h>
24class QSvgRenderer;
25
37class GraphicsPiece : public QGraphicsObject
38{
39 Q_OBJECT
40
41 public:
43 enum { Type = UserType + 4 };
44
53 GraphicsPiece(const Chess::Piece& piece,
54 qreal squareSize,
55 const QString& elementId,
56 QSvgRenderer* renderer,
57 QGraphicsItem* parent = nullptr);
58
59 // Inherited from QGraphicsObject
60 virtual int type() const;
61 virtual QRectF boundingRect() const;
62 virtual void paint(QPainter* painter,
63 const QStyleOptionGraphicsItem* option,
64 QWidget* widget = nullptr);
65
67 Chess::Piece pieceType() const;
75 QGraphicsItem* container() const;
77 void setContainer(QGraphicsItem* item);
78
79 public slots:
88 void restoreParent();
89
90 private:
91 Chess::Piece m_piece;
92 QRectF m_rect;
93 QString m_elementId;
94 QSvgRenderer* m_renderer;
95 QGraphicsItem* m_container;
96};
97
98#endif // GRAPHICSPIECE_H
A chess piece.
Definition piece.h:41
void restoreParent()
Definition graphicspiece.cpp:91
Chess::Piece pieceType() const
Definition graphicspiece.cpp:76
void setContainer(QGraphicsItem *item)
Definition graphicspiece.cpp:86
QGraphicsItem * container() const
Definition graphicspiece.cpp:81
GraphicsPiece(const Chess::Piece &piece, qreal squareSize, const QString &elementId, QSvgRenderer *renderer, QGraphicsItem *parent=nullptr)
Definition graphicspiece.cpp:23