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.
13 #include "QSpellchecker.h"
14 #include "QSpellcheckerDialog.h"
16 #include "qt_helpers.h"
18 #include "controllers/ControlSpellchecker.h"
20 #include <QProgressBar>
22 #include <QPushButton>
23 #include <QListWidget>
24 #include <QListWidgetItem>
31 typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> > base_class;
33 QSpellchecker::QSpellchecker(Dialog & parent)
34 : base_class(parent, _("Spellchecker"))
38 void QSpellchecker::build_dialog()
40 dialog_.reset(new QSpellcheckerDialog(this));
42 bcview().setCancel(dialog_->closePB);
43 dialog_->wordED->setReadOnly(true);
47 void QSpellchecker::update_contents()
50 // controller().check();
55 void QSpellchecker::accept()
57 controller().ignoreAll();
61 void QSpellchecker::add()
63 controller().insert();
67 void QSpellchecker::ignore()
73 void QSpellchecker::replace()
75 controller().replace(fromqstr(dialog_->replaceCO->currentText()));
79 void QSpellchecker::partialUpdate(int s)
81 ControlSpellchecker::State const state =
82 static_cast<ControlSpellchecker::State>(s);
86 case ControlSpellchecker::SPELL_PROGRESSED:
87 dialog_->spellcheckPR->setValue(controller().getProgress());
90 case ControlSpellchecker::SPELL_FOUND_WORD: {
91 dialog_->wordED->setText(toqstr(controller().getWord()));
92 dialog_->suggestionsLW->clear();
95 while (!(w = controller().getSuggestion()).empty()) {
96 dialog_->suggestionsLW->addItem(toqstr(w));
99 if (dialog_->suggestionsLW->count() == 0) {
100 dialog_->suggestionChanged(new QListWidgetItem(dialog_->wordED->text()));
102 dialog_->suggestionChanged(dialog_->suggestionsLW->item(0));
105 dialog_->suggestionsLW->setCurrentRow(0);
112 } // namespace frontend