]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiSpellchecker.h
next one
[lyx.git] / src / frontends / qt4 / GuiSpellchecker.h
1 // -*- C++ -*-
2 /**
3  * \file GuiSpellchecker.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Kalle Dalheimer
9  * \author Edwin Leuven
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUISPELLCHECKER_H
15 #define GUISPELLCHECKER_H
16
17 #include "GuiDialog.h"
18 #include "ui_SpellcheckerUi.h"
19 #include "Dialog.h"
20 #include "WordLangTuple.h"
21
22 class QListWidgetItem;
23
24 namespace lyx {
25
26 class SpellBase;
27
28 namespace frontend {
29
30 class GuiSpellchecker
31         : public GuiDialog, public Ui::SpellcheckerUi, public Controller
32 {
33         Q_OBJECT
34
35 public:
36         GuiSpellchecker(LyXView & lv);
37         ~GuiSpellchecker();
38
39 public Q_SLOTS:
40         void suggestionChanged(QListWidgetItem *);
41
42 private Q_SLOTS:
43         void accept();
44         void add();
45         void ignore();
46         void replace();
47         void replaceChanged(const QString &);
48         void reject();
49
50 private:
51         ///
52         void closeEvent(QCloseEvent * e);
53         /// update from controller
54         void partialUpdate(int id);
55         /// parent controller
56         Controller & controller() { return *this; }
57         ///
58         void updateContents();
59
60         ///
61         enum State {
62                 SPELL_PROGRESSED, //< update progress bar
63                 SPELL_FOUND_WORD //< found a bad word
64         };
65
66         ///
67         bool initialiseParams(std::string const & data);
68         ///
69         void clearParams();
70         /// Not needed here
71         void dispatchParams() {}
72         ///
73         bool isBufferDependent() const { return true; }
74         ///
75         bool exitEarly() const { return exitEarly_; }
76
77         /// replace word with replacement
78         void replace(docstring const &);
79
80         /// replace all occurances of word
81         void replaceAll(docstring const &);
82         /// insert word in personal dictionary
83         void insert();
84         /// ignore all occurances of word
85         void ignoreAll();
86         /// check text until next misspelled/unknown word
87         /// returns true when finished
88         void check();
89         /// get suggestion
90         docstring getSuggestion() const;
91         /// get word
92         docstring getWord() const;
93         /// returns progress value
94         int getProgress() const { return oldval_; }
95         /// returns word count
96         int getCount() const { return count_; }
97         /// give error message is spellchecker dies
98         bool checkAlive();
99         /// show count of checked words at normal exit
100         void showSummary();
101
102         /// set to true when spellchecking is finished
103         bool exitEarly_;
104         /// current word being checked and lang code
105         WordLangTuple word_;
106         /// values for progress
107         int oldval_;
108         int newvalue_;
109         /// word count
110         int count_;
111         /// The actual spellchecker object
112         SpellBase * speller_;
113 };
114
115 } // namespace frontend
116 } // namespace lyx
117
118 #endif // GUISPELLCHECKER_H