From a9f59352853edb4b3e0319e543b2ff44dcca1553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Mon, 24 Dec 2012 17:49:30 +0100 Subject: [PATCH] BoardWidget: preliminary version of played word preview --- qt/board_widget.cpp | 19 +++++++++++++++++++ qt/board_widget.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/qt/board_widget.cpp b/qt/board_widget.cpp index aa759a5..6e1aeaf 100644 --- a/qt/board_widget.cpp +++ b/qt/board_widget.cpp @@ -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(m_game->getBoard()); + board.removeTestRound(); + if (iMove.isValid()) + { + board.testRound(iMove.getRound()); + } + refresh(); +} + + void BoardWidget::refresh() { if (m_game != NULL) diff --git a/qt/board_widget.h b/qt/board_widget.h index 5b7f2d9..a47288d 100644 --- a/qt/board_widget.h +++ b/qt/board_widget.h @@ -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