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 "tile.h"
#include "board.h" #include "board.h"
#include "play_model.h" #include "play_model.h"
#include "move.h"
using namespace std; using namespace std;
@ -101,6 +102,8 @@ BoardWidget::BoardWidget(PlayModel &iPlayModel, QWidget *parent)
// Listen to changes in the coordinates // Listen to changes in the coordinates
QObject::connect(&m_playModel, SIGNAL(coordChanged(const Coord&, const Coord&)), QObject::connect(&m_playModel, SIGNAL(coordChanged(const Coord&, const Coord&)),
this, SLOT(updateArrow(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() void BoardWidget::refresh()
{ {
if (m_game != NULL) if (m_game != NULL)

View file

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