1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 2009 Licq developers 4 * 5 * Licq 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 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Licq 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 Licq; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef SPELLCHECKER_H 21 #define SPELLCHECKER_H 22 23 #include "config.h" 24 25 #include <QSyntaxHighlighter> 26 27 class Hunspell; 28 29 namespace LicqQtGui 30 { 31 32 /** 33 * Syntax highlighter that will mark misspelled words 34 */ 35 class SpellChecker : public QSyntaxHighlighter 36 { 37 Q_OBJECT 38 public: 39 /** 40 * Constructor 41 * 42 * @param parent Document to perform spell checking on 43 * @param dicFile Dictionary file to use 44 */ 45 SpellChecker(QTextDocument* parent, const QString& dicFile); 46 47 /** 48 * Destructor 49 */ 50 ~SpellChecker(); 51 52 /** 53 * Get a list of suggestions for a misspelled word 54 * 55 * @param word Word to get suggestions for 56 * @return List of suggestions or empty if word is valid 57 */ 58 QStringList getSuggestions(const QString& word); 59 60 /** 61 * Check spelling of a single word 62 * 63 * @param word Word to check 64 * @return True if word is valid 65 */ 66 bool checkWord(const QString& word); 67 68 public slots: 69 /** 70 * Set dictionary file to use 71 * 72 * @param dicFile Dictionary file to use 73 */ 74 void setDictionary(const QString& dicFile); 75 76 protected: 77 /** 78 * Perform spell checking on a block of text 79 * 80 * @param text Text to spell check 81 */ 82 virtual void highlightBlock(const QString& text); 83 84 private: 85 QString myDicFile; 86 Hunspell* mySpeller; 87 QTextCodec* mySpellerCodec; 88 }; 89 90 } // namespace LicqQtGui 91 92 #endif 93