]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QSpellchecker.C
This new citation dialog follows a new design similar to lyx-1.3:
[lyx.git] / src / frontends / qt4 / 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 #include "QSpellchecker.h"
14 #include "QSpellcheckerDialog.h"
15 #include "Qt2BC.h"
16 #include "qt_helpers.h"
17
18 #include "controllers/ControlSpellchecker.h"
19
20 #include <q3progressbar.h>
21 #include <qlineedit.h>
22 #include <qpushbutton.h>
23 #include <q3listbox.h>
24
25 using std::string;
26
27 namespace lyx {
28 namespace frontend {
29
30 typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> > base_class;
31
32 QSpellchecker::QSpellchecker(Dialog & parent)
33         : base_class(parent, _("Spellchecker"))
34 {}
35
36
37 void QSpellchecker::build_dialog()
38 {
39         dialog_.reset(new QSpellcheckerDialog(this));
40
41         bcview().setCancel(dialog_->closePB);
42         dialog_->wordED->setReadOnly(true);
43 }
44
45
46 void QSpellchecker::update_contents()
47 {
48         controller().check();
49 }
50
51
52 void QSpellchecker::accept()
53 {
54         controller().ignoreAll();
55 }
56
57
58 void QSpellchecker::add()
59 {
60         controller().insert();
61 }
62
63
64 void QSpellchecker::ignore()
65 {
66         controller().check();
67 }
68
69
70 void QSpellchecker::replace()
71 {
72         controller().replace(fromqstr(dialog_->replaceCO->currentText()));
73 }
74
75
76 void QSpellchecker::partialUpdate(int s)
77 {
78         ControlSpellchecker::State const state =
79                 static_cast<ControlSpellchecker::State>(s);
80
81         switch (state) {
82
83         case ControlSpellchecker::SPELL_PROGRESSED:
84                 dialog_->spellcheckPR->setProgress(controller().getProgress());
85                 break;
86
87         case ControlSpellchecker::SPELL_FOUND_WORD: {
88                 dialog_->wordED->setText(toqstr(controller().getWord()));
89                 dialog_->suggestionsLB->clear();
90
91                 string w;
92                 while (!(w = controller().getSuggestion()).empty()) {
93                         dialog_->suggestionsLB->insertItem(toqstr(w));
94                 }
95
96                 if (dialog_->suggestionsLB->count() == 0) {
97                         dialog_->suggestionChanged(dialog_->wordED->text());
98                 } else {
99                         dialog_->suggestionChanged(dialog_->suggestionsLB->text(0));
100                 }
101         }
102                 break;
103
104         }
105 }
106
107 } // namespace frontend
108 } // namespace lyx