From 89d287dbe7cb3b77e82d99307dce9b11281660b4 Mon Sep 17 00:00:00 2001 From: dockes Date: Thu, 15 Dec 2005 14:39:58 +0000 Subject: [PATCH] user prefs tweaks. Allow switching stemlang from ui --- src/qtgui/main.cpp | 97 ++++++++++++++--------------------- src/qtgui/recoll.h | 5 +- src/qtgui/recollmain.ui | 12 ++--- src/qtgui/recollmain.ui.h | 23 +++++---- src/sampleconf/recoll.conf.in | 41 +++++++-------- 5 files changed, 78 insertions(+), 100 deletions(-) diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 6c23958c..f97a3418 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: main.cpp,v 1.25 2005-12-15 13:41:10 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: main.cpp,v 1.26 2005-12-15 14:39:57 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -37,6 +37,8 @@ int recollNeedsExit; string tmpdir; string iconsdir; RclDHistory *history; +static string dbdir; +static RecollMain *mainWindow; ///////////////////////// // Global variables for user preferences. These are set in the user preference @@ -49,8 +51,39 @@ QString prefs_queryStemLang; int prefs_mainwidth; int prefs_mainheight; bool prefs_ssall; - -static string dbdir; + +#define SETTING_RW(var, nm, tp, def) \ + if (writing) { \ + settings.writeEntry(nm , var); \ + } else { \ + var = settings.read##tp##Entry(nm, def); \ + } + +static void rwSettings(bool writing) +{ + if (writing) { + if (!mainWindow) + return; + prefs_mainwidth = mainWindow->width(); + prefs_mainheight = mainWindow->height(); + prefs_ssall = mainWindow->allTermsCB->isChecked(); + } + + QSettings settings; + settings.setPath("Recoll.org", "Recoll"); + + SETTING_RW(prefs_mainwidth, "/Recoll/geometry/width", Num, 590); + SETTING_RW(prefs_mainheight, "/Recoll/geometry/height", Num, 810); + SETTING_RW(prefs_ssall, "/Recoll/prefs/simpleSearchAll", Bool, false); + SETTING_RW(prefs_showicons, "/Recoll/prefs/reslist/showicons", Bool, true); + SETTING_RW(prefs_respagesize, "/Recoll/prefs/reslist/pagelen", Num, 8); + SETTING_RW(prefs_reslistfontfamily, "/Recoll/prefs/reslist/fontFamily", , + ""); + SETTING_RW(prefs_reslistfontsize, "/Recoll/prefs/reslist/fontSize", Num, + 0); + SETTING_RW(prefs_queryStemLang, "/Recoll/prefs/query/stemLang", , + "english"); +} bool maybeOpenDb(string &reason) { @@ -66,62 +99,9 @@ bool maybeOpenDb(string &reason) return true; } -RecollMain *mainWindow; - -#define SETTING_RW(var, nm, tp, def) { \ - if (writing) { \ - settings.writeEntry(#nm , var); \ - } else { \ - var = settings.read##tp(#nm, def) \ -} - -static void saveSettings() -{ - if (!mainWindow) - return; - prefs_mainwidth = mainWindow->width(); - prefs_mainheight = mainWindow->height(); - prefs_ssall = mainWindow->allTermsCB->isChecked(); - - QSettings settings; - settings.setPath("Recoll.org", "Recoll"); - - settings.writeEntry("/Recoll/geometry/width", prefs_mainwidth); - settings.writeEntry("/Recoll/geometry/height", prefs_mainheight); - settings.writeEntry("/Recoll/prefs/simpleSearchAll", prefs_ssall); - settings.writeEntry("/Recoll/prefs/reslist/showicons", prefs_showicons); - settings.writeEntry("/Recoll/prefs/reslist/pagelen", prefs_respagesize); - settings.writeEntry("/Recoll/prefs/reslist/fontFamily", - prefs_reslistfontfamily); - settings.writeEntry("/Recoll/prefs/reslist/fontSize", - prefs_reslistfontsize);; - settings.writeEntry("/Recoll/prefs/query/stemLang", prefs_queryStemLang);; -} - -static void readSettings() -{ - // Restore some settings from previous session - QSettings settings; - settings.setPath("Recoll.org", "Recoll"); - - prefs_mainwidth = settings.readNumEntry("/Recoll/geometry/width", 590); - prefs_mainheight = settings.readNumEntry("/Recoll/geometry/height", 810); - prefs_ssall = settings.readBoolEntry("/Recoll/prefs/simpleSearchAll", 0); - prefs_showicons = - settings.readBoolEntry("/Recoll/prefs/reslist/showicons", true); - prefs_respagesize = - settings.readNumEntry("/Recoll/prefs/reslist/pagelen", 8); - prefs_reslistfontfamily = - settings.readEntry("/Recoll/prefs/reslist/fontFamily", ""); - prefs_reslistfontsize = - settings.readNumEntry("/Recoll/prefs/reslist/fontSize", 0);; - prefs_queryStemLang = - settings.readEntry("/Recoll/prefs/query/stemLang", "english"); -} - void recollCleanup() { - saveSettings(); + rwSettings(true); stop_idxthread(); delete rcldb; rcldb = 0; @@ -153,11 +133,12 @@ int main( int argc, char ** argv ) qt.load( QString( "qt_" ) + QTextCodec::locale(), "." ); a.installTranslator( &qt ); - readSettings(); + rwSettings(false); // Create main window and set its size to previous session's RecollMain w; mainWindow = &w; + QSize s(prefs_mainwidth, prefs_mainheight); w.resize(s); w.allTermsCB->setChecked(prefs_ssall); diff --git a/src/qtgui/recoll.h b/src/qtgui/recoll.h index 79879cb7..171f8791 100644 --- a/src/qtgui/recoll.h +++ b/src/qtgui/recoll.h @@ -1,6 +1,6 @@ #ifndef _RECOLL_H_INCLUDED_ #define _RECOLL_H_INCLUDED_ -/* @(#$Id: recoll.h,v 1.8 2005-12-14 16:15:39 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: recoll.h,v 1.9 2005-12-15 14:39:57 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -12,7 +12,6 @@ // Misc declarations in need of sharing between the UI files extern void recollCleanup(); -extern void getQueryStemming(bool &dostem, std::string &stemlang); extern bool maybeOpenDb(std::string &reason); extern RclConfig *rclconfig; @@ -27,6 +26,6 @@ extern bool prefs_showicons; extern int prefs_respagesize; extern QString prefs_reslistfontfamily; extern int prefs_reslistfontsize; - +extern QString prefs_queryStemLang; #endif /* _RECOLL_H_INCLUDED_ */ diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index ff3ae9b0..cd16d4a7 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -169,7 +169,7 @@ - + @@ -329,13 +329,13 @@ - preferencesUser_InterfaceAction + preferencesQuery_PrefsAction - &User Interface + &Query configuration - &User Interface + &Query configuration @@ -425,7 +425,7 @@ showResultPage() - preferencesUser_InterfaceAction + preferencesQuery_PrefsAction activated() RecollMain showUIPrefs() @@ -448,8 +448,6 @@ int reslist_car; bool reslist_waitingdbl; bool reslist_dblclck; - bool dostem; - std::string stemlang; Preview *curPreview; advsearch *asearchform; SortForm *sortform; diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index f1873337..fca59db8 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -32,6 +32,7 @@ using std::pair; #include #include #include +#include #include "recoll.h" #include "debuglog.h" @@ -59,7 +60,6 @@ void RecollMain::init() reslist_car = -1; reslist_waitingdbl = false; reslist_dblclck = false; - dostem = false; curPreview = 0; asearchform = 0; sortform = 0; @@ -377,13 +377,12 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata) QMessageBox::critical(0, "Recoll", QString(reason.c_str())); exit(1); } - if (stemlang.empty()) - getQueryStemming(dostem, stemlang); reslist_winfirst = -1; - if (!rcldb->setQuery(sdata, dostem ? - Rcl::Db::QO_STEM : Rcl::Db::QO_NONE, stemlang)) + if (!rcldb->setQuery(sdata, prefs_queryStemLang.length() > 0 ? + Rcl::Db::QO_STEM : Rcl::Db::QO_NONE, + prefs_queryStemLang.ascii())) return; curPreview = 0; if (docsource) @@ -591,7 +590,9 @@ void RecollMain::showResultPage() } #endif - if (reslist_winfirst >= 0 && (reslist_winfirst + prefs_respagesize >= resCnt)) { + if (reslist_winfirst < 0 || + (reslist_winfirst >= 0 && + reslist_winfirst + prefs_respagesize >= resCnt)) { nextPageAction->setEnabled(false); } else { nextPageAction->setEnabled(true); @@ -823,15 +824,19 @@ void RecollMain::setUIPrefs() LOGDEB(("Recollmain::setUIPrefs\n")); prefs_showicons = uiprefs->useIconsCB->isChecked(); prefs_respagesize = uiprefs->pageLenSB->value(); + prefs_reslistfontfamily = uiprefs->reslistFontFamily; prefs_reslistfontsize = uiprefs->reslistFontSize; - if (prefs_reslistfontfamily.length()) { QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize); reslistTE->setFont(nfont); } else { reslistTE->setFont(this->font()); } + + if (uiprefs->stemLangCMB->currentItem() == 0) { + prefs_queryStemLang = ""; + } else { + prefs_queryStemLang = uiprefs->stemLangCMB->currentText(); + } } - - diff --git a/src/sampleconf/recoll.conf.in b/src/sampleconf/recoll.conf.in index 6a34dfa5..b3bdbdd8 100644 --- a/src/sampleconf/recoll.conf.in +++ b/src/sampleconf/recoll.conf.in @@ -1,16 +1,17 @@ -# @(#$Id: recoll.conf.in,v 1.4 2005-12-02 16:17:29 dockes Exp $ (C) 2004 J.F.Dockes - +# @(#$Id: recoll.conf.in,v 1.5 2005-12-15 14:39:58 dockes Exp $ (C) 2004 J.F.Dockes +# # Recoll default configuration file. This should be copied to -# ~/.recoll/recoll.conf +# ~/.recoll/recoll.conf # Space-separated list of directories to index. Next line indexes $HOME topdirs = ~ # Wildcard expressions for names of files and directories that we should -# ignore: -skippedNames = *~ #* .* bin CVS Cache caughtspam tmp +# ignore. If you need index mozilla/thunderbird mail folders, don't put +# ".*" in there (as was the case with an older sample config) +skippedNames = *~ #* bin CVS Cache caughtspam tmp -# Debug messages +# Debug messages. 4 is quite verbose. 3 would be errors only. loglevel = 4 logfilename = stderr @@ -19,24 +20,17 @@ logfilename = stderr filtersdir = @prefix@/share/recoll/filters # Languages for which to build stemming databases at the end of -# indexing. Stemmer names can be found on the xapian site +# indexing. Stemmer names can be found on http://www.xapian.org +# The flag to perform stem expansion at query time is now set from the GUI indexstemminglanguages = english french -# Use stemming of query terms or not (ie: expand search for floors to -# floor, flooring, etc... ) -querystemming = 1 -querystemminglanguage = english - -# Name of file suffix to mime-type map file. +# Name of the file suffix to mime-type map file. mimemapfile = mimemap -# Name of mime-type to filter type/name map file. +# Name of the mime-type to filter type/name map file. mimeconffile = mimeconf -# Decide if we do show icons in the result list. This looks a bit more -# beaglish, but I'm not quite sure it's useful. If you wish to have them, -# you will have to copy the pngs from the distribution to wherever you want -# to store them (the associations are decided in mimeconf) -showicons = 1 +# The only reason to change this would be if you want to change the icons +# displayed in the result list iconsdir = @prefix@/share/recoll/images # Where to store the database. @@ -44,8 +38,10 @@ dbdir = ~/.recoll/xapiandb # Default character set. Values found inside files, ie content tag in html # documents, will override this. It can be specified per directory (see -# below). Used when converting to utf-8 (internal storage format). +# below). Used when converting to utf-8 (internal storage format), so it +# may be quite important for pure text files. defaultcharset = iso-8859-1 +# defaultlanguage is currently not used by the program. defaultlanguage = english # Guessing charsets usually does not work well @@ -56,7 +52,6 @@ guesscharset = 0 # indexation of many bogus 'text' files usesystemfilecommand = 1 -# You could specify different parameters for a subdirectory like this. -#[~/englishdocs/plain] +# You could specify different parameters for a subdirectory like this: +#[~/hungariandocs/plain] #defaultcharset = iso-8859-2 -