2001-08-27 02:54:27 +00:00
|
|
|
/**
|
|
|
|
* \file QThesaurusDialog.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
#include "ControlThesaurus.h"
|
2001-08-27 02:54:27 +00:00
|
|
|
#include "QThesaurusDialog.h"
|
|
|
|
#include "QThesaurus.h"
|
|
|
|
|
|
|
|
#include <qpushbutton.h>
|
2002-01-16 23:56:25 +00:00
|
|
|
#include <qlistview.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
#include <qlineedit.h>
|
2001-08-27 02:54:27 +00:00
|
|
|
|
|
|
|
QThesaurusDialog::QThesaurusDialog(QThesaurus * form)
|
|
|
|
: QThesaurusDialogBase(0, 0, false, 0),
|
|
|
|
form_(form)
|
|
|
|
{
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form, SLOT(slotClose()));
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 02:54:27 +00:00
|
|
|
void QThesaurusDialog::change_adaptor()
|
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 02:54:27 +00:00
|
|
|
void QThesaurusDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QThesaurusDialog::entryChanged()
|
|
|
|
{
|
|
|
|
updateLists();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 02:54:27 +00:00
|
|
|
void QThesaurusDialog::replaceClicked()
|
|
|
|
{
|
|
|
|
form_->replace();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
void QThesaurusDialog::selectionChanged(QListViewItem * item)
|
2001-08-27 02:54:27 +00:00
|
|
|
{
|
2001-08-27 20:41:45 +00:00
|
|
|
if (form_->readOnly())
|
|
|
|
return;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
string const entry(item->text(0).latin1());
|
2001-08-27 20:41:45 +00:00
|
|
|
replaceED->setText(entry.c_str());
|
|
|
|
replacePB->setEnabled(true);
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
void QThesaurusDialog::selectionClicked(QListViewItem * item)
|
2001-08-27 20:41:45 +00:00
|
|
|
{
|
2002-01-16 23:56:25 +00:00
|
|
|
entryED->setText(item->text(0));
|
|
|
|
selectionChanged(item);
|
2001-08-27 02:54:27 +00:00
|
|
|
updateLists();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 02:54:27 +00:00
|
|
|
void QThesaurusDialog::updateLists()
|
|
|
|
{
|
2002-01-16 23:56:25 +00:00
|
|
|
meaningsLV->clear();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 02:54:27 +00:00
|
|
|
std::vector<string> matches;
|
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
meaningsLV->setUpdatesEnabled(false);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
Thesaurus::Meanings meanings = form_->controller().getMeanings(entryED->text().latin1());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
|
|
|
|
cit != meanings.end(); ++cit) {
|
|
|
|
QListViewItem * i = new QListViewItem(meaningsLV);
|
|
|
|
i->setText(0, cit->first.c_str());
|
|
|
|
i->setOpen(true);
|
|
|
|
for (std::vector<string>::const_iterator cit2 = cit->second.begin();
|
|
|
|
cit2 != cit->second.end(); ++cit2) {
|
|
|
|
QListViewItem * i2 = new QListViewItem(i);
|
|
|
|
i2->setText(0, cit2->c_str());
|
|
|
|
i2->setOpen(true);
|
|
|
|
}
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-16 23:56:25 +00:00
|
|
|
meaningsLV->setUpdatesEnabled(true);
|
|
|
|
meaningsLV->update();
|
2001-08-27 02:54:27 +00:00
|
|
|
}
|