From 0763c0771bd4868d02c09fc2642a473354c0f8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Wed, 9 Jan 2013 18:08:56 +0100 Subject: [PATCH] RackWidget: only allow drag & drop if there is no preview on the board --- qt/rack_widget.cpp | 12 ++++++++++++ qt/rack_widget.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/qt/rack_widget.cpp b/qt/rack_widget.cpp index 26e0c44..56f335b 100644 --- a/qt/rack_widget.cpp +++ b/qt/rack_widget.cpp @@ -170,12 +170,24 @@ vector RackWidget::filterRack(const vector &iTiles) const // 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) { ASSERT(row == 0, "Multi-line racks are not supported"); ASSERT(col >= 0 && (unsigned)col < m_tilesVect.size(), "Invalid tile index: " << col); + if (!canStartDragDrop()) + return; + LOG_DEBUG("Starting drag for tile " << col); TileWidget *tileWidget = m_tilesVect[col]; diff --git a/qt/rack_widget.h b/qt/rack_widget.h index 55882b8..3aadb9d 100644 --- a/qt/rack_widget.h +++ b/qt/rack_widget.h @@ -102,6 +102,8 @@ private: */ vector filterRack(const vector &iTiles) const; + bool canStartDragDrop() const; + /** * Return the 0-based index of the tile found at the given (relative) * position. If there is no such tile, return -1.