1 /*********************************************************************** 2 * 3 * Copyright (C) 2009, 2013 Graeme Gott <graeme@gottcode.org> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 ***********************************************************************/ 19 20 #ifndef BOARD_H 21 #define BOARD_H 22 23 class Cell; 24 class Pattern; 25 class Word; 26 class WordList; 27 28 #include <QGraphicsScene> 29 #include <QList> 30 31 class Board : public QGraphicsScene { 32 Q_OBJECT 33 34 public: 35 Board(QObject* parent = 0); 36 ~Board(); 37 38 void check(const QString& original_word, const QString& current_word); 39 void click(const QString& word); 40 cell(int x,int y)41 Cell* cell(int x, int y) const { 42 return m_cells.value(x).value(y); 43 } 44 pattern()45 Pattern* pattern() const { 46 return m_pattern; 47 } 48 isFinished()49 bool isFinished() const { 50 return m_finished; 51 } 52 isPaused()53 bool isPaused() const { 54 return m_paused; 55 } 56 words()57 WordList* words() { 58 return m_wordlist; 59 } 60 61 void setCurrentWord(Word* word); 62 void setPaused(bool paused); 63 64 public slots: 65 void openGame(); 66 bool openGame(const QString& number); 67 void saveGame(); 68 void showHint(); 69 void togglePaused(); 70 71 signals: 72 void loading(); 73 void finished(); 74 void started(); 75 void pauseChanged(); 76 void hintAvailable(bool available); 77 void wordAdded(const QString& word); 78 void wordSelected(const QString& word); 79 void wordSolved(const QString& original_word, const QString& current_word); 80 81 private slots: 82 void patternGenerated(); 83 84 private: 85 void cleanUp(); 86 87 private: 88 WordList* m_wordlist; 89 Pattern* m_pattern; 90 QList<QList<Cell*> > m_cells; 91 QList<Word*> m_words; 92 Word* m_current_word; 93 QGraphicsItem* m_hint; 94 bool m_finished; 95 bool m_paused; 96 }; 97 98 #endif 99