]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellchecker.C
remove preamble dialog from the qt frontend
[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 "qt_helpers.h"
22 #include "debug.h"
23
24 #include <qprogressbar.h>
25 #include <qmessagebox.h>
26 #include <qlineedit.h>
27 #include <qpushbutton.h>
28 #include <qlistbox.h>
29 #include <qcombobox.h>
30
31 typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
32
33
34 QSpellchecker::QSpellchecker()
35         : base_class(qt_("Spellchecker"))
36 {
37 }
38
39
40 void QSpellchecker::build_dialog()
41 {
42         dialog_.reset(new QSpellcheckerDialog(this));
43
44         bc().setCancel(dialog_->closePB);
45         dialog_->wordED->setReadOnly(true);
46 }
47
48
49 void QSpellchecker::update_contents()
50 {
51         dialog_->wordED->setText("");
52         dialog_->replaceCO->clear();
53         dialog_->suggestionsLB->clear();
54         dialog_->spellcheckPR->setProgress(0);
55         dialog_->spellcheckPB->setEnabled(true);
56         dialog_->wordED->setEnabled(false);
57         dialog_->replaceCO->setEnabled(false);
58         dialog_->replacePB->setEnabled(false);
59         dialog_->ignorePB->setEnabled(false);
60         dialog_->replacePB_3->setEnabled(false);
61         dialog_->addPB->setEnabled(false);
62 }
63
64
65 void QSpellchecker::accept()
66 {
67         controller().ignoreAll();
68 }
69
70
71 void QSpellchecker::add()
72 {
73         controller().insert();
74 }
75
76
77 void QSpellchecker::ignore()
78 {
79         controller().check();
80 }
81
82
83 void QSpellchecker::replace()
84 {
85         controller().replace(fromqstr(dialog_->replaceCO->currentText()));
86 }
87
88
89 void QSpellchecker::spellcheck()
90 {
91         dialog_->spellcheckPB->setEnabled(false);
92         dialog_->wordED->setEnabled(true);
93         dialog_->replaceCO->setEnabled(true);
94         dialog_->replacePB->setEnabled(true);
95         dialog_->ignorePB->setEnabled(true);
96         dialog_->replacePB_3->setEnabled(true);
97         dialog_->addPB->setEnabled(true);
98         controller().check();
99 }
100
101
102 void QSpellchecker::stop()
103 {
104         controller().stop();
105         dialog_->spellcheckPB->setEnabled(true);
106         hide();
107 }
108
109
110 void QSpellchecker::partialUpdate(int id)
111 {
112         switch (id) {
113         case 0:
114                 dialog_->spellcheckPR->setProgress(controller().getProgress());
115                 break;
116
117         case 1: {
118                 dialog_->wordED->setText(toqstr(controller().getWord()));
119                 dialog_->suggestionsLB->clear();
120
121                 string w;
122                 while (!(w = controller().getSuggestion()).empty()) {
123                         dialog_->suggestionsLB->insertItem(toqstr(w));
124                 }
125
126                 dialog_->suggestionChanged(dialog_->wordED->text());
127         }
128                 break;
129
130         case 2:
131                 dialog_->spellcheckPB->setEnabled(true);
132                 hide();
133                 QMessageBox::information(0, qt_("Spellcheck complete"),
134                                          toqstr(controller().getMessage()),
135                                          qt_("OK"));
136                 break;
137         }
138 }