]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellchecker.C
qtabular skeleton
[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
33 QSpellchecker::QSpellchecker()
34         : base_class(_("Spellchecker"))
35 {
36 }
37
38
39 void QSpellchecker::build_dialog()
40 {
41         dialog_.reset(new QSpellcheckerDialog(this));
42
43         bc().setCancel(dialog_->closePB);
44         dialog_->wordED->setReadOnly(true);
45 }
46
47
48 void QSpellchecker::update_contents()
49 {
50         dialog_->wordED->setText("");
51         dialog_->replaceCO->clear();
52         dialog_->suggestionsLB->clear();
53         dialog_->spellcheckPR->setProgress(0.0);
54 }
55
56
57 void QSpellchecker::accept()
58 {
59         controller().ignoreAll();
60 }
61
62
63 void QSpellchecker::add()
64 {
65         controller().insert();
66 }
67
68
69 void QSpellchecker::ignore()
70 {
71         controller().check();
72 }
73
74
75 void QSpellchecker::replace()
76 {
77         controller().replace(dialog_->replaceCO->currentText().latin1());
78 }
79
80
81 void QSpellchecker::spellcheck()
82 {
83         controller().check();
84         dialog_->spellcheckPB->setEnabled(false);
85 }
86
87
88 void QSpellchecker::stop()
89 {
90         controller().stop();
91         dialog_->spellcheckPB->setEnabled(true);
92         hide();
93 }
94
95
96 void QSpellchecker::partialUpdate(int id)
97 {
98         switch (id) {
99         case 0:
100                 dialog_->spellcheckPR->setProgress(controller().getProgress());
101                 break;
102         case 1:
103         {
104                 dialog_->wordED->setText(controller().getWord().c_str());
105                 dialog_->suggestionsLB->clear();
106
107                 string w;
108                 while (!(w = controller().getSuggestion()).empty()) {
109                         dialog_->suggestionsLB->insertItem(w.c_str());
110                 }
111         }
112                 break;
113         case 2:
114                 dialog_->spellcheckPB->setEnabled(true);
115                 hide();
116                 QMessageBox::information(0, _("Spellcheck complete"),
117                                          controller().getMessage().c_str(),
118                                          _("OK"));
119                 break;
120         }
121 }