2008-01-24 21:18:00 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Eliot
|
2012-10-07 16:25:41 +02:00
|
|
|
* Copyright (C) 2008-2012 Olivier Teulière
|
2008-01-24 21:18:00 +01:00
|
|
|
* 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 TRAINING_WIDGET_H_
|
|
|
|
#define TRAINING_WIDGET_H_
|
|
|
|
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include "ui/training_widget.ui.h"
|
2012-02-18 22:26:52 +01:00
|
|
|
#include "logging.h"
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class QStandardItemModel;
|
2008-01-27 00:03:32 +01:00
|
|
|
class QString;
|
2011-07-28 22:55:48 +02:00
|
|
|
class QPoint;
|
2012-12-18 00:48:14 +01:00
|
|
|
class PlayModel;
|
2011-07-28 22:55:48 +02:00
|
|
|
class CustomPopup;
|
2009-02-19 19:25:17 +01:00
|
|
|
class PlayWordMediator;
|
|
|
|
class PublicGame;
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
class TrainingWidget: public QWidget, private Ui::TrainingWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT;
|
2012-02-18 22:26:52 +01:00
|
|
|
DEFINE_LOGGER();
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
public:
|
2012-12-18 00:48:14 +01:00
|
|
|
explicit TrainingWidget(QWidget *parent, PlayModel &iPlayModel, PublicGame *iGame);
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void refresh();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void gameUpdated();
|
2008-01-27 00:03:32 +01:00
|
|
|
void notifyProblem(QString iMsg);
|
2008-11-04 22:31:13 +01:00
|
|
|
void notifyInfo(QString iMsg);
|
2008-12-14 14:20:38 +01:00
|
|
|
void rackUpdated(const QString &iRack);
|
2011-07-28 22:55:48 +02:00
|
|
|
void requestDefinition(QString iWord);
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Define a default size
|
|
|
|
virtual QSize sizeHint() const;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void enablePlayButton(const QItemSelection &, const QItemSelection &);
|
|
|
|
void showPreview(const QItemSelection &, const QItemSelection &);
|
|
|
|
|
2011-07-17 11:09:47 +02:00
|
|
|
void lockSizesChanged(bool checked);
|
2011-07-28 22:55:48 +02:00
|
|
|
void populateMenu(QMenu &iMenu, const QPoint &iPoint);
|
2011-07-17 11:09:47 +02:00
|
|
|
|
2012-10-05 15:55:49 +02:00
|
|
|
void onRackEdited(const QString &iText);
|
|
|
|
void setNewRack();
|
|
|
|
void completeRack();
|
|
|
|
void search();
|
|
|
|
void playSelectedWord();
|
2008-01-24 21:18:00 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Encapsulated training game, can be NULL
|
2008-11-30 21:53:44 +01:00
|
|
|
PublicGame *m_game;
|
2008-01-24 21:18:00 +01:00
|
|
|
|
2012-10-05 17:55:41 +02:00
|
|
|
/// Indicate whether the columns should be resized after a search
|
2011-07-17 11:09:47 +02:00
|
|
|
bool m_autoResizeColumns;
|
|
|
|
|
2008-01-24 21:18:00 +01:00
|
|
|
/// Model of the search results
|
|
|
|
QStandardItemModel *m_model;
|
|
|
|
|
2009-02-19 19:25:17 +01:00
|
|
|
/// Mediator for the "play word" controls
|
|
|
|
PlayWordMediator *m_mediator;
|
2008-01-24 21:18:00 +01:00
|
|
|
|
2009-06-27 20:09:44 +02:00
|
|
|
/// Palette to write text in black
|
|
|
|
QPalette blackPalette;
|
|
|
|
|
2012-03-11 00:19:36 +01:00
|
|
|
/// Palette to write text in red
|
|
|
|
QPalette redPalette;
|
|
|
|
|
2011-07-28 22:55:48 +02:00
|
|
|
/// Popup menu for words definition
|
|
|
|
CustomPopup *m_customPopup;
|
|
|
|
|
2008-01-24 21:18:00 +01:00
|
|
|
/// Force synchronizing the model with the contents of the search results
|
|
|
|
void updateModel();
|
2012-10-05 15:55:49 +02:00
|
|
|
|
|
|
|
/// Helper method to set the rack
|
|
|
|
void helperSetRack(bool iAll);
|
2008-01-24 21:18:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|