diff --git a/src/qtgui/rclmain.ui b/src/qtgui/rclmain.ui
index 0c77eed1..f0bb6dbc 100644
--- a/src/qtgui/rclmain.ui
+++ b/src/qtgui/rclmain.ui
@@ -82,18 +82,19 @@
- -
+
-
- -
+
-
+
- -
+
-
diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp
index e46d1043..361c9bba2 100644
--- a/src/qtgui/rclmain_w.cpp
+++ b/src/qtgui/rclmain_w.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.36 2007-07-20 14:32:55 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.37 2007-08-01 07:55:03 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -107,10 +107,42 @@ void RclMain::init()
resList->setFont(nfont);
}
+ // Stemming language menu
+ m_idNoStem = preferencesMenu->insertItem(tr("(no stemming)"));
+ m_stemLangToId[tr("(no stemming)")] = m_idNoStem;
+
+ LOGDEB(("idNoStem: %d\n", m_idNoStem));
+ // Can't get the stemming languages from the db at this stage as
+ // db not open yet (the case where it does not even exist makes
+ // things complicated). So get the languages from the config
+ // instead
+ string slangs;
+ list langs;
+ if (rclconfig->getConfParam("indexstemminglanguages", slangs)) {
+ stringToStrings(slangs, langs);
+ } else {
+ QMessageBox::warning(0, "Recoll",
+ tr("error retrieving stemming languages"));
+ }
+ int curid = m_idNoStem, id; // Menu ids are negative integers
+ for (list::const_iterator it = langs.begin();
+ it != langs.end(); it++) {
+ QString qlang = QString::fromAscii(it->c_str(), it->length());
+ id = preferencesMenu->insertItem(qlang);
+ m_stemLangToId[qlang] = id;
+ if (prefs.queryStemLang == qlang) {
+ curid = id;
+ }
+ }
+ preferencesMenu->setItemChecked(curid, true);
+
// Connections
connect(sSearch, SIGNAL(startSearch(RefCntr)),
this, SLOT(startSearch(RefCntr)));
-
+ connect(preferencesMenu, SIGNAL(activated(int)),
+ this, SLOT(setStemLang(int)));
+ connect(preferencesMenu, SIGNAL(aboutToShow()),
+ this, SLOT(adjustPrefsMenu()));
// signals and slots connections
connect(sSearch, SIGNAL(clearSearch()),
this, SLOT(resetSearch()));
@@ -190,6 +222,68 @@ void RclMain::init()
}
}
+void RclMain::setStemLang(int id)
+{
+ LOGDEB(("RclMain::setStemLang(%d)\n", id));
+ // Check that the menu entry is for a stemming language change
+ // (might also be "show prefs" etc.
+ bool isLangId = false;
+ for (map::const_iterator it = m_stemLangToId.begin();
+ it != m_stemLangToId.end(); it++) {
+ if (id == it->second)
+ isLangId = true;
+ }
+ if (!isLangId)
+ return;
+
+ // Set the "checked" item state for lang entries
+ for (map::const_iterator it = m_stemLangToId.begin();
+ it != m_stemLangToId.end(); it++) {
+ preferencesMenu->setItemChecked(it->second, false);
+ }
+ preferencesMenu->setItemChecked(id, true);
+
+ // Retrieve language value (also handle special cases), set prefs,
+ // notify that we changed
+ QString lang;
+ if (id == m_idNoStem) {
+ lang = "";
+ } else {
+ lang = preferencesMenu->text(id);
+ }
+ prefs.queryStemLang = lang;
+ LOGDEB(("RclMain::setStemLang(%d): lang [%s]\n",
+ id, (const char *)prefs.queryStemLang.ascii()));
+ rwSettings(true);
+ emit stemLangChanged(lang);
+}
+
+// Set the checked stemming language item before showing the prefs menu
+void RclMain::setStemLang(const QString& lang)
+{
+ LOGDEB(("RclMain::setStemLang(%s)\n", (const char *)lang.ascii()));
+ int id;
+ if (lang == "") {
+ id = m_idNoStem;
+ } else {
+ map::iterator it = m_stemLangToId.find(lang);
+ if (it == m_stemLangToId.end())
+ return;
+ id = it->second;
+ }
+ for (map::const_iterator it = m_stemLangToId.begin();
+ it != m_stemLangToId.end(); it++) {
+ preferencesMenu->setItemChecked(it->second, false);
+ }
+ preferencesMenu->setItemChecked(id, true);
+}
+
+// Prefs menu about to show
+void RclMain::adjustPrefsMenu()
+{
+ setStemLang(prefs.queryStemLang);
+}
+
void RclMain::closeEvent( QCloseEvent * )
{
fileExit();
@@ -393,6 +487,8 @@ void RclMain::showUIPrefs()
if (uiprefs == 0) {
uiprefs = new UIPrefsDialog(0);
connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs()));
+ connect(this, SIGNAL(stemLangChanged(const QString&)),
+ uiprefs, SLOT(setStemLang(const QString&)));
} else {
// Close and reopen, in hope that makes us visible...
uiprefs->close();
diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h
index afb92901..2bf40293 100644
--- a/src/qtgui/rclmain_w.h
+++ b/src/qtgui/rclmain_w.h
@@ -67,7 +67,6 @@ public:
}
~RclMain() {}
-
public slots:
virtual bool close();
virtual void fileExit();
@@ -99,6 +98,14 @@ public slots:
virtual void previewExposed(Preview *, int sid, int docnum);
virtual void resetSearch();
virtual void eraseDocHistory();
+ // Callback for setting the stemming language through the prefs menu
+ virtual void setStemLang(int id);
+ // Prefs menu about to show, set the checked lang entry
+ virtual void adjustPrefsMenu();
+
+signals:
+ void stemLangChanged(const QString& lang);
+
protected:
virtual void closeEvent( QCloseEvent * );
@@ -117,9 +124,13 @@ private:
// Serial number of current search for this process.
// Used to match to preview windows
int m_searchId;
+ map m_stemLangToId;
+ int m_idNoStem;
+
virtual void init();
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
bool next);
+ virtual void setStemLang(const QString& lang);
};
#endif // RCLMAIN_W_H
diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp
index e7423423..731896f7 100644
--- a/src/qtgui/uiprefs_w.cpp
+++ b/src/qtgui/uiprefs_w.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.19 2007-07-12 10:13:37 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.20 2007-08-01 07:55:03 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -233,6 +233,22 @@ void UIPrefsDialog::reject()
QDialog::reject();
}
+void UIPrefsDialog::setStemLang(const QString& lang)
+{
+ int cur = 0;
+ if (lang == "") {
+ cur = 0;
+ } else {
+ for (int i = 1; i < stemLangCMB->count(); i++) {
+ if (lang == stemLangCMB->text(i)) {
+ cur = i;
+ break;
+ }
+ }
+ }
+ stemLangCMB->setCurrentItem(cur);
+}
+
void UIPrefsDialog::showFontDialog()
{
bool ok;
diff --git a/src/qtgui/uiprefs_w.h b/src/qtgui/uiprefs_w.h
index 91340e1d..a34dc835 100644
--- a/src/qtgui/uiprefs_w.h
+++ b/src/qtgui/uiprefs_w.h
@@ -1,4 +1,4 @@
-/* @(#$Id: uiprefs_w.h,v 1.8 2007-02-08 09:03:29 dockes Exp $ (C) 2006 J.F.Dockes */
+/* @(#$Id: uiprefs_w.h,v 1.9 2007-08-01 07:55:03 dockes Exp $ (C) 2006 J.F.Dockes */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
*/
#ifndef _UIPREFS_W_H_INCLUDED_
#define _UIPREFS_W_H_INCLUDED_
-/* @(#$Id: uiprefs_w.h,v 1.8 2007-02-08 09:03:29 dockes Exp $ (C) 2005 J.F.Dockes */
+/* @(#$Id: uiprefs_w.h,v 1.9 2007-08-01 07:55:03 dockes Exp $ (C) 2005 J.F.Dockes */
#include
#include
@@ -75,6 +75,7 @@ public slots:
virtual void togExtraDbPB_clicked();
virtual void actAllExtraDbPB_clicked();
virtual void unacAllExtraDbPB_clicked();
+ virtual void setStemLang(const QString& lang);
signals:
void uiprefsDone();