]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellchecker.C
Lots and lots of little trivial bits.
[lyx.git] / src / frontends / qt2 / QSpellchecker.C
1 /**
2  * \file QSpellchecker.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon 
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlSpellchecker.h"
18 #include "QSpellcheckerDialog.h"
19 #include "QSpellchecker.h"
20 #include "Qt2BC.h"
21 #include "gettext.h"
22
23 #include <qprogressbar.h>
24 #include <qmessagebox.h>
25 #include <qlineedit.h>
26 #include <qpushbutton.h>
27 #include <qlistbox.h>
28 #include <qcombobox.h>
29
30 typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
31
32 QSpellchecker::QSpellchecker()
33         : base_class(_("Spellchecker"))
34 {
35 }
36
37
38 void QSpellchecker::build_dialog()
39 {
40         dialog_.reset(new QSpellcheckerDialog(this));
41
42         bc().setCancel(dialog_->closePB);
43         dialog_->wordED->setReadOnly(true);
44 }
45
46
47 void QSpellchecker::update_contents()
48 {
49         dialog_->wordED->setText("");
50         dialog_->replaceCO->clear();
51         dialog_->suggestionsLB->clear();
52 }
53
54
55 void QSpellchecker::accept()
56 {
57         controller().ignoreAll();
58 }
59
60
61 void QSpellchecker::add()
62 {
63         controller().insert();
64 }
65
66
67 void QSpellchecker::ignore()
68 {
69         controller().check();
70 }
71
72
73 void QSpellchecker::replace()
74 {
75         controller().replace(dialog_->replaceCO->currentText().latin1());
76 }
77
78
79 void QSpellchecker::spellcheck()
80 {
81         controller().check();
82         dialog_->spellcheckPB->setEnabled(false);
83 }
84
85
86 void QSpellchecker::stop()
87 {
88         controller().stop();
89         dialog_->spellcheckPB->setEnabled(true);
90         hide();
91 }
92
93
94 void QSpellchecker::partialUpdate(int id)
95 {
96         switch (id) {
97         case 0:
98                 dialog_->spellcheckPR->setProgress(controller().getProgress());
99                 break;
100         case 1:
101         {
102                 dialog_->wordED->setText(controller().getWord().c_str());
103                 dialog_->suggestionsLB->clear();
104
105                 string w;
106                 while (!(w = controller().getSuggestion()).empty()) {
107                         dialog_->suggestionsLB->insertItem(w.c_str());
108                 }
109         }
110                 break;
111         case 2:
112                 dialog_->spellcheckPB->setEnabled(true);
113                 hide();
114                 QMessageBox::information(0, _("Spellcheck complete"), controller().getMessage().c_str() , _("OK"));
115                 break;
116         }
117 }