From d76382ce2eae70e32bbc93eeb5e82e513adb5acf Mon Sep 17 00:00:00 2001 From: dockes Date: Wed, 13 Sep 2006 08:13:36 +0000 Subject: [PATCH] add feature to save asearch ignored file types as startup default --- src/qtgui/advsearch.ui | 49 +++++++++++++++++++++++++++++++++------ src/qtgui/advsearch_w.cpp | 21 +++++++++++++++-- src/qtgui/advsearch_w.h | 3 ++- src/qtgui/guiutils.cpp | 18 ++++++++++++-- src/qtgui/guiutils.h | 10 ++++++-- src/qtgui/main.cpp | 7 +++++- src/qtgui/rclmain.cpp | 8 ++++++- src/qtgui/uiprefs.ui | 30 ++++++++++++++++++++++-- src/qtgui/uiprefs_w.cpp | 9 ++++++- 9 files changed, 136 insertions(+), 19 deletions(-) diff --git a/src/qtgui/advsearch.ui b/src/qtgui/advsearch.ui index 30cdafd5..9f4fb1f9 100644 --- a/src/qtgui/advsearch.ui +++ b/src/qtgui/advsearch.ui @@ -39,6 +39,12 @@ textLabel2 + + NoFrame + + + Plain + 7 @@ -180,13 +186,42 @@ Horizontal - + - restrictFtCB - - - Restrict file types + layout25 + + + unnamed + + + + restrictFtCB + + + + 1 + 0 + 1 + 0 + + + + Restrict file types + + + + + saveFileTypesPB + + + Save as default + + + false + + + @@ -356,7 +391,7 @@ unnamed - + subtreeCMB @@ -387,7 +422,7 @@ NoInsertion - false + false Enter top directory for search diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index 9976aab4..cd3486fd 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.3 2006-09-12 10:11:36 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.4 2006-09-13 08:13:36 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -72,12 +72,18 @@ void AdvSearch::init() this, SLOT(delAFiltypPB_clicked())); connect(addAFiltypPB, SIGNAL(clicked()), this, SLOT(addAFiltypPB_clicked())); + connect(saveFileTypesPB, SIGNAL(clicked()), + this, SLOT(saveFileTypes())); + // Initialize lists of accepted and ignored mime types from config + // and settings list types = rclconfig->getAllMimeTypes(); + noFiltypsLB->insertStringList(prefs.asearchIgnFilTyps); QStringList ql; for (list::iterator it = types.begin(); it != types.end(); it++) { - ql.append(it->c_str()); + if (prefs.asearchIgnFilTyps.findIndex(it->c_str())<0) + ql.append(it->c_str()); } yesFiltypsLB->insertStringList(ql); @@ -115,6 +121,17 @@ void AdvSearch::delAFiltypPB_clicked() delFiltypPB_clicked(); } +// Save current list of ignored file types to prefs +void AdvSearch::saveFileTypes() +{ + prefs.asearchIgnFilTyps.clear(); + for (unsigned int i = 0; i < noFiltypsLB->count();i++) { + QListBoxItem *item = noFiltypsLB->item(i); + prefs.asearchIgnFilTyps.append(item->text()); + } + rwSettings(true); +} + // Move selected file types from the ignored to the searched box void AdvSearch::addFiltypPB_clicked() { diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h index bfccaaae..bb9a5bed 100644 --- a/src/qtgui/advsearch_w.h +++ b/src/qtgui/advsearch_w.h @@ -1,6 +1,6 @@ #ifndef _ADVSEARCH_W_H_INCLUDED_ #define _ADVSEARCH_W_H_INCLUDED_ -/* @(#$Id: advsearch_w.h,v 1.1 2006-09-04 15:13:01 dockes Exp $ (C) 2005 J.F.Dockes */ +/* @(#$Id: advsearch_w.h,v 1.2 2006-09-13 08:13:36 dockes Exp $ (C) 2005 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 @@ -40,6 +40,7 @@ public slots: virtual void restrictFtCB_toggled( bool on ); virtual void searchPB_clicked(); virtual void browsePB_clicked(); + virtual void saveFileTypes(); signals: void startSearch(Rcl::AdvSearchData); diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 45ff8b57..f39a8052 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.15 2006-09-11 12:05:38 dockes Exp $ (C) 2005 Jean-Francois Dockes"; +static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.16 2006-09-13 08:13:36 dockes Exp $ (C) 2005 Jean-Francois Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -131,6 +131,11 @@ void rwSettings(bool writing) SETTING_RW(prefs.mainheight, "/Recoll/geometry/height", Num, 400); SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Num, 0); SETTING_RW(prefs.htmlBrowser, "/Recoll/prefs/htmlBrowser", , ""); + SETTING_RW(prefs.startWithAdvSearchOpen, + "/Recoll/prefs/startWithAdvSearchOpen", Bool, false); + SETTING_RW(prefs.startWithSortToolOpen, + "/Recoll/prefs/startWithSortToolOpen", Bool, false); + SETTING_RW(prefs.showicons, "/Recoll/prefs/reslist/showicons", Bool, true); SETTING_RW(prefs.autoSearchOnWS, "/Recoll/prefs/reslist/autoSearchOnWS", Bool, false); @@ -139,9 +144,9 @@ void rwSettings(bool writing) ""); SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Num, 0); + SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", , "english"); - SETTING_RW(prefs.queryBuildAbstract, "/Recoll/prefs/query/buildAbstract", Bool, true); SETTING_RW(prefs.queryReplaceAbstract, @@ -156,6 +161,15 @@ void rwSettings(bool writing) settings.readListEntry("/Recoll/prefs/query/ssearchHistory"); } + // Ssearch combobox history list + if (writing) { + settings.writeEntry("/Recoll/prefs/query/asearchIgnFilTyps", + prefs.asearchIgnFilTyps); + } else { + prefs.asearchIgnFilTyps = + settings.readListEntry("/Recoll/prefs/query/asearchIgnFilTyps"); + } + // The extra databases settings. These are stored as a list of // xapian directory names, encoded in base64 to avoid any // binary/charset conversion issues. There are 2 lists for all diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index 6a8222b0..8aa0a68d 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -17,7 +17,7 @@ #ifndef _GUIUTILS_H_INCLUDED_ #define _GUIUTILS_H_INCLUDED_ /* - * @(#$Id: guiutils.h,v 1.7 2006-09-11 12:05:38 dockes Exp $ (C) 2005 Jean-Francois Dockes + * @(#$Id: guiutils.h,v 1.8 2006-09-13 08:13:36 dockes Exp $ (C) 2005 Jean-Francois Dockes * jean-francois.dockes@wanadoo.fr * * This program is free software; you can redistribute it and/or modify @@ -64,6 +64,8 @@ class PrefsPack { QString htmlBrowser; bool queryBuildAbstract; bool queryReplaceAbstract; + bool startWithAdvSearchOpen; + bool startWithSortToolOpen; // Extra query databases. This are encoded to base64 before storing // to the qt settings file to avoid any bin string/ charset conv issues list allExtraDbs; @@ -73,6 +75,8 @@ class PrefsPack { QStringList asearchSubdirHist; // Textual history of simple searches (this is just the combobox list) QStringList ssearchHistory; + // Ignored file types in adv search (startup default) + QStringList asearchIgnFilTyps; PrefsPack() : showicons(true), @@ -80,7 +84,9 @@ class PrefsPack { reslistfontsize(10), ssearchTyp(0), queryBuildAbstract(true), - queryReplaceAbstract(false) + queryReplaceAbstract(false), + startWithAdvSearchOpen(false), + startWithSortToolOpen(false) { } }; diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 86345d94..b7db3767 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.47 2006-09-11 09:08:44 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: main.cpp,v 1.48 2006-09-13 08:13:36 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -288,6 +288,11 @@ int main(int argc, char **argv) } mainWindow->show(); + if (prefs.startWithAdvSearchOpen) + mainWindow->showAdvSearchDialog(); + if (prefs.startWithSortToolOpen) + mainWindow->showSortDialog(); + start_idxthread(*rclconfig); // Let's go diff --git a/src/qtgui/rclmain.cpp b/src/qtgui/rclmain.cpp index d71c2562..75d1595e 100644 --- a/src/qtgui/rclmain.cpp +++ b/src/qtgui/rclmain.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.30 2006-09-12 10:11:36 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.31 2006-09-13 08:13:36 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -131,6 +131,12 @@ void RclMain::init() nextPageAction->setIconSet(createIconSet("nextpage.png")); prevPageAction->setIconSet(createIconSet("prevpage.png")); + + + if (prefs.startWithAdvSearchOpen) + showAdvSearchDialog(); + if (prefs.startWithSortToolOpen) + showSortDialog(); } // We also want to get rid of the advanced search form and previews diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index 35b34b63..a650dc19 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -164,7 +164,7 @@ useIconsCB - Show document type icons in result list + Show document type icons in result list. true @@ -175,12 +175,38 @@ autoSearchCB - Auto-start simple search on whitespace entry + Auto-start simple search on whitespace entry. false + + + + initStartAdvCB + + + Start with advanced search dialog open. + + + false + + + + + initStartSortCB + + + Start with sort dialog open. + + + false + + + + + diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index 5a78f0fa..1f46d735 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.2 2006-09-06 09:50:59 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.3 2006-09-13 08:13:36 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -54,6 +54,10 @@ void UIPrefsDialog::init() // Show icons checkbox useIconsCB->setChecked(prefs.showicons); autoSearchCB->setChecked(prefs.autoSearchOnWS); + + initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen); + initStartSortCB->setChecked(prefs.startWithSortToolOpen); + // Result list font family and size reslistFontFamily = prefs.reslistfontfamily; reslistFontSize = prefs.reslistfontsize; @@ -149,6 +153,9 @@ void UIPrefsDialog::accept() prefs.queryReplaceAbstract = buildAbsCB->isChecked() && replAbsCB->isChecked(); + prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked(); + prefs.startWithSortToolOpen = initStartSortCB->isChecked(); + prefs.activeExtraDbs.clear(); for (unsigned int i = 0; i < actDbsLB->count(); i++) { QListBoxItem *item = actDbsLB->item(i);