Cute Chess 0.1
gameviewer.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 GAMEVIEWER_H
20#define GAMEVIEWER_H
21
22#include <QWidget>
23#include <QVector>
24#include <QPointer>
25#include <board/side.h>
26#include <board/genericmove.h>
27class QToolButton;
28class QSlider;
29class ChessGame;
30class PgnGame;
31class BoardScene;
32class BoardView;
33class ChessClock;
34namespace Chess
35{
36 class Board;
37}
38
39class GameViewer : public QWidget
40{
41 Q_OBJECT
42
43 public:
44 explicit GameViewer(Qt::Orientation orientation = Qt::Horizontal,
45 QWidget* parent = nullptr,
46 bool addChessClock = false);
47
48 void setGame(ChessGame* game);
49 void setGame(const PgnGame* pgn);
50 void disconnectGame();
51 Chess::Board* board() const;
52 BoardScene* boardScene() const;
53 ChessClock* chessClock(Chess::Side side);
54
55 public slots:
56 void viewMove(int index, bool keyLeft = false);
57
58 signals:
59 void moveSelected(int moveNumber);
60
61 private slots:
62 void viewFirstMoveClicked();
63 void viewPreviousMoveClicked();
64 void viewNextMoveClicked();
65 void viewLastMoveClicked();
66 void viewPositionClicked(int index);
67
68 void onFenChanged(const QString& fen);
69 void onMoveMade(const Chess::GenericMove& move);
70
71 private:
72 void viewFirstMove();
73 void viewPreviousMove();
74 void viewNextMove();
75 void viewLastMove();
76 void viewPosition(int index);
77
78 BoardScene* m_boardScene;
79 BoardView* m_boardView;
80 QSlider* m_moveNumberSlider;
81 ChessClock* m_chessClock[2];
82
83 QToolButton* m_viewFirstMoveBtn;
84 QToolButton* m_viewPreviousMoveBtn;
85 QToolButton* m_viewNextMoveBtn;
86 QToolButton* m_viewLastMoveBtn;
87
88 QPointer<ChessGame> m_game;
90 int m_moveIndex;
91};
92
93#endif // GAMEVIEWER_H
A graphical surface for displaying a chessgame.
Definition boardscene.h:58
A view widget for displaying a QGraphicsScene.
Definition boardview.h:34
Definition chessclock.h:29
Definition chessgame.h:39
An internal chessboard class.
Definition board.h:58
A chess move independent of chess variant or opening book format.
Definition genericmove.h:35
The side or color of a chess player.
Definition side.h:36
A game of chess in PGN format.
Definition pgngame.h:52