]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellchecker.C
Compile fixes. Qt2 should now build (and fail immediately when you start it,
[lyx.git] / src / frontends / qt2 / QSpellchecker.C
1 /**
2  * \file QSpellchecker.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10
11 #include "ControlSpellchecker.h"
12 #include "QSpellcheckerDialog.h"
13 #include "QSpellchecker.h"
14 #include "Qt2BC.h"
15 #include "gettext.h"
16
17 #include <qprogressbar.h>
18 #include <qmessagebox.h>
19 #include <qlineedit.h>
20 #include <qpushbutton.h>
21 #include <qlistbox.h>
22 #include <qcombobox.h>
23
24 typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
25
26 QSpellchecker::QSpellchecker(ControlSpellchecker & c, Dialogs &)
27         : base_class(c, _("Spellchecker"))
28 {
29 }
30
31
32 void QSpellchecker::build_dialog()
33 {
34         dialog_.reset(new QSpellcheckerDialog(this));
35
36         bc().setCancel(dialog_->closePB);
37         dialog_->wordED->setReadOnly(true);
38 }
39
40
41 void QSpellchecker::update_contents()
42 {
43         dialog_->wordED->setText("");
44         dialog_->replaceCO->clear();
45         dialog_->suggestionsLB->clear();
46 }
47
48
49 void QSpellchecker::accept()
50 {
51         controller().ignoreAll();
52 }
53
54
55 void QSpellchecker::add()
56 {
57         controller().insert();
58 }
59
60
61 void QSpellchecker::ignore()
62 {
63         controller().check();
64 }
65
66
67 void QSpellchecker::replace()
68 {
69         controller().replace(dialog_->replaceCO->currentText().latin1());
70 }
71
72
73 void QSpellchecker::options()
74 {
75         controller().options();
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 }