KTextEditor

spellingmenu.h
1/*
2 SPDX-FileCopyrightText: 2008-2009 Michel Ludwig <michel.ludwig@kdemail.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef SPELLINGMENU_H
8#define SPELLINGMENU_H
9
10#include <QObject>
11
12#include <KActionCollection>
13#include <KActionMenu>
14#include <ktexteditor/movingrange.h>
15#include <ktexteditor/movingrangefeedback.h>
16#include <ktexteditor/range.h>
17#include <ktexteditor/view.h>
18
19namespace KTextEditor
20{
21class ViewPrivate;
22}
23class KateOnTheFlyChecker;
24
25class KateSpellingMenu : public QObject
26{
28 friend class KateOnTheFlyChecker;
29
30public:
31 explicit KateSpellingMenu(KTextEditor::ViewPrivate *view);
32 ~KateSpellingMenu() override;
33
34 bool isEnabled() const;
35 bool isVisible() const;
36
37 void createActions(KActionCollection *ac);
38
39 /**
40 * This method has to be called before the menu is shown in response to a context
41 * menu event. Ensure contextMenu is valid pointer!
42 **/
43 void prepareToBeShown(QMenu *contextMenu);
44
45 /**
46 * This method has to be called after a context menu event.
47 **/
48 void cleanUpAfterShown();
49
50 void setEnabled(bool b);
51 void setVisible(bool b);
52
53protected:
54 KTextEditor::ViewPrivate *m_view;
55 KActionMenu *m_spellingMenuAction;
56 QAction *m_ignoreWordAction, *m_addToDictionaryAction;
57 QActionGroup *m_dictionaryGroup;
58 QList<QAction *> m_menuOnTopSuggestionList;
59 QMenu *m_spellingMenu;
60 KTextEditor::MovingRange *m_currentMisspelledRange;
61 /**
62 * Set to true when a word was selected. Needed because in such case we got no "exited-notification"
63 * and end up with an always active m_currentMisspelledRange
64 **/
65 bool m_currentMisspelledRangeNeedCleanUp = false;
66 KTextEditor::Range m_selectedRange;
67 QString m_currentDictionary;
68 QStringList m_currentSuggestions;
69
70 // These methods are called from KateOnTheFlyChecker to inform about events involving
71 // moving ranges.
72 void rangeDeleted(KTextEditor::MovingRange *range);
73 void caretEnteredMisspelledRange(KTextEditor::MovingRange *range);
74 void caretExitedMisspelledRange(KTextEditor::MovingRange *range);
75
76protected Q_SLOTS:
77 void populateSuggestionsMenu();
78 void replaceWordBySuggestion(const QString &suggestion);
79
80 void addCurrentWordToDictionary();
81 void ignoreCurrentWord();
82};
83
84#endif
A range that is bound to a specific Document, and maintains its position.
An object representing a section of text, from one Cursor to another.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.