File indexing completed on 2024-04-28 15:30:46
0001 /* 0002 SPDX-FileCopyrightText: 2009-2010 Michel Ludwig <michel.ludwig@kdemail.net> 0003 SPDX-FileCopyrightText: 2008 Mirko Stocker <me@misto.ch> 0004 SPDX-FileCopyrightText: 2004-2005 Anders Lund <anders@alweb.dk> 0005 SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org> 0006 SPDX-FileCopyrightText: 2001-2004 Christoph Cullmann <cullmann@kde.org> 0007 SPDX-FileCopyrightText: 2001 Joseph Wenninger <jowenn@kde.org> 0008 SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> 0009 0010 SPDX-License-Identifier: LGPL-2.0-or-later 0011 */ 0012 0013 #ifndef KATE_SPELLCHECKDIALOG_H 0014 #define KATE_SPELLCHECKDIALOG_H 0015 0016 #include <QObject> 0017 0018 namespace KTextEditor 0019 { 0020 class ViewPrivate; 0021 } 0022 0023 class QAction; 0024 class KActionCollection; 0025 0026 namespace Sonnet 0027 { 0028 class BackgroundChecker; 0029 class Speller; 0030 } 0031 0032 #include "ktexteditor/range.h" 0033 0034 namespace KTextEditor 0035 { 0036 class MovingRange; 0037 } 0038 0039 class SpellCheckBar; 0040 0041 class KateSpellCheckDialog : public QObject 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 explicit KateSpellCheckDialog(KTextEditor::ViewPrivate *); 0047 ~KateSpellCheckDialog() override; 0048 0049 void createActions(KActionCollection *); 0050 0051 // spellcheck from cursor, selection 0052 private Q_SLOTS: 0053 void spellcheckFromCursor(); 0054 0055 // defined here in anticipation of per view selections ;) 0056 void spellcheckSelection(); 0057 0058 void spellcheck(); 0059 0060 /** 0061 * Spellcheck a defined portion of the text. 0062 * 0063 * @param from Where to start the check 0064 * @param to Where to end. If this is (0,0), it will be set to the end of the document. 0065 */ 0066 void spellcheck(const KTextEditor::Cursor from, const KTextEditor::Cursor to = KTextEditor::Cursor()); 0067 0068 void misspelling(const QString &, int); 0069 void corrected(const QString &, int, const QString &); 0070 0071 void performSpellCheck(KTextEditor::Range range); 0072 void installNextSpellCheckRange(); 0073 0074 void cancelClicked(); 0075 0076 void objectDestroyed(QObject *object); 0077 0078 void languageChanged(const QString &language); 0079 0080 private: 0081 KTextEditor::Cursor locatePosition(int pos); 0082 0083 KTextEditor::ViewPrivate *m_view; 0084 0085 Sonnet::Speller *m_speller; 0086 Sonnet::BackgroundChecker *m_backgroundChecker; 0087 0088 SpellCheckBar *m_sonnetDialog; 0089 0090 // define the part of the text that is to be checked 0091 KTextEditor::Range m_currentSpellCheckRange; 0092 KTextEditor::MovingRange *m_globalSpellCheckRange; 0093 0094 QList<QPair<int, int>> m_currentDecToEncOffsetList; 0095 0096 QList<QPair<KTextEditor::Range, QString>> m_languagesInSpellCheckRange; 0097 QList<QPair<KTextEditor::Range, QString>>::iterator m_currentLanguageRangeIterator; 0098 0099 // keep track of where we are. 0100 KTextEditor::Cursor m_spellPosCursor; 0101 uint m_spellLastPos; 0102 0103 bool m_spellCheckCancelledByUser; 0104 0105 QString m_userSpellCheckLanguage, m_previousGivenSpellCheckLanguage; 0106 0107 void spellCheckDone(); 0108 }; 0109 0110 #endif