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
|
|
|
|
2003-09-29 10:50:51 +00:00
|
|
|
#include "debug.h"
|
2001-09-01 03:52:21 +00:00
|
|
|
#include "ControlSpellchecker.h"
|
|
|
|
#include "QSpellcheckerDialog.h"
|
|
|
|
#include "QSpellchecker.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.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;
|
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
typedef Qt2CB<ControlSpellchecker, Qt2DB<QSpellcheckerDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QSpellchecker::QSpellchecker()
|
2003-05-22 18:14:36 +00:00
|
|
|
: base_class(_("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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|