From 90a4256e033b16432cfd405fd1762e5315b71895 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 17 Nov 2008 07:15:44 +0000 Subject: [PATCH] * GuiThesaurus.cpp: - entry parsing should work for all cases now. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27602 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiThesaurus.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/frontends/qt4/GuiThesaurus.cpp b/src/frontends/qt4/GuiThesaurus.cpp index 083ed2eac0..413be69e53 100644 --- a/src/frontends/qt4/GuiThesaurus.cpp +++ b/src/frontends/qt4/GuiThesaurus.cpp @@ -105,15 +105,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 +132,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); -- 2.39.2