Cute Chess  0.1
gameviewer.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef GAMEVIEWER_H
19 #define GAMEVIEWER_H
20 
21 #include <QWidget>
22 #include <QVector>
23 #include <QPointer>
24 #include <board/side.h>
25 #include <board/genericmove.h>
26 class QToolButton;
27 class QSlider;
28 class ChessGame;
29 class PgnGame;
30 class BoardScene;
31 class BoardView;
32 class ChessClock;
33 namespace Chess
34 {
35  class Board;
36 }
37 
38 class GameViewer : public QWidget
39 {
40  Q_OBJECT
41 
42  public:
43  explicit GameViewer(Qt::Orientation orientation = Qt::Horizontal,
44  QWidget* parent = nullptr,
45  bool addChessClock = false);
46 
47  void setGame(ChessGame* game);
48  void setGame(const PgnGame* pgn);
49  void disconnectGame();
50  Chess::Board* board() const;
51  BoardScene* boardScene() const;
52  ChessClock* chessClock(Chess::Side side);
53 
54  public slots:
55  void viewMove(int index);
56 
57  signals:
58  void moveSelected(int moveNumber);
59 
60  private slots:
61  void viewFirstMoveClicked();
62  void viewPreviousMoveClicked();
63  void viewNextMoveClicked();
64  void viewLastMoveClicked();
65  void viewPositionClicked(int index);
66 
67  void onFenChanged(const QString& fen);
68  void onMoveMade(const Chess::GenericMove& move);
69 
70  private:
71  void viewFirstMove();
72  void viewPreviousMove();
73  void viewNextMove();
74  void viewLastMove();
75  void viewPosition(int index);
76 
77  BoardScene* m_boardScene;
78  BoardView* m_boardView;
79  QSlider* m_moveNumberSlider;
80  ChessClock* m_chessClock[2];
81 
82  QToolButton* m_viewFirstMoveBtn;
83  QToolButton* m_viewPreviousMoveBtn;
84  QToolButton* m_viewNextMoveBtn;
85  QToolButton* m_viewLastMoveBtn;
86 
87  QPointer<ChessGame> m_game;
89  int m_moveIndex;
90 };
91 
92 #endif // GAMEVIEWER_H
Definition: chessclock.h:27
An internal chessboard class.
Definition: board.h:56
A graphical surface for displaying a chessgame.
Definition: boardscene.h:56
A game of chess in PGN format.
Definition: pgngame.h:51
Definition: chessgame.h:38
A chess move independent of chess variant or opening book format.
Definition: genericmove.h:33
Definition: boardscene.h:28
The side or color of a chess player.
Definition: side.h:34
Definition: gameviewer.h:38
A view widget for displaying a QGraphicsScene.
Definition: boardview.h:32