]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiSpellchecker.h
move Controller inheritance further up the tree
[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 : public GuiDialog, public Ui::SpellcheckerUi
31 {
32         Q_OBJECT
33
34 public:
35         GuiSpellchecker(LyXView & lv);
36         ~GuiSpellchecker();
37
38 public Q_SLOTS:
39         void suggestionChanged(QListWidgetItem *);
40
41 private Q_SLOTS:
42         void accept();
43         void add();
44         void ignore();
45         void replace();
46         void replaceChanged(const QString &);
47         void reject();
48
49 private:
50         ///
51         void closeEvent(QCloseEvent * e);
52         /// update from controller
53         void partialUpdate(int id);
54         ///
55         void updateContents();
56
57         ///
58         enum State {
59                 SPELL_PROGRESSED, //< update progress bar
60                 SPELL_FOUND_WORD //< found a bad word
61         };
62
63         ///
64         bool initialiseParams(std::string const & data);
65         ///
66         void clearParams();
67         /// Not needed here
68         void dispatchParams() {}
69         ///
70         bool isBufferDependent() const { return true; }
71         ///
72         bool exitEarly() const { return exitEarly_; }
73
74         /// replace word with replacement
75         void replace(docstring const &);
76
77         /// replace all occurances of word
78         void replaceAll(docstring const &);
79         /// insert word in personal dictionary
80         void insert();
81         /// ignore all occurances of word
82         void ignoreAll();
83         /// check text until next misspelled/unknown word
84         /// returns true when finished
85         void check();
86         /// get suggestion
87         docstring getSuggestion() const;
88         /// get word
89         docstring getWord() const;
90         /// returns progress value
91         int getProgress() const { return oldval_; }
92         /// returns word count
93         int getCount() const { return count_; }
94         /// give error message is spellchecker dies
95         bool checkAlive();
96         /// show count of checked words at normal exit
97         void showSummary();
98
99         /// set to true when spellchecking is finished
100         bool exitEarly_;
101         /// current word being checked and lang code
102         WordLangTuple word_;
103         /// values for progress
104         int oldval_;
105         int newvalue_;
106         /// word count
107         int count_;
108         /// The actual spellchecker object
109         SpellBase * speller_;
110 };
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #endif // GUISPELLCHECKER_H