2012-01-29 02:25:37 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 2012 Olivier Teulière
|
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef RACK_WIDGET_H_
|
|
|
|
#define RACK_WIDGET_H_
|
|
|
|
|
2012-12-18 09:56:07 +01:00
|
|
|
#include <vector>
|
2012-08-07 22:18:55 +02:00
|
|
|
#include <QtGui/QFrame>
|
2012-01-29 02:25:37 +01:00
|
|
|
|
|
|
|
#include "tile.h"
|
|
|
|
#include "logging.h"
|
|
|
|
|
2012-12-18 09:56:07 +01:00
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
2012-01-29 02:25:37 +01:00
|
|
|
class PublicGame;
|
|
|
|
class TileWidget;
|
2012-12-18 09:56:07 +01:00
|
|
|
class PlayedRack;
|
2012-12-25 16:30:37 +01:00
|
|
|
class PlayModel;
|
2012-01-29 02:25:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget used to display a rack with big letters
|
|
|
|
*/
|
2012-08-07 22:18:55 +02:00
|
|
|
class RackWidget: public QFrame
|
2012-01-29 02:25:37 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT;
|
|
|
|
DEFINE_LOGGER();
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RackWidget(QWidget *parent = 0);
|
2012-04-10 20:29:52 +02:00
|
|
|
void setShowOnlyLastTurn(bool iShow) { m_showOnlyLastTurn = iShow; }
|
2012-01-29 02:25:37 +01:00
|
|
|
|
2012-12-25 16:30:37 +01:00
|
|
|
void setPlayModel(PlayModel *iPlayModel);
|
|
|
|
|
2012-01-29 02:25:37 +01:00
|
|
|
public slots:
|
|
|
|
void setGame(const PublicGame *iGame);
|
|
|
|
void refresh();
|
2012-12-18 09:56:07 +01:00
|
|
|
void setRack(const vector<Tile> &iTiles);
|
2012-01-29 02:25:37 +01:00
|
|
|
|
2012-12-23 18:40:40 +01:00
|
|
|
protected:
|
|
|
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
virtual void dragLeaveEvent(QDragLeaveEvent *event);
|
|
|
|
virtual void dragMoveEvent(QDragMoveEvent *event);
|
|
|
|
virtual void dropEvent(QDropEvent *event);
|
|
|
|
|
2012-01-29 02:25:37 +01:00
|
|
|
private:
|
|
|
|
/// Encapsulated tiles
|
|
|
|
vector<TileWidget *> m_tilesVect;
|
|
|
|
|
|
|
|
/// Encapsulated game, can be NULL
|
|
|
|
const PublicGame *m_game;
|
2012-04-10 20:29:52 +02:00
|
|
|
|
2012-12-25 16:30:37 +01:00
|
|
|
/// Word being played
|
|
|
|
PlayModel *m_playModel;
|
|
|
|
|
2012-04-10 20:29:52 +02:00
|
|
|
/**
|
|
|
|
* Indicate whether to show only the last rack
|
|
|
|
* (useful for on the external board, in particular in arbitration mode)
|
|
|
|
*/
|
|
|
|
bool m_showOnlyLastTurn;
|
2012-12-23 18:40:40 +01:00
|
|
|
|
2012-12-25 16:30:37 +01:00
|
|
|
/**
|
|
|
|
* If the play model is not NULL and contains a valid move, this method
|
|
|
|
* returns a vector of tiles filtered from the tiles in the move.
|
|
|
|
* Otherwise, the given tiles are returned without any change.
|
|
|
|
*/
|
|
|
|
vector<Tile> filterRack(const vector<Tile> &iTiles) const;
|
|
|
|
|
2012-12-23 18:40:40 +01:00
|
|
|
/**
|
|
|
|
* Return the 0-based index of the tile found at the given (relative)
|
|
|
|
* position. If there is no such tile, return -1.
|
|
|
|
*/
|
|
|
|
int findTile(const QPoint &iPos) const;
|
|
|
|
|
|
|
|
int findClosestTile(const QPoint &iPos) const;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void tilePressed(int row, int col, QMouseEvent *event);
|
2012-01-29 02:25:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|