Changeset 27572

Show
Ignore:
Timestamp:
11/16/08 19:48:25 (2 months ago)
Author:
spitz
Message:

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

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lyx-devel/trunk/configure.ac

    r27469 r27572  
    113113AC_SUBST(LIBSHLWAPI) 
    114114AC_CHECK_LIB(gdi32, main) 
     115 
     116AC_ARG_WITH(mythes, 
     117  [  --without-mythes        do not use the MyThes library], 
     118  [lyx_use_mythes=$withval]) 
     119if test x$lyx_use_mythes != xno; then 
     120AC_CHECK_LIB(mythes, main, 
     121        [AC_DEFINE(HAVE_LIBMYTHES,1,[Define this if you have the MyThes library]) 
     122         MYTHES_LIBS="-lmythes" 
     123         lyx_flags="mythes $lyx_flags" 
     124        ]) 
     125AC_CHECK_HEADER(mythes.hxx,[ 
     126  ac_cv_header_mythes_h=yes 
     127  lyx_cv_mythes_h_location="<mythes.hxx>"]) 
     128AC_CHECK_HEADER(mythes/mythes.hxx,[ 
     129  ac_cv_header_mythes_h=yes 
     130  lyx_cv_mythes_h_location="<mythes/mythes.hxx>"]) 
     131AC_DEFINE_UNQUOTED(MYTHES_H_LOCATION,$lyx_cv_mythes_h_location,[Location of mythes.hxx]) 
     132fi 
     133AC_SUBST(MYTHES_LIBS) 
    115134 
    116135AC_ARG_WITH(aiksaurus, 
     
    132151fi 
    133152AC_SUBST(AIKSAURUS_LIBS) 
     153 
     154AC_DEFINE(HAVE_THESAURUS, (HAVE_LIBMYTHES || HAVE_LIBAIKSAURUS),[Define this if you have a supported thesaurus library]) 
    134155 
    135156LYX_USE_INCLUDED_BOOST 
  • lyx-devel/trunk/src/LyXAction.cpp

    r27527 r27572  
    962962 * \var lyx::FuncCode lyx::LFUN_THESAURUS_ENTRY 
    963963 * \li Action: Look up thesaurus entries with respect to the word under the cursor. 
    964  * \li Syntax: thesaurus-entry 
     964 * \li Syntax: thesaurus-entry [<STRING>] [lang=<LANG>] 
     965 * \li Params: <STRING>: word to look up 
     966               <LANG>: language (see file languages) 
    965967 * \li Origin: Levon, 20 Jul 2001 
    966968 * \endvar 
  • lyx-devel/trunk/src/LyXFunc.cpp

    r27565 r27572  
    396396        switch (cmd.action) { 
    397397        case LFUN_UNKNOWN_ACTION: 
    398 #ifndef HAVE_LIBAIKSAURUS 
     398#ifndef HAVE_THESAURUS 
    399399        case LFUN_THESAURUS_ENTRY: 
    400400#endif 
     
    19441944                        os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths); 
    19451945                } 
     1946        case LyXRC::RC_THESAURUSDIRPATH: 
    19461947        case LyXRC::RC_UIFILE: 
    19471948        case LyXRC::RC_USER_EMAIL: 
  • lyx-devel/trunk/src/LyXRC.cpp

    r27547 r27572  
    166166        { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES }, 
    167167        { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS }, 
     168        { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH }, 
    168169        { "\\ui_file", LyXRC::RC_UIFILE }, 
    169170        { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG }, 
     
    671672                        break; 
    672673 
     674                case RC_THESAURUSDIRPATH: 
     675                        if (lexrc.next()) { 
     676                                thesaurusdir_path = os::internal_path(lexrc.getString()); 
     677                                thesaurusdir_path = expandPath(thesaurusdir_path); 
     678                        } 
     679                        break; 
     680 
    673681                case RC_USETEMPDIR: 
    674682                        if (lexrc.next()) 
     
    20402048                if (tag != RC_LAST) 
    20412049                        break; 
     2050        case RC_THESAURUSDIRPATH: 
     2051                if (ignore_system_lyxrc || 
     2052                    thesaurusdir_path != system_lyxrc.thesaurusdir_path) { 
     2053                        string const path = os::external_path(thesaurusdir_path); 
     2054                        os << "\\thesaurusdir_path \"" << path << "\"\n"; 
     2055                } 
     2056                if (tag != RC_LAST) 
     2057                        break; 
    20422058        case RC_USETEMPDIR: 
    20432059                if (tag != RC_LAST) 
     
    27922808                break; 
    27932809 
     2810        case RC_THESAURUSDIRPATH: 
     2811                str = _("This is the place where the files of the thesaurus library reside."); 
     2812                break; 
     2813 
    27942814        case RC_TEMPLATEPATH: 
    27952815                str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from."); 
  • lyx-devel/trunk/src/LyXRC.h

    r27531 r27572  
    150150                RC_TEX_ALLOWS_SPACES, 
    151151                RC_TEX_EXPECTS_WINDOWS_PATHS, 
     152                RC_THESAURUSDIRPATH, 
    152153                RC_UIFILE, 
    153154                RC_USELASTFILEPOS, 
     
    258259        /// 
    259260        std::string tempdir_path; 
     261        /// 
     262        std::string thesaurusdir_path; 
    260263        /// 
    261264        bool auto_region_delete; 
  • lyx-devel/trunk/src/Text3.cpp

    r27567 r27572  
    17991799                                selectWordWhenUnderCursor(cur, WHOLE_WORD); 
    18001800                                arg = cur.selectionAsString(false); 
     1801                                arg += " lang=" + from_ascii(cur.getFont().language()->lang()); 
    18011802                        } 
    18021803                } 
  • lyx-devel/trunk/src/Thesaurus.cpp

    r22097 r27572  
    55 * 
    66 * \author John Levon 
     7 * \author JÃŒrgen SpitzmÃŒller 
    78 * 
    89 * Full author contact details are available in file CREDITS. 
     
    1314#include "Thesaurus.h" 
    1415 
     16#include "support/debug.h" 
    1517#include "support/gettext.h" 
    16  
     18#include "LyXRC.h" 
     19 
     20#include "support/FileNameList.h" 
     21#include "support/filetools.h" 
    1722#include "support/lstrings.h" 
     23#include "support/os.h" 
     24#include "support/unicode.h" 
    1825 
    1926#include "frontends/alert.h" 
    2027 
    2128#include <algorithm> 
     29#include <cstring> 
    2230 
    2331using namespace std; 
     32using namespace lyx::support; 
     33using namespace lyx::support::os; 
    2434 
    2535namespace lyx { 
    2636 
     37#ifndef HAVE_LIBMYTHES 
    2738#ifdef HAVE_LIBAIKSAURUS 
    28 using support::bformat; 
    2939 
    3040 
    3141Thesaurus::Thesaurus() 
    32         : aik_(new Aiksaurus) 
     42        : thes_(new Aiksaurus) 
    3343{} 
    3444 
     
    3646Thesaurus::~Thesaurus() 
    3747{ 
    38         delete aik_; 
    39 } 
    40  
    41  
    42 Thesaurus::Meanings Thesaurus::lookup(docstring const & t
     48        delete thes_; 
     49} 
     50 
     51 
     52Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const &
    4353{ 
    4454        Meanings meanings; 
     
    5464        string const text = to_ascii(t); 
    5565 
    56         docstring error = from_ascii(aik_->error()); 
     66        docstring error = from_ascii(thes_->error()); 
    5767        if (!error.empty()) { 
    5868                static bool sent_error = false; 
     
    6575                return meanings; 
    6676        } 
    67         if (!aik_->find(text.c_str())) 
     77        if (!thes_->find(text.c_str())) 
    6878                return meanings; 
    6979 
     
    7585 
    7686        // correct, returns "" at the end 
    77         string ret = aik_->next(cur_meaning); 
     87        string ret = thes_->next(cur_meaning); 
    7888 
    7989        while (!ret.empty()) { 
    8090                if (cur_meaning != prev_meaning) { 
    8191                        meaning = from_ascii(ret); 
    82                         ret = aik_->next(cur_meaning); 
     92                        ret = thes_->next(cur_meaning); 
    8393                        prev_meaning = cur_meaning; 
    8494                } else { 
     
    8797                } 
    8898 
    89                 ret = aik_->next(cur_meaning); 
     99                ret = thes_->next(cur_meaning); 
    90100        } 
    91101 
     
    97107} 
    98108 
     109 
     110bool Thesaurus::thesaurusAvailable(docstring const & lang) const 
     111{ 
     112        // we support English only 
     113        return (prefixIs(lang, "en_")); 
     114} 
     115 
     116#endif // HAVE_LIBAIKSAURUS 
     117#endif // !HAVE_LIBMYTHES 
     118 
     119 
     120#ifdef HAVE_LIBMYTHES 
     121 
     122namespace { 
     123 
     124string const to_iconv_encoding(docstring const & s, string const & encoding) 
     125{ 
     126        std::vector<char> const encoded = 
     127                ucs4_to_eightbit(s.data(), s.length(), encoding); 
     128        return string(encoded.begin(), encoded.end()); 
     129} 
     130 
     131 
     132docstring const from_iconv_encoding(string const & s, string const & encoding) 
     133{ 
     134        std::vector<char_type> const ucs4 = 
     135                eightbit_to_ucs4(s.data(), s.length(), encoding); 
     136        return docstring(ucs4.begin(), ucs4.end()); 
     137} 
     138 
     139} // namespace anon 
     140 
     141 
     142Thesaurus::Thesaurus() 
     143{} 
     144 
     145 
     146Thesaurus::~Thesaurus() 
     147{ 
     148        for (Thesauri::iterator it = thes_.begin(); 
     149             it != thes_.end(); ++it) { 
     150                delete it->second; 
     151        } 
     152} 
     153 
     154 
     155bool Thesaurus::addThesaurus(docstring const & lang) 
     156{ 
     157        string const thes_path = external_path(lyxrc.thesaurusdir_path); 
     158        LYXERR(Debug::FILES, "thesaurus path: " << thes_path); 
     159        if (thes_path.empty()) 
     160                return false; 
     161 
     162        if (thesaurusAvailable(lang)) 
     163                return true; 
     164 
     165        FileNameList const idx_files = FileName(thes_path).dirList("idx"); 
     166        FileNameList const data_files = FileName(thes_path).dirList("dat"); 
     167        string idx; 
     168        string data; 
     169 
     170        for (FileNameList::const_iterator it = idx_files.begin(); 
     171             it != idx_files.end(); ++it) { 
     172                LYXERR(Debug::FILES, "found thesaurus idx file: " << it->onlyFileName()); 
     173                if (contains(it->onlyFileName(), to_ascii(lang))) { 
     174                        idx = it->absFilename(); 
     175                        LYXERR(Debug::FILES, "selected thesaurus idx file: " << idx); 
     176                        break; 
     177                        } 
     178                } 
     179 
     180        for (support::FileNameList::const_iterator it = data_files.begin(); 
     181             it != data_files.end(); ++it) { 
     182                LYXERR(Debug::FILES, "found thesaurus data file: " << it->onlyFileName()); 
     183                if (contains(it->onlyFileName(), to_ascii(lang))) { 
     184                        data = it->absFilename(); 
     185                        LYXERR(Debug::FILES, "selected thesaurus data file: " << data); 
     186                        break; 
     187                        } 
     188                } 
     189 
     190        if (idx.empty() || data.empty()) 
     191                return false; 
     192 
     193        char const * af = idx.c_str(); 
     194        char const * df = data.c_str(); 
     195        thes_[lang] = new MyThes(af, df); 
     196        return true; 
     197} 
     198 
     199 
     200bool Thesaurus::thesaurusAvailable(docstring const & lang) const 
     201{ 
     202        for (Thesauri::const_iterator it = thes_.begin(); 
     203             it != thes_.end(); ++it) { 
     204                if (it->first == lang) 
     205                        if (it->second) 
     206                                return true; 
     207        } 
     208 
     209        return false; 
     210} 
     211 
     212 
     213Thesaurus::Meanings Thesaurus::lookup(docstring const & t, docstring const & lang) 
     214{ 
     215        Meanings meanings; 
     216        MyThes * mythes = 0; 
     217 
     218        if (!addThesaurus(lang)) 
     219                return meanings; 
     220 
     221        for (Thesauri::const_iterator it = thes_.begin(); 
     222             it != thes_.end(); ++it) { 
     223                if (it->first == lang) { 
     224                        mythes = it->second; 
     225                        break; 
     226                } 
     227        } 
     228 
     229        if (!mythes) 
     230                return meanings; 
     231 
     232        string const encoding = mythes->get_th_encoding(); 
     233         
     234        mentry * pmean; 
     235        string const text = to_iconv_encoding(support::lowercase(t), encoding); 
     236        int len = strlen(text.c_str()); 
     237        int count = mythes->Lookup(text.c_str(), len, &pmean); 
     238        if (!count) 
     239                return meanings; 
     240 
     241        // don't change value of pmean or count 
     242        // they are needed for the CleanUpAfterLookup routine 
     243        mentry * pm = pmean; 
     244        docstring meaning; 
     245        docstring ret; 
     246        for (int i = 0; i < count; i++) { 
     247                meaning = from_iconv_encoding(string(pm->defn), encoding); 
     248                // remove silly item 
     249                if (support::prefixIs(meaning, '-')) 
     250                        meaning = support::ltrim(meaning, "- "); 
     251                for (int j = 0; j < pm->count; j++) { 
     252                        ret = from_iconv_encoding(string(pm->psyns[j]), encoding); 
     253                } 
     254        meanings[meaning].push_back(ret); 
     255        pm++; 
     256        } 
     257        // now clean up all allocated memory 
     258        mythes->CleanUpAfterLookup(&pmean, count); 
     259 
     260        for (Meanings::iterator it = meanings.begin(); 
     261             it != meanings.end(); ++it) 
     262                sort(it->second.begin(), it->second.end()); 
     263 
     264        return meanings; 
     265} 
     266 
    99267#else 
    100268 
     
    114282} 
    115283 
    116 #endif // HAVE_LIBAIKSAURU
     284#endif // HAVE_LIBMYTHE
    117285 
    118286// Global instance 
  • lyx-devel/trunk/src/Thesaurus.h

    r18539 r27572  
    66 * 
    77 * \author John Levon 
     8 * \author JÃŒrgen SpitzmÃŒller 
    89 * 
    910 * Full author contact details are available in file CREDITS. 
     
    1718#include <vector> 
    1819#include <map> 
     20#include <string> 
    1921 
     22#ifdef HAVE_LIBMYTHES 
     23#include MYTHES_H_LOCATION 
     24#else 
    2025#ifdef HAVE_LIBAIKSAURUS 
    2126#include AIKSAURUS_H_LOCATION 
    22 #endif 
     27#endif // HAVE_LIBAIKSAURUS 
     28#endif // !HAVE_LIBMYTHES 
    2329 
    2430namespace lyx { 
     
    4046         * look up some text in the thesaurus 
    4147         */ 
    42         Meanings lookup(docstring const & text); 
     48        Meanings lookup(docstring const & text, docstring const & lang); 
     49        /// check if a thesaurus for a given language \p lang is available 
     50        bool thesaurusAvailable(docstring const & lang) const; 
    4351 
    4452private: 
     53#ifdef HAVE_LIBMYTHES 
     54        /// add a thesaurus to the list 
     55        bool addThesaurus(docstring const & lang); 
     56 
     57        typedef std::map<docstring, MyThes *> Thesauri; 
     58        /// the thesauri 
     59        Thesauri thes_; 
     60#else 
    4561#ifdef HAVE_LIBAIKSAURUS 
    46         Aiksaurus * aik_; 
    47 #endif 
     62        Aiksaurus * thes_; 
     63#endif // HAVE_LIBAIKSAURUS 
     64#endif // !HAVE_LIBMYTHES 
    4865}; 
    4966 
  • lyx-devel/trunk/src/frontends/qt4/GuiPrefs.cpp

    r27531 r27572  
    927927        connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir())); 
    928928        connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe())); 
     929        connect(thesaurusDirPB, SIGNAL(clicked()), this, SLOT(select_thesaurusdir())); 
    929930        connect(workingDirED, SIGNAL(textChanged(QString)), 
    930931                this, SIGNAL(changed())); 
     
    938939                this, SIGNAL(changed())); 
    939940        connect(lyxserverDirED, SIGNAL(textChanged(QString)), 
     941                this, SIGNAL(changed())); 
     942        connect(thesaurusDirED, SIGNAL(textChanged(QString)), 
    940943                this, SIGNAL(changed())); 
    941944        connect(pathPrefixED, SIGNAL(textChanged(QString)), 
     
    951954        rc.backupdir_path = internal_path(fromqstr(backupDirED->text())); 
    952955        rc.tempdir_path = internal_path(fromqstr(tempDirED->text())); 
     956        rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text())); 
    953957        rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text())); 
    954958        // FIXME: should be a checkbox only 
     
    964968        backupDirED->setText(toqstr(external_path(rc.backupdir_path))); 
    965969        tempDirED->setText(toqstr(external_path(rc.tempdir_path))); 
     970        thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path))); 
    966971        pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix))); 
    967972        // FIXME: should be a checkbox only 
     
    10121017        if (!file.isEmpty()) 
    10131018                workingDirED->setText(file); 
     1019} 
     1020 
     1021 
     1022void PrefPaths::select_thesaurusdir() 
     1023{ 
     1024        QString file = browseDir(internalPath(thesaurusDirED->text()), 
     1025                qt_("Set the path to the thesaurus dictionaries")); 
     1026        if (!file.isEmpty()) 
     1027                thesaurusDirED->setText(file); 
    10141028} 
    10151029 
  • lyx-devel/trunk/src/frontends/qt4/GuiPrefs.h

    r26503 r27572  
    284284        void select_backupdir(); 
    285285        void select_workingdir(); 
     286        void select_thesaurusdir(); 
    286287        void select_lyxpipe(); 
    287288 
  • lyx-devel/trunk/src/frontends/qt4/GuiThesaurus.cpp

    r27420 r27572  
    55 * 
    66 * \author John Levon 
     7 * \author JÃŒrgen SpitzmÃŒller 
    78 * 
    89 * Full author contact details are available in file CREDITS. 
     
    1213 
    1314#include "GuiThesaurus.h" 
     15#include "GuiApplication.h" 
    1416 
    1517#include "qt_helpers.h" 
    1618 
     19#include "Buffer.h" 
     20#include "BufferParams.h" 
     21#include "BufferView.h" 
    1722#include "FuncRequest.h" 
     23#include "Language.h" 
    1824#include "lyxfind.h" 
    1925 
    2026#include "support/debug.h" 
    2127#include "support/gettext.h" 
    22  
     28#include "support/lstrings.h" 
     29 
     30#include <QAbstractItemModel> 
    2331#include <QHeaderView> 
    2432#include <QLineEdit> 
     
    2836 
    2937 
     38using namespace lyx::support; 
    3039using namespace std; 
    3140 
     
    4756        connect(replaceED, SIGNAL(textChanged(QString)), 
    4857                this, SLOT(change_adaptor())); 
    49         connect(entryED, SIGNAL(returnPressed()), 
     58        connect(entryCO, SIGNAL(editTextChanged(const QString &)), 
     59                this, SLOT(entryChanged())); 
     60        connect(entryCO, SIGNAL(activated(int)), 
     61                this, SLOT(entryChanged())); 
     62        connect(lookupPB, SIGNAL(clicked()), 
    5063                this, SLOT(entryChanged())); 
    5164        connect(replacePB, SIGNAL(clicked()), 
    5265                this, SLOT(replaceClicked())); 
     66        connect(languageCO, SIGNAL(activated(int)), 
     67                this, SLOT(entryChanged())); 
    5368        connect(meaningsTV, SIGNAL(itemClicked(QTreeWidgetItem *, int)), 
    5469                this, SLOT(itemClicked(QTreeWidgetItem *, int))); 
    5570        connect(meaningsTV, SIGNAL(itemSelectionChanged()), 
    5671                this, SLOT(selectionChanged())); 
    57         connect(meaningsTV, SIGNAL(itemActivated(QTreeWidgetItem *, int)), 
     72        connect(meaningsTV, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), 
    5873                this, SLOT(selectionClicked(QTreeWidgetItem *, int))); 
     74 
     75        // language 
     76        QAbstractItemModel * language_model = guiApp->languageModel(); 
     77        // FIXME: it would be nice if sorting was enabled/disabled via a checkbox. 
     78        language_model->sort(0); 
     79        languageCO->setModel(language_model); 
    5980 
    6081        bc().setCancel(closePB); 
     
    84105                return; 
    85106 
    86         replaceED->setText(meaningsTV->currentItem()->text(col)); 
     107        QString item = meaningsTV->currentItem()->text(col); 
     108        // cut out the classification in brackets 
     109        // (as in "hominid (generic term)") 
     110        // FIXME: not ideal yet. We need to cut off classifications 
     111        // at the beginning as well  
     112        // (as in "(noun) man" and "(noun) male (generic term)") 
     113        QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); 
     114        int pos = re.indexIn(item); 
     115        if (pos > -1) 
     116                item = re.cap(1).trimmed(); 
     117        replaceED->setText(item); 
    87118        replacePB->setEnabled(true); 
    88119        changed(); 
     
    98129void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col) 
    99130{ 
    100         entryED->setText(item->text(col)); 
     131        QString str = item->text(col); 
     132        // cut out the classification in brackets 
     133        // (as in "hominid (generic term)") 
     134        // FIXME: not ideal yet. We need to cut off classifications 
     135        // at the beginning as well  
     136        // (as in "(noun) man" and "(noun) male (generic term)") 
     137        QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); 
     138        int pos = re.indexIn(str); 
     139        if (pos > -1) 
     140                str = re.cap(1).trimmed(); 
     141        entryCO->insertItem(0, str); 
     142        entryCO->setCurrentIndex(0); 
     143 
    101144        selectionChanged(); 
    102145        updateLists(); 
     
    109152        meaningsTV->setUpdatesEnabled(false); 
    110153 
    111         Thesaurus::Meanings meanings = getMeanings(qstring_to_ucs4(entryED->text())); 
     154        QString const lang = languageCO->itemData( 
     155                languageCO->currentIndex()).toString(); 
     156        docstring const lang_code = 
     157                from_ascii(lyx::languages.getLanguage(fromqstr(lang))->code()); 
     158 
     159        Thesaurus::Meanings meanings = 
     160                getMeanings(qstring_to_ucs4(entryCO->currentText()), lang_code); 
    112161 
    113162        for (Thesaurus::Meanings::const_iterator cit = meanings.begin(); 
     
    121170                                i2->setText(0, toqstr(*cit2)); 
    122171                        } 
     172                meaningsTV->setEnabled(true); 
     173                lookupPB->setEnabled(true); 
     174                replaceED->setEnabled(true); 
     175                replacePB->setEnabled(true); 
     176        } 
     177 
     178        if (meanings.empty()) { 
     179                if (!thesaurus.thesaurusAvailable(lang_code)) { 
     180                        QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV); 
     181                        i->setText(0, qt_("No thesaurus available for this language!")); 
     182                        meaningsTV->setEnabled(false); 
     183                        lookupPB->setEnabled(false); 
     184                        replaceED->setEnabled(false); 
     185                        replacePB->setEnabled(false); 
     186                } 
    123187        } 
    124188 
     
    130194void GuiThesaurus::updateContents() 
    131195{ 
    132         entryED->setText(toqstr(text_)); 
     196        entryCO->clear(); 
     197        entryCO->addItem(toqstr(text_)); 
     198        entryCO->setCurrentIndex(0); 
    133199        replaceED->setText(""); 
     200        int const pos = languageCO->findData(toqstr(lang_)); 
     201        if (pos != -1) 
     202                languageCO->setCurrentIndex(pos); 
    134203        updateLists(); 
    135204} 
     
    144213bool GuiThesaurus::initialiseParams(string const & data) 
    145214{ 
    146         text_ = from_utf8(data); 
     215        string arg; 
     216        string const lang = rsplit(data, arg, ' '); 
     217        if (prefixIs(lang, "lang=")) { 
     218                lang_ = from_utf8(split(lang, '=')); 
     219                text_ = from_utf8(arg); 
     220        } else { 
     221                text_ = from_utf8(data); 
     222                if (bufferview()) 
     223                        lang_ = from_ascii( 
     224                                bufferview()->buffer().params().language->lang()); 
     225        } 
    147226        return true; 
    148227} 
     
    152231{ 
    153232        text_.erase(); 
     233        lang_.erase(); 
    154234} 
    155235 
     
    171251 
    172252 
    173 Thesaurus::Meanings const & GuiThesaurus::getMeanings(docstring const & str) 
     253Thesaurus::Meanings const & GuiThesaurus::getMeanings(docstring const & str, 
     254        docstring const & lang) 
    174255{ 
    175256        if (str != laststr_) 
    176                 meanings_ = thesaurus.lookup(str); 
     257                meanings_ = thesaurus.lookup(str, lang); 
    177258        return meanings_; 
    178259} 
  • lyx-devel/trunk/src/frontends/qt4/GuiThesaurus.h

    r23045 r27572  
    5555 
    5656        /// get meanings 
    57         Thesaurus::Meanings const & getMeanings(docstring const & str); 
     57        Thesaurus::Meanings const & getMeanings(docstring const & str, 
     58                docstring const & lang); 
    5859 
    5960private: 
     
    6768        docstring text_; 
    6869 
     70        /// language 
     71        docstring lang_; 
     72 
    6973        /// not needed. 
    7074        void apply() {} 
  • lyx-devel/trunk/src/frontends/qt4/ui/PrefPathsUi.ui

    r24389 r27572  
    77    <y>0</y> 
    88    <width>347</width> 
    9     <height>259</height> 
     9    <height>311</height> 
    1010   </rect> 
    1111  </property> 
     
    1414  </property> 
    1515  <layout class="QGridLayout" > 
    16    <item row="0" column="0" > 
    17     <widget class="QLabel" name="workingDirLA" > 
    18      <property name="text" > 
    19       <string>&amp;Working directory:</string> 
    20      </property> 
    21      <property name="buddy" > 
    22       <cstring>workingDirED</cstring> 
    23      </property> 
    24     </widget> 
    25    </item> 
    26    <item row="0" column="1" > 
    27     <widget class="QLineEdit" name="workingDirED" /> 
    28    </item> 
    29    <item row="0" column="2" > 
    30     <widget class="QPushButton" name="workingDirPB" > 
    31      <property name="text" > 
    32       <string>Browse...</string> 
    33      </property> 
    34      <property name="autoDefault" > 
    35       <bool>false</bool> 
    36      </property> 
    37     </widget> 
    38    </item> 
    39    <item row="1" column="0" > 
    40     <widget class="QLabel" name="templateDirLA" > 
    41      <property name="text" > 
    42       <string>&amp;Document templates:</string> 
    43      </property> 
    44      <property name="buddy" > 
    45       <cstring>templateDirED</cstring> 
    46      </property> 
    47     </widget> 
    48    </item> 
    49    <item row="1" column="1" > 
    50     <widget class="QLineEdit" name="templateDirED" /> 
    51    </item> 
    52    <item row="1" column="2" > 
    53     <widget class="QPushButton" name="templateDirPB" > 
    54      <property name="text" > 
    55       <string>Browse...</string> 
    56      </property> 
    57      <property name="autoDefault" > 
    58       <bool>false</bool> 
    59      </property> 
    60     </widget> 
    61    </item> 
    62    <item row="2" column="0" > 
    63     <widget class="QLabel" name="exampleDirLA" > 
    64      <property name="text" > 
    65       <string>&amp;Example files:</string> 
    66      </property> 
    67      <property name="buddy" > 
    68       <cstring>templateDirED</cstring> 
    69      </property> 
    70     </widget> 
    71    </item> 
    72    <item row="2" column="1" > 
    73     <widget class="QLineEdit" name="exampleDirED" /> 
    74    </item> 
    75    <item row="2" column="2" > 
    76     <widget class="QPushButton" name="exampleDirPB" > 
    77      <property name="text" > 
    78       <string>Browse...</string> 
    79      </property> 
    80      <property name="autoDefault" > 
    81       <bool>false</bool> 
    82      </property> 
    83     </widget> 
    84    </item> 
    85    <item row="3" column="0" > 
    86     <widget class="QLabel" name="backupDirLA" > 
    87      <property name="text" > 
    88       <string>&amp;Backup directory:</string> 
    89      </property> 
    90      <property name="buddy" > 
    91       <cstring>backupDirED</cstring> 
    92      </property> 
    93     </widget> 
    94    </item> 
    95    <item row="3" column="1" > 
    96     <widget class="QLineEdit" name="backupDirED" /> 
    97    </item> 
    98    <item row="3" column="2" > 
    99     <widget class="QPushButton" name="backupDirPB" > 
    100      <property name="text" > 
    101       <string>Browse...</string> 
    102      </property> 
    103      <property name="autoDefault" > 
    104       <bool>false</bool> 
    105      </property> 
    106     </widget> 
    107    </item> 
    108    <item row="4" column="0" > 
    109     <widget class="QLabel" name="lyxserverDirLA" > 
    110      <property name="text" > 
    111       <string>Ly&amp;XServer pipe:</string> 
    112      </property> 
    113      <property name="buddy" > 
    114       <cstring>lyxserverDirED</cstring> 
    115      </property> 
    116     </widget> 
    117    </item> 
    118    <item row="4" column="1" > 
    119     <widget class="QLineEdit" name="lyxserverDirED" /> 
    120    </item> 
    121    <item row="4" column="2" > 
    122     <widget class="QPushButton" name="lyxserverDirPB" > 
    123      <property name="text" > 
    124       <string>Browse...</string> 
    125      </property> 
    126      <property name="autoDefault" > 
    127       <bool>false</bool> 
    128      </property> 
    129     </widget> 
    130    </item> 
    131    <item row="5" column="0" > 
    132     <widget class="QLabel" name="tempDirLA" > 
    133      <property name="text" > 
    134       <string>&amp;Temporary directory:</string> 
    135      </property> 
    136      <property name="buddy" > 
    137       <cstring>tempDirED</cstring> 
    138      </property> 
    139     </widget> 
    140    </item> 
    141    <item row="5" column="1" > 
    142     <widget class="QLineEdit" name="tempDirED" /> 
    143    </item> 
    144    <item row="5" column="2" > 
    145     <widget class="QPushButton" name="tempDirPB" > 
    146      <property name="text" > 
    147       <string>Browse...</string> 
    148      </property> 
    149      <property name="autoDefault" > 
    150       <bool>false</bool> 
    151      </property> 
    152     </widget> 
    153    </item> 
    154    <item row="6" column="0" > 
    155     <widget class="QLabel" name="pathPrefixLA" > 
    156      <property name="text" > 
    157       <string>&amp;PATH prefix:</string> 
    158      </property> 
    159      <property name="buddy" > 
    160       <cstring>pathPrefixED</cstring> 
    161      </property> 
    162     </widget> 
    163    </item> 
    164    <item row="6" column="1" colspan="2" > 
    165     <widget class="QLineEdit" name="pathPrefixED" /> 
    166    </item> 
    167    <item row="7" column="0" colspan="3" > 
     16   <property name="margin" > 
     17    <number>9</number> 
     18   </property> 
     19   <property name="spacing" > 
     20    <number>6</number> 
     21   </property> 
     22   <item row="8" column="0" colspan="3" > 
    16823    <spacer> 
    16924     <property name="orientation" > 
     
    17530     <property name="sizeHint" > 
    17631      <size> 
    177        <width>20</width> 
    178        <height>20</height> 
     32       <width>329</width> 
     33       <height>16</height> 
    17934      </size> 
    18035     </property> 
    18136    </spacer> 
     37   </item> 
     38   <item row="7" column="0" > 
     39    <widget class="QLabel" name="pathPrefixLA" > 
     40     <property name="text" > 
     41      <string>&amp;PATH prefix:</string> 
     42     </property> 
     43     <property name="buddy" > 
     44      <cstring>pathPrefixED</cstring> 
     45     </property> 
     46    </widget> 
     47   </item> 
     48   <item row="7" column="1" colspan="2" > 
     49    <widget class="QLineEdit" name="pathPrefixED" /> 
     50   </item> 
     51   <item row="6" column="2" > 
     52    <widget class="QPushButton" name="thesaurusDirPB" > 
     53     <property name="text" > 
     54      <string>Browse...</string> 
     55     </property> 
     56     <property name="autoDefault" > 
     57      <bool>false</bool> 
     58     </property> 
     59    </widget> 
     60   </item> 
     61   <item row="6" column="0" > 
     62    <widget class="QLabel" name="thesaurusDirLA" > 
     63     <property name="text" > 
     64      <string>T&amp;hesaurus dictionaries:</string> 
     65     </property> 
     66     <property name="buddy" > 
     67      <cstring>thesaurusDirED</cstring> 
     68     </property> 
     69    </widget> 
     70   </item> 
     71   <item row="6" column="1" > 
     72    <widget class="QLineEdit" name="thesaurusDirED" /> 
     73   </item> 
     74   <item row="5" column="2" > 
     75    <widget class="QPushButton" name="tempDirPB" > 
     76     <property name="text" > 
     77      <string>Browse...</string> 
     78     </property> 
     79     <property name="autoDefault" > 
     80      <bool>false</bool> 
     81     </property> 
     82    </widget> 
     83   </item> 
     84   <item row="5" column="1" > 
     85    <widget class="QLineEdit" name="tempDirED" /> 
     86   </item> 
     87   <item row="5" column="0" > 
     88    <widget class="QLabel" name="tempDirLA" > 
     89     <property name="text" > 
     90      <string>&amp;Temporary directory:</string> 
     91     </property> 
     92     <property name="buddy" > 
     93      <cstring>tempDirED</cstring> 
     94     </property> 
     95    </widget> 
     96   </item> 
     97   <item row="4" column="2" > 
     98    <widget class="QPushButton" name="lyxserverDirPB" > 
     99     <property name="text" > 
     100      <string>Browse...</string> 
     101     </property> 
     102     <property name="autoDefault" > 
     103      <bool>false</bool> 
     104     </property> 
     105    </widget> 
     106   </item> 
     107   <item row="4" column="1" > 
     108    <widget class="QLineEdit" name="lyxserverDirED" /> 
     109   </item> 
     110   <item row="4" column="0" > 
     111    <widget class="QLabel" name="lyxserverDirLA" > 
     112     <property name="text" > 
     113      <string>Ly&amp;XSe