Topping:: allow shuffling the rack

This commit is contained in:
Olivier Teulière 2013-01-09 18:05:22 +01:00
parent 59b739d292
commit cedb320f91
2 changed files with 13 additions and 1 deletions

View file

@ -32,6 +32,7 @@
#include "dic.h" #include "dic.h"
#include "move.h" #include "move.h"
#include "pldrack.h" #include "pldrack.h"
#include "player.h"
#include "public_game.h" #include "public_game.h"
#include "game_exception.h" #include "game_exception.h"
#include "debug.h" #include "debug.h"
@ -64,6 +65,9 @@ ToppingWidget::ToppingWidget(QWidget *parent, PlayModel &iPlayModel, PublicGame
QObject::connect(m_mediator, SIGNAL(notifyProblem(QString)), QObject::connect(m_mediator, SIGNAL(notifyProblem(QString)),
this, SIGNAL(notifyProblem(QString))); this, SIGNAL(notifyProblem(QString)));
QObject::connect(pushButtonShuffle, SIGNAL(clicked()),
this, SLOT(shuffle()));
// Associate the model to the view. // Associate the model to the view.
// We use a proxy for easy sorting. // We use a proxy for easy sorting.
m_model = new QStandardItemModel(this); m_model = new QStandardItemModel(this);
@ -113,7 +117,7 @@ void ToppingWidget::refresh()
} }
else else
{ {
wstring rack = m_game->getCurrentRack().toString(PlayedRack::RACK_SIMPLE); wstring rack = m_game->getCurrentPlayer().getCurrentRack().toString(PlayedRack::RACK_SIMPLE);
// Update the rack only if it is needed, to avoid losing cursor position // Update the rack only if it is needed, to avoid losing cursor position
if (qfw(rack) != lineEditRack->text()) if (qfw(rack) != lineEditRack->text())
lineEditRack->setText(qfw(rack)); lineEditRack->setText(qfw(rack));
@ -172,6 +176,13 @@ void ToppingWidget::lockSizesChanged(bool checked)
} }
void ToppingWidget::shuffle()
{
m_game->shuffleRack();
emit gameUpdated();
}
void ToppingWidget::showHintsDialog() void ToppingWidget::showHintsDialog()
{ {
const Move &move = m_game->toppingGetTopMove(); const Move &move = m_game->toppingGetTopMove();

View file

@ -57,6 +57,7 @@ protected:
private slots: private slots:
void lockSizesChanged(bool checked); void lockSizesChanged(bool checked);
void shuffle();
void showHintsDialog(); void showHintsDialog();
void hintUsed(const AbstractHint&); void hintUsed(const AbstractHint&);