diff --git a/src/qtgui/advsearch.ui b/src/qtgui/advsearch.ui
index aa72d9b0..2bb8714f 100644
--- a/src/qtgui/advsearch.ui
+++ b/src/qtgui/advsearch.ui
@@ -118,6 +118,25 @@
+
+
+ delClausePB
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ Delete clause
+
+
+ false
+
+
addClausePB
diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp
index bd2e5f19..bba87091 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.11 2006-11-17 10:08:12 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.12 2006-11-17 15:26:40 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -50,6 +50,7 @@ using std::string;
extern RclConfig *rclconfig;
static const int initclausetypes[] = {1, 3, 0, 0, 2, 5};
+static const unsigned int iclausescnt = sizeof(initclausetypes) / sizeof(int);
void AdvSearch::init()
{
@@ -71,15 +72,29 @@ void AdvSearch::init()
connect(saveFileTypesPB, SIGNAL(clicked()),
this, SLOT(saveFileTypes()));
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
+ connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause()));
conjunctCMB->insertItem(tr("All clauses"));
conjunctCMB->insertItem(tr("Any clause"));
// Create preconfigured clauses
- for (unsigned int i = 0; i < sizeof(initclausetypes) / sizeof(int); i++) {
+ for (unsigned int i = 0; i < iclausescnt; i++) {
addClause(initclausetypes[i]);
}
-
+ // Tune initial state according to last saved
+ {
+ std::list::iterator cit = m_clauseWins.begin();
+ for (vector::iterator it = prefs.advSearchClauses.begin();
+ it != prefs.advSearchClauses.end(); it++) {
+ if (cit != m_clauseWins.end()) {
+ (*cit)->tpChange(*it);
+ cit++;
+ } else {
+ addClause(*it);
+ }
+ }
+ }
+
// Initialize lists of accepted and ignored mime types from config
// and settings
list types = rclconfig->getAllMimeTypes();
@@ -102,6 +117,21 @@ void AdvSearch::init()
clauseline->close();
}
+void AdvSearch::saveCnf()
+{
+ // Save my state
+ prefs.advSearchClauses.clear();
+ for (std::list::iterator cit = m_clauseWins.begin();
+ cit != m_clauseWins.end(); cit++) {
+ prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentItem());
+ }
+}
+
+bool AdvSearch::close()
+{
+ saveCnf();
+ return AdvSearchBase::close();
+}
// Move selected file types from the searched to the ignored box
void AdvSearch::delFiltypPB_clicked()
@@ -155,11 +185,38 @@ void AdvSearch::addClause(int tp)
clauseVBox->addWidget(w);
w->show();
w->tpChange(tp);
+ if (m_clauseWins.size() > iclausescnt) {
+ delClausePB->setEnabled(true);
+ } else {
+ delClausePB->setEnabled(false);
+ }
// Have to adjust the size else we lose the bottom buttons! Why?
QSize sz = AdvSearchBaseLayout->sizeHint();
resize(QSize(sz.width()+40, sz.height()+80));
}
+void AdvSearch::delClause()
+{
+ if (m_clauseWins.size() <= iclausescnt)
+ return;
+ delete m_clauseWins.back();
+ m_clauseWins.pop_back();
+ if (m_clauseWins.size() > iclausescnt) {
+ delClausePB->setEnabled(true);
+ } else {
+ delClausePB->setEnabled(false);
+ }
+ QSize sz = AdvSearchBaseLayout->sizeHint();
+ resize(QSize(sz.width()+40, sz.height()+80));
+}
+
+void AdvSearch::polish()
+{
+ QSize sz = AdvSearchBaseLayout->sizeHint();
+ resize(QSize(sz.width()+40, sz.height()+80));
+ AdvSearchBase::polish();
+}
+
// Move selected file types from the ignored to the searched box
void AdvSearch::addFiltypPB_clicked()
{
@@ -248,10 +305,11 @@ void AdvSearch::searchPB_clicked()
for (int index = 0; index < subtreeCMB->count(); index++)
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
}
+ saveCnf();
+
emit startSearch(sdata);
}
-
void AdvSearch::browsePB_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h
index 5d386c71..ec75f573 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.6 2006-11-14 18:29:09 dockes Exp $ (C) 2005 J.F.Dockes */
+/* @(#$Id: advsearch_w.h,v 1.7 2006-11-17 15:26:40 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
@@ -46,8 +46,11 @@ public slots:
virtual void searchPB_clicked();
virtual void browsePB_clicked();
virtual void saveFileTypes();
+ virtual void delClause();
virtual void addClause();
virtual void addClause(int);
+ virtual bool close();
+ virtual void polish();
signals:
void startSearch(RefCntr);
@@ -55,6 +58,7 @@ signals:
private:
virtual void init();
std::list m_clauseWins;
+ void saveCnf();
};
diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp
index 651101cb..17dbba18 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.23 2006-11-10 13:32:08 dockes Exp $ (C) 2005 Jean-Francois Dockes";
+static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.24 2006-11-17 15:26:40 dockes Exp $ (C) 2005 Jean-Francois Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -147,6 +147,27 @@ void rwSettings(bool writing)
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
SETTING_RW(prefs.startWithSortToolOpen,
"/Recoll/prefs/startWithSortToolOpen", Bool, false);
+
+ QString advSearchClauses;
+ QString ascdflt = QString::fromAscii("1 3 0 0 2 5 ");
+ if (writing) {
+ for (vector::iterator it = prefs.advSearchClauses.begin();
+ it != prefs.advSearchClauses.end(); it++) {
+ char buf[20];
+ sprintf(buf, "%d ", *it);
+ advSearchClauses += QString::fromAscii(buf);
+ }
+ }
+ SETTING_RW(advSearchClauses, "/Recoll/prefs/adv/clauseList", , ascdflt);
+ if (!writing) {
+ list clauses;
+ stringToStrings(advSearchClauses, clauses);
+ for (list::iterator it = clauses.begin();
+ it != clauses.end(); it++) {
+ prefs.advSearchClauses.push_back(atoi(it->c_str()));
+ }
+ }
+
SETTING_RW(prefs.showicons, "/Recoll/prefs/reslist/showicons", Bool, true);
SETTING_RW(prefs.autoSearchOnWS, "/Recoll/prefs/reslist/autoSearchOnWS",
Bool, false);
@@ -157,10 +178,10 @@ void rwSettings(bool writing)
"");
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Num,
0);
- QString rlfDflt =QString::fromAscii(
- "%R %S %L %T
"
- "%M %D %U
"
- "%A %K");
+ QString rlfDflt =
+ QString::fromAscii("%R %S %L %T
"
+ "%M %D %U
"
+ "%A %K");
SETTING_RW(prefs.reslistformat, "/Recoll/prefs/reslist/format", , rlfDflt);
if (prefs.reslistformat.stripWhiteSpace().isEmpty())
prefs.reslistformat = rlfDflt;
diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h
index f1999cc5..9cb33682 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.15 2006-11-10 13:32:08 dockes Exp $ (C) 2005 Jean-Francois Dockes
+ * @(#$Id: guiutils.h,v 1.16 2006-11-17 15:26:40 dockes Exp $ (C) 2005 Jean-Francois Dockes
* jean-francois.dockes@wanadoo.fr
*
* This program is free software; you can redistribute it and/or modify
@@ -38,12 +38,15 @@
#include
#include
+#include
+
#include
#include
#ifndef NO_NAMESPACES
using std::string;
using std::list;
+using std::vector;
#endif
/** Start a browser on the help document */
@@ -96,6 +99,9 @@ class PrefsPack {
// Remembered term match mode
int termMatchType;
+ // Advanced search window clause list state
+ vector advSearchClauses;
+
PrefsPack() :
showicons(true),
respagesize(8),