2 * \file QSpellchecker.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #include "ControlSpellchecker.h"
15 #include "QSpellcheckerDialog.h"
16 #include "QSpellchecker.h"
18 #include "qt_helpers.h"
21 #include <qprogressbar.h>
22 #include <qmessagebox.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
26 #include <qcombobox.h>
28 typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
31 QSpellchecker::QSpellchecker()
32 : base_class(qt_("LyX: Spell-check Document"))
37 void QSpellchecker::build_dialog()
39 dialog_.reset(new QSpellcheckerDialog(this));
41 bc().setCancel(dialog_->closePB);
42 dialog_->wordED->setReadOnly(true);
46 void QSpellchecker::accept()
48 controller().ignoreAll();
52 void QSpellchecker::add()
54 controller().insert();
58 void QSpellchecker::ignore()
64 void QSpellchecker::replace()
66 controller().replace(fromqstr(dialog_->replaceCO->currentText()));
70 void QSpellchecker::partialUpdate(int s)
72 ControlSpellchecker::State const state =
73 static_cast<ControlSpellchecker::State>(s);
77 case ControlSpellchecker::SPELL_PROGRESSED:
78 dialog_->spellcheckPR->setProgress(controller().getProgress());
81 case ControlSpellchecker::SPELL_FOUND_WORD: {
82 dialog_->wordED->setText(toqstr(controller().getWord()));
83 dialog_->suggestionsLB->clear();
86 while (!(w = controller().getSuggestion()).empty()) {
87 dialog_->suggestionsLB->insertItem(toqstr(w));
90 if (dialog_->suggestionsLB->count() == 0) {
91 dialog_->suggestionChanged(dialog_->wordED->text());
93 dialog_->suggestionChanged(dialog_->suggestionsLB->text(0));