BoardWidget: preliminary version of played word preview

This commit is contained in:
Olivier Teulière 2012-12-24 17:49:30 +01:00
parent 8d85df630b
commit a9f5935285
2 changed files with 21 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include "tile.h"
#include "board.h"
#include "play_model.h"
#include "move.h"
using namespace std;
@ -101,6 +102,8 @@ BoardWidget::BoardWidget(PlayModel &iPlayModel, QWidget *parent)
// Listen to changes in the coordinates
QObject::connect(&m_playModel, SIGNAL(coordChanged(const Coord&, const Coord&)),
this, SLOT(updateArrow(const Coord&, const Coord&)));
QObject::connect(&m_playModel, SIGNAL(moveChanged(const Move&, const Move&)),
this, SLOT(onMoveChanged(const Move&)));
}
@ -131,6 +134,22 @@ void BoardWidget::updateArrow(const Coord &iNewCoord, const Coord &iOldCoord)
}
void BoardWidget::onMoveChanged(const Move &iMove)
{
if (m_game == NULL)
return;
// FIXME
Board &board = const_cast<Board&>(m_game->getBoard());
board.removeTestRound();
if (iMove.isValid())
{
board.testRound(iMove.getRound());
}
refresh();
}
void BoardWidget::refresh()
{
if (m_game != NULL)

View file

@ -31,6 +31,7 @@ class PublicGame;
class TileWidget;
class PlayModel;
class Coord;
class Move;
class BoardWidget: public QFrame
{
@ -57,6 +58,7 @@ protected:
private slots:
void tileClicked(int row, int col, QMouseEvent *iEvent);
void updateArrow(const Coord &iNewCoord, const Coord &iOldCoord);
void onMoveChanged(const Move &iMove);
private:
/// Encapsulated game, can be NULL