From 308e60996601387f4cd2fb61fa43a4fa76046007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Fri, 22 Oct 2010 16:56:32 +0000 Subject: [PATCH] Display the letters correctly --- qt/board_widget.cpp | 21 +++++++++++++++++++-- qt/board_widget.h | 5 ++++- qt/tile_widget.cpp | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/qt/board_widget.cpp b/qt/board_widget.cpp index d697dda..ee3cdb6 100644 --- a/qt/board_widget.cpp +++ b/qt/board_widget.cpp @@ -121,7 +121,8 @@ private: }; BoardWidget::BoardWidget(CoordModel &iCoordModel, QWidget *parent) - : QFrame(parent), m_game(NULL), m_coordModel(iCoordModel) + : QFrame(parent), m_game(NULL), m_coordModel(iCoordModel), + m_widgetsMatrix(BOARD_MAX + 1, BOARD_MAX + 1, 0) { // Try to have a black background... FIXME: not working well! QPalette pal = palette(); @@ -131,7 +132,7 @@ BoardWidget::BoardWidget(CoordModel &iCoordModel, QWidget *parent) setForegroundRole(QPalette::Window); setBackgroundRole(QPalette::Window); - BoardLayout *layout = new BoardLayout(16); + BoardLayout *layout = new BoardLayout(BOARD_MAX + 1); // Line full of coordinates layout->addWidget(new BasicTileWidget(this, "")); for (unsigned int col = BOARD_MIN; col <= BOARD_MAX; ++col) @@ -160,6 +161,7 @@ BoardWidget::BoardWidget(CoordModel &iCoordModel, QWidget *parent) else if (Board::GetLetterMultiplier(row, col) == 2) mult = TileWidget::LETTER_DOUBLE; TileWidget *t = new TileWidget(this, mult); + m_widgetsMatrix[row][col] = t; layout->addWidget(t); } } @@ -194,6 +196,21 @@ void BoardWidget::updateArrow(const Coord &) void BoardWidget::refresh() { + if (m_game != NULL) + { + const Board &board = m_game->getBoard(); + for (unsigned int row = BOARD_MIN; row <= BOARD_MAX; ++row) + { + for (unsigned int col = BOARD_MIN; col <= BOARD_MAX; ++col) + { + m_widgetsMatrix[row][col]->tileChanged( + board.getTile(row, col), + board.isJoker(row, col), + board.isTestChar(row, col), + false, false); + } + } + } update(); } diff --git a/qt/board_widget.h b/qt/board_widget.h index a4085f2..010d03b 100644 --- a/qt/board_widget.h +++ b/qt/board_widget.h @@ -22,10 +22,11 @@ #define BOARD_WIDGET_H_ #include +#include "matrix.h" -class QTreeView; class PublicGame; +class TileWidget; class CoordModel; class Coord; @@ -57,6 +58,8 @@ private: /// Coordinates of the next word to play CoordModel &m_coordModel; + + Matrix m_widgetsMatrix; }; #endif diff --git a/qt/tile_widget.cpp b/qt/tile_widget.cpp index 2856cc6..2b1dd54 100644 --- a/qt/tile_widget.cpp +++ b/qt/tile_widget.cpp @@ -170,7 +170,7 @@ void TileWidget::paintEvent(QPaintEvent *) { painter.setFont(pointsFont); painter.drawText(xPos + squareSize * (1 - pointsCoeff), - yPos + squareSize * (1 - pointsCoeff) + 1, + yPos + squareSize * (1 - pointsCoeff), squareSize * pointsCoeff, squareSize * pointsCoeff + 3, Qt::AlignRight | Qt::AlignBottom, QString("%1").arg(m_tile.getPoints()));