22 #if defined(QTSPELL_LIBRARY)
23 # define QTSPELL_API Q_DECL_EXPORT
25 # define QTSPELL_API Q_DECL_IMPORT
39 namespace enchant {
class Dict; }
57 class QTSPELL_API
Checker :
public QObject
84 bool setLanguage(
const QString& lang);
127 void addWordToDictionary(
const QString& word);
134 bool checkWord(
const QString& word)
const;
140 void ignoreWord(
const QString& word)
const;
147 QList<QString> getSpellingSuggestions(
const QString& word)
const;
154 static QList<QString> getLanguageList();
164 static QString decodeLanguageCode(
const QString& lang);
182 void showContextMenu(QMenu* menu,
const QPoint& pos,
int wordPos);
186 void slotIgnoreWord();
187 void slotReplaceWord();
188 void slotSetLanguage(
bool checked);
191 enchant::Dict* m_speller =
nullptr;
193 bool m_decodeCodes =
false;
194 bool m_spellingCheckbox =
false;
195 bool m_spellingEnabled =
true;
204 virtual QString
getWord(
int pos,
int* start = 0,
int* end = 0)
const = 0;
212 virtual void insertWord(
int start,
int end,
const QString& word) = 0;
219 bool setLanguageInternal(
const QString& lang);
249 void setTextEdit(QTextEdit* textEdit);
255 void setTextEdit(QPlainTextEdit* textEdit);
275 void checkSpelling(
int start = 0,
int end = -1);
284 void setUndoRedoEnabled(
bool enabled);
309 void clearUndoRedo();
331 TextEditProxy* m_textEdit =
nullptr;
332 QTextDocument* m_document =
nullptr;
333 UndoRedoStack* m_undoRedoStack =
nullptr;
334 bool m_undoRedoInProgress =
false;
335 Qt::ContextMenuPolicy m_oldContextMenuPolicy;
336 int m_noSpellingProperty = -1;
338 QString getWord(
int pos,
int* start = 0,
int* end = 0)
const;
339 void insertWord(
int start,
int end,
const QString& word);
341 void setTextEdit(TextEditProxy* textEdit);
342 bool eventFilter(QObject *obj, QEvent *event);
343 bool noSpellingPropertySet(
const QTextCursor& cursor)
const;
346 void slotShowContextMenu(
const QPoint& pos);
347 void slotCheckDocumentChanged();
348 void slotDetachTextEdit();
349 void slotCheckRange(
int pos,
int removed,
int added);
An abstract class providing spell checking support.
void setShowCheckSpellingCheckbox(bool show)
Set whether to display an "Check spelling" checkbox in the UI.
virtual bool isAttached() const =0
Returns whether a widget is attached to the checker.
void setDecodeLanguageCodes(bool decode)
Set whether to decode language codes in the UI.
bool getShowCheckSpellingCheckbox() const
Return whether a "Check spelling" checkbox is displayed in the UI.
bool getSpellingEnabled() const
Return whether spellchecking is performed.
bool getDecodeLanguageCodes() const
Return whether langauge codes are decoded in the UI.
void setSpellingEnabled(bool enabled)
Set whether spell checking should be performed.
void languageChanged(const QString &newLang)
This signal is emitted when the user selects a new language from the spellchecker UI.
virtual void checkSpelling(int start=0, int end=-1)=0
Check the spelling.
virtual QString getWord(int pos, int *start=0, int *end=0) const =0
Get the word at the specified cursor position.
virtual void insertWord(int start, int end, const QString &word)=0
Replaces the specified range with the specified word.
const QString & getLanguage() const
Retreive the current spelling language.
Checker class for QTextEdit widgets.
void setNoSpellingPropertyId(int propertyId)
Set the QTextCharFormat property identifier which marks whether a word ought to be spell-checked.
bool isAttached() const
Returns whether a widget is attached to the checker.
void redoAvailable(bool available)
Emitted when the redo stak changes.
void undoAvailable(bool available)
Emitted when the undo stack changes.
int noSpellingPropertyId() const
Returns the current QTextCharFormat property identifier which marks whether a word ought to be spell-...
bool checkLanguageInstalled(const QString &lang)
Check whether the dictionary for a language is installed.