]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellchecker.C
build fixes
[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::spellcheck()
74 {
75         controller().check();
76         dialog_->spellcheckPB->setEnabled(false);
77 }
78
79
80 void QSpellchecker::stop()
81 {
82         controller().stop();
83         dialog_->spellcheckPB->setEnabled(true);
84         hide();
85 }
86
87
88 void QSpellchecker::partialUpdate(int id)
89 {
90         switch (id) {
91         case 0:
92                 dialog_->spellcheckPR->setProgress(controller().getProgress());
93                 break;
94         case 1:
95         {
96                 dialog_->wordED->setText(controller().getWord().c_str());
97                 dialog_->suggestionsLB->clear();
98
99                 string w;
100                 while (!(w = controller().getSuggestion()).empty()) {
101                         dialog_->suggestionsLB->insertItem(w.c_str());
102                 }
103         }
104                 break;
105         case 2:
106                 dialog_->spellcheckPB->setEnabled(true);
107                 hide();
108                 QMessageBox::information(0, _("Spellcheck complete"), controller().getMessage().c_str() , _("OK"));
109                 break;
110         }
111 }