X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiThesaurus.cpp;h=e92946b8c330bb547a367f914025e84557a6ca78;hb=5c59e8c7cb3a804d403061e76a34c0378320b9b0;hp=083ed2eac0d7d07102a1475d2bf1bd3ea7a41add;hpb=df4814e0267789ce84802d69aa6725395517ca9b;p=lyx.git diff --git a/src/frontends/qt4/GuiThesaurus.cpp b/src/frontends/qt4/GuiThesaurus.cpp index 083ed2eac0..e92946b8c3 100644 --- a/src/frontends/qt4/GuiThesaurus.cpp +++ b/src/frontends/qt4/GuiThesaurus.cpp @@ -77,6 +77,7 @@ GuiThesaurus::GuiThesaurus(GuiView & lv) // FIXME: it would be nice if sorting was enabled/disabled via a checkbox. language_model->sort(0); languageCO->setModel(language_model); + languageCO->setModelColumn(2); bc().setCancel(closePB); bc().setApply(replacePB); @@ -105,15 +106,18 @@ void GuiThesaurus::selectionChanged() return; 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)") + // cut out the classification in brackets: + // "hominid (generic term)" -> "hominid" QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); + // This is for items with classifications at the beginning: + // "(noun) man" -> "man"; "(noun) male (generic term)" -> "male" + QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$"); int pos = re.indexIn(item); if (pos > -1) item = re.cap(1).trimmed(); + pos = rex.indexIn(item); + if (pos > -1) + item = rex.cap(2).trimmed(); replaceED->setText(item); replacePB->setEnabled(true); changed(); @@ -129,15 +133,18 @@ void GuiThesaurus::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/) void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int 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)") + // cut out the classification in brackets: + // "hominid (generic term)" -> "hominid" QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); + // This is for items with classifications at the beginning: + // "(noun) man" -> "man"; "(noun) male (generic term)" -> "male" + QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$"); int pos = re.indexIn(str); if (pos > -1) str = re.cap(1).trimmed(); + pos = rex.indexIn(str); + if (pos > -1) + str = rex.cap(2).trimmed(); entryCO->insertItem(0, str); entryCO->setCurrentIndex(0); @@ -241,7 +248,7 @@ void GuiThesaurus::replace(docstring const & newstr) * deletion/change ! */ docstring const data = - replace2string(text_, newstr, + replace2string(newstr, text_, true, // case sensitive true, // match word false, // all words