| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2009-2010 Michel Ludwig <michel.ludwig@kdemail.net> |
| 3 | SPDX-FileCopyrightText: 2008 Mirko Stocker <me@misto.ch> |
| 4 | SPDX-FileCopyrightText: 2004-2005 Anders Lund <anders@alweb.dk> |
| 5 | SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org> |
| 6 | SPDX-FileCopyrightText: 2001-2004 Christoph Cullmann <cullmann@kde.org> |
| 7 | SPDX-FileCopyrightText: 2001 Joseph Wenninger <jowenn@kde.org> |
| 8 | SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> |
| 9 | |
| 10 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | #ifndef KATE_SPELLCHECKDIALOG_H |
| 14 | #define KATE_SPELLCHECKDIALOG_H |
| 15 | |
| 16 | #include <QObject> |
| 17 | |
| 18 | namespace KTextEditor |
| 19 | { |
| 20 | class ViewPrivate; |
| 21 | } |
| 22 | |
| 23 | class QAction; |
| 24 | class KActionCollection; |
| 25 | |
| 26 | namespace Sonnet |
| 27 | { |
| 28 | class BackgroundChecker; |
| 29 | class Speller; |
| 30 | } |
| 31 | |
| 32 | #include "ktexteditor/range.h" |
| 33 | |
| 34 | namespace KTextEditor |
| 35 | { |
| 36 | class MovingRange; |
| 37 | } |
| 38 | |
| 39 | class SpellCheckBar; |
| 40 | |
| 41 | class KateSpellCheckDialog : public QObject |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | public: |
| 45 | explicit KateSpellCheckDialog(KTextEditor::ViewPrivate *); |
| 46 | ~KateSpellCheckDialog() override; |
| 47 | |
| 48 | void createActions(KActionCollection *); |
| 49 | |
| 50 | // spellcheck from cursor, selection |
| 51 | private Q_SLOTS: |
| 52 | void spellcheckFromCursor(); |
| 53 | |
| 54 | // defined here in anticipation of per view selections ;) |
| 55 | void spellcheckSelection(); |
| 56 | |
| 57 | void spellcheck(); |
| 58 | |
| 59 | /** |
| 60 | * Spellcheck a defined portion of the text. |
| 61 | * |
| 62 | * @param from Where to start the check |
| 63 | * @param to Where to end. If this is (0,0), it will be set to the end of the document. |
| 64 | */ |
| 65 | void spellcheck(const KTextEditor::Cursor from, const KTextEditor::Cursor to = KTextEditor::Cursor()); |
| 66 | |
| 67 | void misspelling(const QString &, int); |
| 68 | void corrected(const QString &, int, const QString &); |
| 69 | |
| 70 | void performSpellCheck(KTextEditor::Range range); |
| 71 | void installNextSpellCheckRange(); |
| 72 | |
| 73 | void cancelClicked(); |
| 74 | |
| 75 | void objectDestroyed(QObject *object); |
| 76 | |
| 77 | void languageChanged(const QString &language); |
| 78 | |
| 79 | private: |
| 80 | KTextEditor::Cursor locatePosition(int pos); |
| 81 | |
| 82 | KTextEditor::ViewPrivate *m_view; |
| 83 | |
| 84 | Sonnet::Speller *m_speller; |
| 85 | Sonnet::BackgroundChecker *m_backgroundChecker; |
| 86 | |
| 87 | SpellCheckBar *m_sonnetDialog; |
| 88 | |
| 89 | // define the part of the text that is to be checked |
| 90 | KTextEditor::Range m_currentSpellCheckRange; |
| 91 | KTextEditor::MovingRange *m_globalSpellCheckRange; |
| 92 | |
| 93 | QList<QPair<int, int>> m_currentDecToEncOffsetList; |
| 94 | |
| 95 | QList<QPair<KTextEditor::Range, QString>> m_languagesInSpellCheckRange; |
| 96 | QList<QPair<KTextEditor::Range, QString>>::iterator m_currentLanguageRangeIterator; |
| 97 | |
| 98 | // keep track of where we are. |
| 99 | KTextEditor::Cursor m_spellPosCursor; |
| 100 | uint m_spellLastPos; |
| 101 | |
| 102 | bool m_spellCheckCancelledByUser; |
| 103 | |
| 104 | QString m_userSpellCheckLanguage, m_previousGivenSpellCheckLanguage; |
| 105 | |
| 106 | void spellCheckDone(); |
| 107 | }; |
| 108 | |
| 109 | #endif |
| 110 | |