RackWidget: only allow drag & drop if there is no preview on the board

This commit is contained in:
Olivier Teulière 2013-01-09 18:08:56 +01:00
parent cedb320f91
commit 0763c0771b
2 changed files with 14 additions and 0 deletions

View file

@ -170,12 +170,24 @@ vector<Tile> RackWidget::filterRack(const vector<Tile> &iTiles) const
// Drag & drop handling // Drag & drop handling
bool RackWidget::canStartDragDrop() const
{
if (m_game == NULL || m_game->isFinished())
return false;
// Drag & drop is not allowed when a word is being played
return m_tiles.size() == m_filteredTiles.size();
}
void RackWidget::tilePressed(int row, int col, QMouseEvent *event) void RackWidget::tilePressed(int row, int col, QMouseEvent *event)
{ {
ASSERT(row == 0, "Multi-line racks are not supported"); ASSERT(row == 0, "Multi-line racks are not supported");
ASSERT(col >= 0 && (unsigned)col < m_tilesVect.size(), ASSERT(col >= 0 && (unsigned)col < m_tilesVect.size(),
"Invalid tile index: " << col); "Invalid tile index: " << col);
if (!canStartDragDrop())
return;
LOG_DEBUG("Starting drag for tile " << col); LOG_DEBUG("Starting drag for tile " << col);
TileWidget *tileWidget = m_tilesVect[col]; TileWidget *tileWidget = m_tilesVect[col];

View file

@ -102,6 +102,8 @@ private:
*/ */
vector<Tile> filterRack(const vector<Tile> &iTiles) const; vector<Tile> filterRack(const vector<Tile> &iTiles) const;
bool canStartDragDrop() const;
/** /**
* Return the 0-based index of the tile found at the given (relative) * Return the 0-based index of the tile found at the given (relative)
* position. If there is no such tile, return -1. * position. If there is no such tile, return -1.