KDEUI
highlighter.h
Go to the documentation of this file.
00001 /* 00002 * highlighter.h 00003 * 00004 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 * 02110-1301 USA 00020 */ 00021 #ifndef SONNET_HIGHLIGHTER_H 00022 #define SONNET_HIGHLIGHTER_H 00023 00024 #include <QtGui/QSyntaxHighlighter> 00025 #include <QtCore/QStringList> 00026 #include <kdemacros.h> 00027 #include <kdeui_export.h> 00028 00029 class QTextEdit; 00030 00031 namespace Sonnet 00032 { 00034 class KDEUI_EXPORT Highlighter : public QSyntaxHighlighter 00035 { 00036 Q_OBJECT 00037 public: 00038 explicit Highlighter(QTextEdit *textEdit, 00039 const QString &configFile = QString(), 00040 const QColor &col=QColor()); 00041 ~Highlighter(); 00042 00043 bool spellCheckerFound() const; 00044 00045 QString currentLanguage() const; 00046 void setCurrentLanguage(const QString &lang); 00047 00048 static QStringList personalWords(); 00049 00063 void setActive(bool active); 00064 00072 bool isActive() const; 00073 00074 bool automatic() const; 00075 00076 void setAutomatic(bool automatic); 00077 00085 void addWordToDictionary(const QString &word); 00086 00095 void ignoreWord(const QString &word); 00096 00108 QStringList suggestionsForWord(const QString &word, int max = 10 ); 00109 00117 bool isWordMisspelled(const QString &word); 00118 00123 void setMisspelledColor(const QColor &color); 00124 00129 bool checkerEnabledByDefault() const; 00130 00131 Q_SIGNALS: 00132 00139 void activeChanged(const QString &description); 00140 00149 QT_MOC_COMPAT void newSuggestions(const QString &originalWord, const QStringList &suggestions); 00150 00151 protected: 00152 00153 virtual void highlightBlock(const QString &text); 00154 virtual void setMisspelled(int start, int count); 00155 virtual void unsetMisspelled(int start, int count); 00156 00157 bool eventFilter(QObject *o, QEvent *e); 00158 bool intraWordEditing() const; 00159 void setIntraWordEditing(bool editing); 00160 00161 public Q_SLOTS: 00162 void slotAutoDetection(); 00163 void slotRehighlight(); 00164 private: 00165 virtual void connectNotify(const char* signal); 00166 virtual void disconnectNotify(const char* signal); 00167 class Private; 00168 Private *const d; 00169 Q_DISABLE_COPY( Highlighter ) 00170 }; 00171 00172 } 00173 00174 #endif
KDE 4.6 API Reference