2001-09-01 03:52:21 +00:00
|
|
|
/**
|
|
|
|
* \file QSpellchecker.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-09-01 03:52:21 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-09-01 03:52:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
#include "QSpellchecker.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "QSpellcheckerDialog.h"
|
2001-09-01 03:52:21 +00:00
|
|
|
#include "Qt2BC.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2001-09-01 03:52:21 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "controllers/ControlSpellchecker.h"
|
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
#include <qprogressbar.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2004-03-31 19:51:55 +00:00
|
|
|
typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2004-03-31 19:51:55 +00:00
|
|
|
QSpellchecker::QSpellchecker(Dialog & parent)
|
|
|
|
: base_class(parent, _("LyX: Spell-check Document"))
|
|
|
|
{}
|
2001-09-01 03:52:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QSpellcheckerDialog(this));
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setCancel(dialog_->closePB);
|
2001-09-01 03:52:21 +00:00
|
|
|
dialog_->wordED->setReadOnly(true);
|
2004-03-31 19:51:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::update_contents()
|
|
|
|
{
|
|
|
|
controller().check();
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
void QSpellchecker::accept()
|
|
|
|
{
|
|
|
|
controller().ignoreAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::add()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
controller().insert();
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::ignore()
|
|
|
|
{
|
|
|
|
controller().check();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::replace()
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
controller().replace(fromqstr(dialog_->replaceCO->currentText()));
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-17 18:40:04 +00:00
|
|
|
void QSpellchecker::partialUpdate(int s)
|
2001-09-01 03:52:21 +00:00
|
|
|
{
|
2003-02-25 13:35:26 +00:00
|
|
|
ControlSpellchecker::State const state =
|
2003-02-17 18:40:04 +00:00
|
|
|
static_cast<ControlSpellchecker::State>(s);
|
2001-09-01 03:52:21 +00:00
|
|
|
|
2003-02-17 18:40:04 +00:00
|
|
|
switch (state) {
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-02-17 18:40:04 +00:00
|
|
|
case ControlSpellchecker::SPELL_PROGRESSED:
|
2001-09-01 03:52:21 +00:00
|
|
|
dialog_->spellcheckPR->setProgress(controller().getProgress());
|
|
|
|
break;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2003-02-17 18:40:04 +00:00
|
|
|
case ControlSpellchecker::SPELL_FOUND_WORD: {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->wordED->setText(toqstr(controller().getWord()));
|
2001-09-01 03:52:21 +00:00
|
|
|
dialog_->suggestionsLB->clear();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
string w;
|
|
|
|
while (!(w = controller().getSuggestion()).empty()) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->suggestionsLB->insertItem(toqstr(w));
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
2002-12-12 21:07:20 +00:00
|
|
|
|
2003-02-15 22:26:27 +00:00
|
|
|
if (dialog_->suggestionsLB->count() == 0) {
|
|
|
|
dialog_->suggestionChanged(dialog_->wordED->text());
|
|
|
|
} else {
|
|
|
|
dialog_->suggestionChanged(dialog_->suggestionsLB->text(0));
|
|
|
|
}
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|