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 #pragma implementation
17 #include "ControlSpellchecker.h"
18 #include "QSpellcheckerDialog.h"
19 #include "QSpellchecker.h"
21 #include "qt_helpers.h"
24 #include <qprogressbar.h>
25 #include <qmessagebox.h>
26 #include <qlineedit.h>
27 #include <qpushbutton.h>
29 #include <qcombobox.h>
31 typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
34 QSpellchecker::QSpellchecker()
35 : base_class(qt_("Spellchecker"))
40 void QSpellchecker::build_dialog()
42 dialog_.reset(new QSpellcheckerDialog(this));
44 bc().setCancel(dialog_->closePB);
45 dialog_->wordED->setReadOnly(true);
49 void QSpellchecker::update_contents()
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);
65 void QSpellchecker::accept()
67 controller().ignoreAll();
71 void QSpellchecker::add()
73 controller().insert();
77 void QSpellchecker::ignore()
83 void QSpellchecker::replace()
85 controller().replace(fromqstr(dialog_->replaceCO->currentText()));
89 void QSpellchecker::spellcheck()
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);
102 void QSpellchecker::stop()
105 dialog_->spellcheckPB->setEnabled(true);
110 void QSpellchecker::partialUpdate(int id)
114 dialog_->spellcheckPR->setProgress(controller().getProgress());
118 dialog_->wordED->setText(toqstr(controller().getWord()));
119 dialog_->suggestionsLB->clear();
122 while (!(w = controller().getSuggestion()).empty()) {
123 dialog_->suggestionsLB->insertItem(toqstr(w));
126 dialog_->suggestionChanged(dialog_->wordED->text());
131 dialog_->spellcheckPB->setEnabled(true);
133 QMessageBox::information(0, qt_("Spellcheck complete"),
134 toqstr(controller().getMessage()),