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
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
#include "ControlSpellchecker.h"
|
|
|
|
#include "QSpellcheckerDialog.h"
|
|
|
|
#include "QSpellchecker.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#include <qprogressbar.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
#include <qmessagebox.h>
|
2001-09-01 03:52:21 +00:00
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
|
|
|
|
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()
|
|
|
|
: base_class(_("Spellchecker"))
|
2001-09-01 03:52:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QSpellcheckerDialog(this));
|
|
|
|
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
dialog_->wordED->setReadOnly(true);
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-01 03:52:21 +00:00
|
|
|
void QSpellchecker::update_contents()
|
|
|
|
{
|
|
|
|
dialog_->wordED->setText("");
|
|
|
|
dialog_->replaceCO->clear();
|
|
|
|
dialog_->suggestionsLB->clear();
|
|
|
|
}
|
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()
|
|
|
|
{
|
|
|
|
controller().replace(dialog_->replaceCO->currentText().latin1());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::spellcheck()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
controller().check();
|
2001-09-01 03:52:21 +00:00
|
|
|
dialog_->spellcheckPB->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellchecker::stop()
|
|
|
|
{
|
|
|
|
controller().stop();
|
|
|
|
dialog_->spellcheckPB->setEnabled(true);
|
2002-03-21 21:21:28 +00:00
|
|
|
hide();
|
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::partialUpdate(int id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
|
|
|
case 0:
|
|
|
|
dialog_->spellcheckPR->setProgress(controller().getProgress());
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
dialog_->wordED->setText(controller().getWord().c_str());
|
|
|
|
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()) {
|
|
|
|
dialog_->suggestionsLB->insertItem(w.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dialog_->spellcheckPB->setEnabled(true);
|
|
|
|
hide();
|
2002-10-20 01:48:28 +00:00
|
|
|
QMessageBox::information(0, _("Spellcheck complete"),
|
|
|
|
controller().getMessage().c_str(),
|
|
|
|
_("OK"));
|
2001-09-01 03:52:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|