2001-08-27 02:54:27 +00:00
|
|
|
/**
|
|
|
|
* \file QThesaurusDialog.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-08-27 02:54:27 +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-08-27 02:54:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
|
|
|
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"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2001-08-27 02:54:27 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
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-12-17 20:37:13 +00:00
|
|
|
string const entry(fromqstr(item->text(0)));
|
|
|
|
replaceED->setText(toqstr(entry));
|
2001-08-27 20:41:45 +00:00
|
|
|
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-12-17 20:37:13 +00:00
|
|
|
Thesaurus::Meanings meanings = form_->controller().getMeanings(fromqstr(entryED->text()));
|
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);
|
2002-12-17 20:37:13 +00:00
|
|
|
i->setText(0, toqstr(cit->first));
|
2002-01-16 23:56:25 +00:00
|
|
|
i->setOpen(true);
|
|
|
|
for (std::vector<string>::const_iterator cit2 = cit->second.begin();
|
|
|
|
cit2 != cit->second.end(); ++cit2) {
|
|
|
|
QListViewItem * i2 = new QListViewItem(i);
|
2002-12-17 20:37:13 +00:00
|
|
|
i2->setText(0, toqstr(*cit2));
|
2002-01-16 23:56:25 +00:00
|
|
|
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
|
|
|
}
|