2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file QSpellcheckerDialog.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QSpellcheckerDialog.h"
|
|
|
|
#include "QSpellchecker.h"
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
#include <QListWidget>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
|
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form, SLOT(slotClose()));
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
connect( replaceCO, SIGNAL( highlighted(const QString&) ),
|
|
|
|
this, SLOT( replaceChanged(const QString &) ) );
|
|
|
|
connect( replacePB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( replaceClicked() ) );
|
|
|
|
connect( ignorePB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( ignoreClicked() ) );
|
|
|
|
connect( replacePB_3, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( acceptClicked() ) );
|
|
|
|
connect( addPB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( addClicked() ) );
|
|
|
|
connect( suggestionsLW, SIGNAL( itemDoubleClicked(QListWidgetItem*) ),
|
|
|
|
this, SLOT( replaceClicked() ) );
|
|
|
|
connect( suggestionsLW, SIGNAL( itemClicked(QListWidgetItem*) ),
|
|
|
|
this, SLOT( suggestionChanged(QListWidgetItem*) ) );
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::acceptClicked()
|
|
|
|
{
|
|
|
|
form_->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::addClicked()
|
|
|
|
{
|
|
|
|
form_->add();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::replaceClicked()
|
|
|
|
{
|
|
|
|
form_->replace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::ignoreClicked()
|
|
|
|
{
|
|
|
|
form_->ignore();
|
|
|
|
}
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
void QSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
if (replaceCO->count() != 0)
|
2006-05-03 19:51:15 +00:00
|
|
|
replaceCO->changeItem(item->text(), 0);
|
2006-03-05 17:24:44 +00:00
|
|
|
else
|
2006-05-03 19:51:15 +00:00
|
|
|
replaceCO->insertItem(item->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
replaceCO->setCurrentItem(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::replaceChanged(const QString & str)
|
|
|
|
{
|
2006-05-03 19:51:15 +00:00
|
|
|
if (suggestionsLW->currentItem()->text() == str)
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
unsigned int i = 0;
|
2006-05-03 19:51:15 +00:00
|
|
|
for (; i < suggestionsLW->count(); ++i) {
|
|
|
|
if (suggestionsLW->item(i)->text() == str)
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
if (i != suggestionsLW->count())
|
|
|
|
suggestionsLW->setCurrentRow(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSpellcheckerDialog::reject()
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
QDialog::reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
#include "QSpellcheckerDialog_moc.cpp"
|