Add support for MyThes (i.e., OpenOffice thesauri).

RegExp experts please have a look at the FIXMEs in GuiThesaurus.cpp.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27572 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-11-16 18:48:25 +00:00
parent 86618e2650
commit df4814e026
14 changed files with 595 additions and 208 deletions

View File

@ -113,6 +113,25 @@ AC_CHECK_LIB(shlwapi, main, [LIBSHLWAPI=-lshlwapi])
AC_SUBST(LIBSHLWAPI)
AC_CHECK_LIB(gdi32, main)
AC_ARG_WITH(mythes,
[ --without-mythes do not use the MyThes library],
[lyx_use_mythes=$withval])
if test x$lyx_use_mythes != xno; then
AC_CHECK_LIB(mythes, main,
[AC_DEFINE(HAVE_LIBMYTHES,1,[Define this if you have the MyThes library])
MYTHES_LIBS="-lmythes"
lyx_flags="mythes $lyx_flags"
])
AC_CHECK_HEADER(mythes.hxx,[
ac_cv_header_mythes_h=yes
lyx_cv_mythes_h_location="<mythes.hxx>"])
AC_CHECK_HEADER(mythes/mythes.hxx,[
ac_cv_header_mythes_h=yes
lyx_cv_mythes_h_location="<mythes/mythes.hxx>"])
AC_DEFINE_UNQUOTED(MYTHES_H_LOCATION,$lyx_cv_mythes_h_location,[Location of mythes.hxx])
fi
AC_SUBST(MYTHES_LIBS)
AC_ARG_WITH(aiksaurus,
[ --without-aiksaurus do not use the Aiksaurus library],
[lyx_use_aiksaurus=$withval])
@ -132,6 +151,8 @@ AC_DEFINE_UNQUOTED(AIKSAURUS_H_LOCATION,$lyx_cv_aiksaurus_h_location,[Location o
fi
AC_SUBST(AIKSAURUS_LIBS)
AC_DEFINE(HAVE_THESAURUS, (HAVE_LIBMYTHES || HAVE_LIBAIKSAURUS),[Define this if you have a supported thesaurus library])
LYX_USE_INCLUDED_BOOST
# Needed for our char_type

View File

@ -961,7 +961,9 @@ void LyXAction::init()
/*!
* \var lyx::FuncCode lyx::LFUN_THESAURUS_ENTRY
* \li Action: Look up thesaurus entries with respect to the word under the cursor.
* \li Syntax: thesaurus-entry
* \li Syntax: thesaurus-entry [<STRING>] [lang=<LANG>]
* \li Params: <STRING>: word to look up
<LANG>: language (see file languages)
* \li Origin: Levon, 20 Jul 2001
* \endvar
*/

View File

@ -395,7 +395,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
switch (cmd.action) {
case LFUN_UNKNOWN_ACTION:
#ifndef HAVE_LIBAIKSAURUS
#ifndef HAVE_THESAURUS
case LFUN_THESAURUS_ENTRY:
#endif
flag.unknown(true);
@ -1943,6 +1943,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
}
case LyXRC::RC_THESAURUSDIRPATH:
case LyXRC::RC_UIFILE:
case LyXRC::RC_USER_EMAIL:
case LyXRC::RC_USER_NAME:

View File

@ -165,6 +165,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
{ "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
{ "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
{ "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
{ "\\ui_file", LyXRC::RC_UIFILE },
{ "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
{ "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
@ -670,6 +671,13 @@ int LyXRC::read(Lexer & lexrc)
}
break;
case RC_THESAURUSDIRPATH:
if (lexrc.next()) {
thesaurusdir_path = os::internal_path(lexrc.getString());
thesaurusdir_path = expandPath(thesaurusdir_path);
}
break;
case RC_USETEMPDIR:
if (lexrc.next())
LYXERR0("Ignoring obsolete use_tempdir flag.");
@ -2039,6 +2047,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
}
if (tag != RC_LAST)
break;
case RC_THESAURUSDIRPATH:
if (ignore_system_lyxrc ||
thesaurusdir_path != system_lyxrc.thesaurusdir_path) {
string const path = os::external_path(thesaurusdir_path);
os << "\\thesaurusdir_path \"" << path << "\"\n";
}
if (tag != RC_LAST)
break;
case RC_USETEMPDIR:
if (tag != RC_LAST)
break;
@ -2791,6 +2807,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
break;
case RC_THESAURUSDIRPATH:
str = _("This is the place where the files of the thesaurus library reside.");
break;
case RC_TEMPLATEPATH:
str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
break;

View File

@ -149,6 +149,7 @@ public:
RC_TEMPLATEPATH,
RC_TEX_ALLOWS_SPACES,
RC_TEX_EXPECTS_WINDOWS_PATHS,
RC_THESAURUSDIRPATH,
RC_UIFILE,
RC_USELASTFILEPOS,
RC_USER_EMAIL,
@ -258,6 +259,8 @@ public:
///
std::string tempdir_path;
///
std::string thesaurusdir_path;
///
bool auto_region_delete;
/// flag telling whether lastfiles should be checked for existance
bool auto_reset_options;

View File

@ -1798,6 +1798,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Get word or selection
selectWordWhenUnderCursor(cur, WHOLE_WORD);
arg = cur.selectionAsString(false);
arg += " lang=" + from_ascii(cur.getFont().language()->lang());
}
}
bv->showDialog("thesaurus", to_utf8(arg));

View File

@ -4,6 +4,7 @@
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
@ -12,34 +13,43 @@
#include "Thesaurus.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "LyXRC.h"
#include "support/FileNameList.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "support/unicode.h"
#include "frontends/alert.h"
#include <algorithm>
#include <cstring>
using namespace std;
using namespace lyx::support;
using namespace lyx::support::os;
namespace lyx {
#ifndef HAVE_LIBMYTHES
#ifdef HAVE_LIBAIKSAURUS
using support::bformat;
Thesaurus::Thesaurus()
: aik_(new Aiksaurus)
: thes_(new Aiksaurus)
{}
Thesaurus::~Thesaurus()
{
delete aik_;
delete thes_;
}
Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &)
{
Meanings meanings;
@ -53,7 +63,7 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
string const text = to_ascii(t);
docstring error = from_ascii(aik_->error());
docstring error = from_ascii(thes_->error());
if (!error.empty()) {
static bool sent_error = false;
if (!sent_error) {
@ -64,7 +74,7 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
}
return meanings;
}
if (!aik_->find(text.c_str()))
if (!thes_->find(text.c_str()))
return meanings;
// weird api, but ...
@ -74,19 +84,19 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
docstring meaning;
// correct, returns "" at the end
string ret = aik_->next(cur_meaning);
string ret = thes_->next(cur_meaning);
while (!ret.empty()) {
if (cur_meaning != prev_meaning) {
meaning = from_ascii(ret);
ret = aik_->next(cur_meaning);
ret = thes_->next(cur_meaning);
prev_meaning = cur_meaning;
} else {
if (ret != text)
meanings[meaning].push_back(from_ascii(ret));
}
ret = aik_->next(cur_meaning);
ret = thes_->next(cur_meaning);
}
for (Meanings::iterator it = meanings.begin();
@ -96,6 +106,164 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const & t)
return meanings;
}
bool Thesaurus::thesaurusAvailable(docstring const & lang) const
{
// we support English only
return (prefixIs(lang, "en_"));
}
#endif // HAVE_LIBAIKSAURUS
#endif // !HAVE_LIBMYTHES
#ifdef HAVE_LIBMYTHES
namespace {
string const to_iconv_encoding(docstring const & s, string const & encoding)
{
std::vector<char> const encoded =
ucs4_to_eightbit(s.data(), s.length(), encoding);
return string(encoded.begin(), encoded.end());
}
docstring const from_iconv_encoding(string const & s, string const & encoding)
{
std::vector<char_type> const ucs4 =
eightbit_to_ucs4(s.data(), s.length(), encoding);
return docstring(ucs4.begin(), ucs4.end());
}
} // namespace anon
Thesaurus::Thesaurus()
{}
Thesaurus::~Thesaurus()
{
for (Thesauri::iterator it = thes_.begin();
it != thes_.end(); ++it) {
delete it->second;
}
}
bool Thesaurus::addThesaurus(docstring const & lang)
{
string const thes_path = external_path(lyxrc.thesaurusdir_path);
LYXERR(Debug::FILES, "thesaurus path: " << thes_path);
if (thes_path.empty())
return false;
if (thesaurusAvailable(lang))
return true;
FileNameList const idx_files = FileName(thes_path).dirList("idx");
FileNameList const data_files = FileName(thes_path).dirList("dat");
string idx;
string data;
for (FileNameList::const_iterator it = idx_files.begin();
it != idx_files.end(); ++it) {
LYXERR(Debug::FILES, "found thesaurus idx file: " << it->onlyFileName());
if (contains(it->onlyFileName(), to_ascii(lang))) {
idx = it->absFilename();
LYXERR(Debug::FILES, "selected thesaurus idx file: " << idx);
break;
}
}
for (support::FileNameList::const_iterator it = data_files.begin();
it != data_files.end(); ++it) {
LYXERR(Debug::FILES, "found thesaurus data file: " << it->onlyFileName());
if (contains(it->onlyFileName(), to_ascii(lang))) {
data = it->absFilename();
LYXERR(Debug::FILES, "selected thesaurus data file: " << data);
break;
}
}
if (idx.empty() || data.empty())
return false;
char const * af = idx.c_str();
char const * df = data.c_str();
thes_[lang] = new MyThes(af, df);
return true;
}
bool Thesaurus::thesaurusAvailable(docstring const & lang) const
{
for (Thesauri::const_iterator it = thes_.begin();
it != thes_.end(); ++it) {
if (it->first == lang)
if (it->second)
return true;
}
return false;
}
Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const & lang)
{
Meanings meanings;
MyThes * mythes = 0;
if (!addThesaurus(lang))
return meanings;
for (Thesauri::const_iterator it = thes_.begin();
it != thes_.end(); ++it) {
if (it->first == lang) {
mythes = it->second;
break;
}
}
if (!mythes)
return meanings;
string const encoding = mythes->get_th_encoding();
mentry * pmean;
string const text = to_iconv_encoding(support::lowercase(t), encoding);
int len = strlen(text.c_str());
int count = mythes->Lookup(text.c_str(), len, &pmean);
if (!count)
return meanings;
// don't change value of pmean or count
// they are needed for the CleanUpAfterLookup routine
mentry * pm = pmean;
docstring meaning;
docstring ret;
for (int i = 0; i < count; i++) {
meaning = from_iconv_encoding(string(pm->defn), encoding);
// remove silly item
if (support::prefixIs(meaning, '-'))
meaning = support::ltrim(meaning, "- ");
for (int j = 0; j < pm->count; j++) {
ret = from_iconv_encoding(string(pm->psyns[j]), encoding);
}
meanings[meaning].push_back(ret);
pm++;
}
// now clean up all allocated memory
mythes->CleanUpAfterLookup(&pmean, count);
for (Meanings::iterator it = meanings.begin();
it != meanings.end(); ++it)
sort(it->second.begin(), it->second.end());
return meanings;
}
#else
Thesaurus::Thesaurus()
@ -113,7 +281,7 @@ Thesaurus::Meanings Thesaurus::lookup(docstring const &)
return Meanings();
}
#endif // HAVE_LIBAIKSAURUS
#endif // HAVE_LIBMYTHES
// Global instance
Thesaurus thesaurus;

View File

@ -5,6 +5,7 @@
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
@ -16,10 +17,15 @@
#include <vector>
#include <map>
#include <string>
#ifdef HAVE_LIBMYTHES
#include MYTHES_H_LOCATION
#else
#ifdef HAVE_LIBAIKSAURUS
#include AIKSAURUS_H_LOCATION
#endif
#endif // HAVE_LIBAIKSAURUS
#endif // !HAVE_LIBMYTHES
namespace lyx {
@ -39,12 +45,23 @@ public:
/**
* look up some text in the thesaurus
*/
Meanings lookup(docstring const & text);
Meanings lookup(docstring const & text, docstring const & lang);
/// check if a thesaurus for a given language \p lang is available
bool thesaurusAvailable(docstring const & lang) const;
private:
#ifdef HAVE_LIBMYTHES
/// add a thesaurus to the list
bool addThesaurus(docstring const & lang);
typedef std::map<docstring, MyThes *> Thesauri;
/// the thesauri
Thesauri thes_;
#else
#ifdef HAVE_LIBAIKSAURUS
Aiksaurus * aik_;
#endif
Aiksaurus * thes_;
#endif // HAVE_LIBAIKSAURUS
#endif // !HAVE_LIBMYTHES
};
extern Thesaurus thesaurus;

View File

@ -926,6 +926,7 @@ PrefPaths::PrefPaths(GuiPreferences * form)
connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
connect(thesaurusDirPB, SIGNAL(clicked()), this, SLOT(select_thesaurusdir()));
connect(workingDirED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
connect(exampleDirED, SIGNAL(textChanged(QString)),
@ -938,6 +939,8 @@ PrefPaths::PrefPaths(GuiPreferences * form)
this, SIGNAL(changed()));
connect(lyxserverDirED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
connect(thesaurusDirED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
connect(pathPrefixED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
}
@ -950,6 +953,7 @@ void PrefPaths::apply(LyXRC & rc) const
rc.template_path = internal_path(fromqstr(templateDirED->text()));
rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
// FIXME: should be a checkbox only
rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
@ -963,6 +967,7 @@ void PrefPaths::update(LyXRC const & rc)
templateDirED->setText(toqstr(external_path(rc.template_path)));
backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
// FIXME: should be a checkbox only
lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
@ -1014,6 +1019,15 @@ void PrefPaths::select_workingdir()
}
void PrefPaths::select_thesaurusdir()
{
QString file = browseDir(internalPath(thesaurusDirED->text()),
qt_("Set the path to the thesaurus dictionaries"));
if (!file.isEmpty())
thesaurusDirED->setText(file);
}
void PrefPaths::select_lyxpipe()
{
QString file = form_->browse(internalPath(lyxserverDirED->text()),

View File

@ -283,6 +283,7 @@ private Q_SLOTS:
void select_tempdir();
void select_backupdir();
void select_workingdir();
void select_thesaurusdir();
void select_lyxpipe();
};

View File

@ -4,6 +4,7 @@
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
@ -11,15 +12,22 @@
#include <config.h>
#include "GuiThesaurus.h"
#include "GuiApplication.h"
#include "qt_helpers.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "FuncRequest.h"
#include "Language.h"
#include "lyxfind.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include <QAbstractItemModel>
#include <QHeaderView>
#include <QLineEdit>
#include <QPushButton>
@ -27,6 +35,7 @@
#include <QTreeWidgetItem>
using namespace lyx::support;
using namespace std;
namespace lyx {
@ -46,17 +55,29 @@ GuiThesaurus::GuiThesaurus(GuiView & lv)
this, SLOT(replaceClicked()));
connect(replaceED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
connect(entryED, SIGNAL(returnPressed()),
connect(entryCO, SIGNAL(editTextChanged(const QString &)),
this, SLOT(entryChanged()));
connect(entryCO, SIGNAL(activated(int)),
this, SLOT(entryChanged()));
connect(lookupPB, SIGNAL(clicked()),
this, SLOT(entryChanged()));
connect(replacePB, SIGNAL(clicked()),
this, SLOT(replaceClicked()));
connect(languageCO, SIGNAL(activated(int)),
this, SLOT(entryChanged()));
connect(meaningsTV, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
this, SLOT(itemClicked(QTreeWidgetItem *, int)));
connect(meaningsTV, SIGNAL(itemSelectionChanged()),
this, SLOT(selectionChanged()));
connect(meaningsTV, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
connect(meaningsTV, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(selectionClicked(QTreeWidgetItem *, int)));
// language
QAbstractItemModel * language_model = guiApp->languageModel();
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
language_model->sort(0);
languageCO->setModel(language_model);
bc().setCancel(closePB);
bc().setApply(replacePB);
bc().addReadOnly(replaceED);
@ -83,7 +104,17 @@ void GuiThesaurus::selectionChanged()
if (col < 0 || isBufferReadonly())
return;
replaceED->setText(meaningsTV->currentItem()->text(col));
QString item = meaningsTV->currentItem()->text(col);
// cut out the classification in brackets
// (as in "hominid (generic term)")
// FIXME: not ideal yet. We need to cut off classifications
// at the beginning as well
// (as in "(noun) man" and "(noun) male (generic term)")
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
int pos = re.indexIn(item);
if (pos > -1)
item = re.cap(1).trimmed();
replaceED->setText(item);
replacePB->setEnabled(true);
changed();
}
@ -97,7 +128,19 @@ void GuiThesaurus::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/)
void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
{
entryED->setText(item->text(col));
QString str = item->text(col);
// cut out the classification in brackets
// (as in "hominid (generic term)")
// FIXME: not ideal yet. We need to cut off classifications
// at the beginning as well
// (as in "(noun) man" and "(noun) male (generic term)")
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
int pos = re.indexIn(str);
if (pos > -1)
str = re.cap(1).trimmed();
entryCO->insertItem(0, str);
entryCO->setCurrentIndex(0);
selectionChanged();
updateLists();
}
@ -108,7 +151,13 @@ void GuiThesaurus::updateLists()
meaningsTV->clear();
meaningsTV->setUpdatesEnabled(false);
Thesaurus::Meanings meanings = getMeanings(qstring_to_ucs4(entryED->text()));
QString const lang = languageCO->itemData(
languageCO->currentIndex()).toString();
docstring const lang_code =
from_ascii(lyx::languages.getLanguage(fromqstr(lang))->code());
Thesaurus::Meanings meanings =
getMeanings(qstring_to_ucs4(entryCO->currentText()), lang_code);
for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
cit != meanings.end(); ++cit) {
@ -120,6 +169,21 @@ void GuiThesaurus::updateLists()
QTreeWidgetItem * i2 = new QTreeWidgetItem(i);
i2->setText(0, toqstr(*cit2));
}
meaningsTV->setEnabled(true);
lookupPB->setEnabled(true);
replaceED->setEnabled(true);
replacePB->setEnabled(true);
}
if (meanings.empty()) {
if (!thesaurus.thesaurusAvailable(lang_code)) {
QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV);
i->setText(0, qt_("No thesaurus available for this language!"));
meaningsTV->setEnabled(false);
lookupPB->setEnabled(false);
replaceED->setEnabled(false);
replacePB->setEnabled(false);
}
}
meaningsTV->setUpdatesEnabled(true);
@ -129,8 +193,13 @@ void GuiThesaurus::updateLists()
void GuiThesaurus::updateContents()
{
entryED->setText(toqstr(text_));
entryCO->clear();
entryCO->addItem(toqstr(text_));
entryCO->setCurrentIndex(0);
replaceED->setText("");
int const pos = languageCO->findData(toqstr(lang_));
if (pos != -1)
languageCO->setCurrentIndex(pos);
updateLists();
}
@ -143,7 +212,17 @@ void GuiThesaurus::replaceClicked()
bool GuiThesaurus::initialiseParams(string const & data)
{
text_ = from_utf8(data);
string arg;
string const lang = rsplit(data, arg, ' ');
if (prefixIs(lang, "lang=")) {
lang_ = from_utf8(split(lang, '='));
text_ = from_utf8(arg);
} else {
text_ = from_utf8(data);
if (bufferview())
lang_ = from_ascii(
bufferview()->buffer().params().language->lang());
}
return true;
}
@ -151,6 +230,7 @@ bool GuiThesaurus::initialiseParams(string const & data)
void GuiThesaurus::clearParams()
{
text_.erase();
lang_.erase();
}
@ -170,10 +250,11 @@ void GuiThesaurus::replace(docstring const & newstr)
}
Thesaurus::Meanings const & GuiThesaurus::getMeanings(docstring const & str)
Thesaurus::Meanings const & GuiThesaurus::getMeanings(docstring const & str,
docstring const & lang)
{
if (str != laststr_)
meanings_ = thesaurus.lookup(str);
meanings_ = thesaurus.lookup(str, lang);
return meanings_;
}

View File

@ -54,7 +54,8 @@ private:
void replace(docstring const & newstr);
/// get meanings
Thesaurus::Meanings const & getMeanings(docstring const & str);
Thesaurus::Meanings const & getMeanings(docstring const & str,
docstring const & lang);
private:
/// last string looked up
@ -66,6 +67,9 @@ private:
/// original string
docstring text_;
/// language
docstring lang_;
/// not needed.
void apply() {}
};

View File

@ -6,28 +6,50 @@
<x>0</x>
<y>0</y>
<width>347</width>
<height>259</height>
<height>311</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="workingDirLA" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="8" column="0" colspan="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>329</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="pathPrefixLA" >
<property name="text" >
<string>&amp;Working directory:</string>
<string>&amp;PATH prefix:</string>
</property>
<property name="buddy" >
<cstring>workingDirED</cstring>
<cstring>pathPrefixED</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="workingDirED" />
<item row="7" column="1" colspan="2" >
<widget class="QLineEdit" name="pathPrefixED" />
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="workingDirPB" >
<item row="6" column="2" >
<widget class="QPushButton" name="thesaurusDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
@ -36,110 +58,18 @@
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="templateDirLA" >
<item row="6" column="0" >
<widget class="QLabel" name="thesaurusDirLA" >
<property name="text" >
<string>&amp;Document templates:</string>
<string>T&amp;hesaurus dictionaries:</string>
</property>
<property name="buddy" >
<cstring>templateDirED</cstring>
<cstring>thesaurusDirED</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="templateDirED" />
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="templateDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="exampleDirLA" >
<property name="text" >
<string>&amp;Example files:</string>
</property>
<property name="buddy" >
<cstring>templateDirED</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="exampleDirED" />
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="exampleDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="backupDirLA" >
<property name="text" >
<string>&amp;Backup directory:</string>
</property>
<property name="buddy" >
<cstring>backupDirED</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="backupDirED" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="backupDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="lyxserverDirLA" >
<property name="text" >
<string>Ly&amp;XServer pipe:</string>
</property>
<property name="buddy" >
<cstring>lyxserverDirED</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="lyxserverDirED" />
</item>
<item row="4" column="2" >
<widget class="QPushButton" name="lyxserverDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="tempDirLA" >
<property name="text" >
<string>&amp;Temporary directory:</string>
</property>
<property name="buddy" >
<cstring>tempDirED</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="tempDirED" />
<item row="6" column="1" >
<widget class="QLineEdit" name="thesaurusDirED" />
</item>
<item row="5" column="2" >
<widget class="QPushButton" name="tempDirPB" >
@ -151,34 +81,133 @@
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="pathPrefixLA" >
<item row="5" column="1" >
<widget class="QLineEdit" name="tempDirED" />
</item>
<item row="5" column="0" >
<widget class="QLabel" name="tempDirLA" >
<property name="text" >
<string>&amp;PATH prefix:</string>
<string>&amp;Temporary directory:</string>
</property>
<property name="buddy" >
<cstring>pathPrefixED</cstring>
<cstring>tempDirED</cstring>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2" >
<widget class="QLineEdit" name="pathPrefixED" />
<item row="4" column="2" >
<widget class="QPushButton" name="lyxserverDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item row="4" column="1" >
<widget class="QLineEdit" name="lyxserverDirED" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="lyxserverDirLA" >
<property name="text" >
<string>Ly&amp;XServer pipe:</string>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
<property name="buddy" >
<cstring>lyxserverDirED</cstring>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</widget>
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="backupDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
</spacer>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="backupDirED" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="backupDirLA" >
<property name="text" >
<string>&amp;Backup directory:</string>
</property>
<property name="buddy" >
<cstring>backupDirED</cstring>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="exampleDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="exampleDirED" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="exampleDirLA" >
<property name="text" >
<string>&amp;Example files:</string>
</property>
<property name="buddy" >
<cstring>templateDirED</cstring>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="templateDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="templateDirED" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="templateDirLA" >
<property name="text" >
<string>&amp;Document templates:</string>
</property>
<property name="buddy" >
<cstring>templateDirED</cstring>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="workingDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="workingDirED" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="workingDirLA" >
<property name="text" >
<string>&amp;Working directory:</string>
</property>
<property name="buddy" >
<cstring>workingDirED</cstring>
</property>
</widget>
</item>
</layout>
</widget>

View File

@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<width>313</width>
<height>414</height>
</rect>
</property>
@ -22,56 +22,57 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QTreeWidget" name="meaningsTV" />
</item>
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="languageCO" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="spacing" >
<number>6</number>
<property name="toolTip" >
<string>Language of the thesaurus</string>
</property>
<item>
<widget class="QLabel" name="entryLA" >
<property name="toolTip" >
<string>Index entry</string>
</property>
<property name="text" >
<string>&amp;Keyword:</string>
</property>
<property name="buddy" >
<cstring>entryED</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="entryED" >
<property name="toolTip" >
<string>Entry</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" >
<item row="1" column="1" >
<widget class="QComboBox" name="entryCO" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Word to look up</string>
</property>
<property name="editable" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="lookupPB" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>L&amp;ookup</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3" >
<widget class="QTreeWidget" name="meaningsTV" >
<property name="toolTip" >
<string>Click to select a proposal, double click to look it up.</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@ -111,7 +112,7 @@
</item>
</layout>
</item>
<item row="3" column="0" >
<item row="4" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@ -144,19 +145,43 @@
</item>
</layout>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="languageLA" >
<property name="text" >
<string>&amp;Language:</string>
</property>
<property name="buddy" >
<cstring>languageCO</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="entryLA" >
<property name="toolTip" >
<string>Index entry</string>
</property>
<property name="text" >
<string>&amp;Keyword:</string>
</property>
<property name="buddy" >
<cstring>entryCO</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<tabstops>
<tabstop>languageCO</tabstop>
<tabstop>entryCO</tabstop>
<tabstop>lookupPB</tabstop>
<tabstop>replaceED</tabstop>
<tabstop>replacePB</tabstop>
<tabstop>meaningsTV</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_i18n.h</include>
</includes>
<tabstops>
<tabstop>entryED</tabstop>
<tabstop>meaningsTV</tabstop>
<tabstop>replaceED</tabstop>
<tabstop>replacePB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>