diff --git a/src/qtgui/advsearch.ui b/src/qtgui/advsearch.ui
index 6791d727..552fddd8 100644
--- a/src/qtgui/advsearch.ui
+++ b/src/qtgui/advsearch.ui
@@ -118,121 +118,6 @@
unnamed
-
-
- layout10
-
-
-
- unnamed
-
-
- 8
-
-
-
- andWordsTL
-
-
- All of these
-
-
-
-
- andWordsLE
-
-
-
- 300
- 0
-
-
-
- Enter words, and/or quoted phrases.
-
-
-
-
- phraseTL
-
-
- This exact phrase
-
-
-
-
- phraseLE
-
-
- Enter words.
-
-
-
-
- orWordsTL
-
-
- Any of these
-
-
-
-
- orWordsLE
-
-
- Enter words, and/or quoted phrases.
-
-
-
-
- orWords1TL
-
-
- Any of these
-
-
-
-
- orWords1LE
-
-
- Enter words, and/or quoted phrases.
-
-
-
-
- noWordsTL
-
-
- None of these
-
-
-
-
- noWordsLE
-
-
- Enter words, and/or quoted phrases.
-
-
-
-
- textLabel1_2
-
-
- File name matching
-
-
-
-
- fileNameLE
-
-
- Enter file name. * and ? are wildcards.
-
-
-
-
clauseline
diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp
index 8c640272..c458277a 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.7 2006-11-14 15:13:50 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.8 2006-11-14 17:41:12 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -59,13 +59,7 @@ void AdvSearch::init()
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
connect(browsePB, SIGNAL(clicked()), this, SLOT(browsePB_clicked()));
connect(addFiltypPB, SIGNAL(clicked()), this, SLOT(addFiltypPB_clicked()));
- connect(andWordsLE, SIGNAL(returnPressed()),
- this, SLOT(searchPB_clicked()));
- connect(orWordsLE, SIGNAL(returnPressed()),
- this, SLOT(searchPB_clicked()));
- connect(noWordsLE, SIGNAL(returnPressed()),
- this, SLOT(searchPB_clicked()));
- connect(phraseLE, SIGNAL(returnPressed()), this, SLOT(searchPB_clicked()));
+
connect(subtreeCMB->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(searchPB_clicked()));
connect(delAFiltypPB, SIGNAL(clicked()),
@@ -76,6 +70,31 @@ void AdvSearch::init()
this, SLOT(saveFileTypes()));
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
+ // Create preconfigured clauses
+ andWords = new SearchClauseW(this);
+ andWords->tpChange(1);
+ clauseVBox->addWidget(andWords);
+
+ phrase = new SearchClauseW(this);
+ phrase->tpChange(3);
+ clauseVBox->addWidget(phrase);
+
+ orWords = new SearchClauseW(this);
+ orWords->tpChange(0);
+ clauseVBox->addWidget(orWords);
+
+ orWords1 = new SearchClauseW(this);
+ orWords1->tpChange(0);
+ clauseVBox->addWidget(orWords1);
+
+ noWords = new SearchClauseW(this);
+ noWords->tpChange(2);
+ clauseVBox->addWidget(noWords);
+
+ fileName = new SearchClauseW(this);
+ fileName->tpChange(5);
+ clauseVBox->addWidget(fileName);
+
// Initialize lists of accepted and ignored mime types from config
// and settings
list types = rclconfig->getAllMimeTypes();
@@ -145,7 +164,7 @@ void AdvSearch::addClause()
m_clauseWins.push_back(w);
connect(w->wordsLE, SIGNAL(returnPressed()),
this, SLOT(searchPB_clicked()));
- clauseVBox->insertWidget(-1, w);
+ clauseVBox->addWidget(w);
w->show();
// Have to adjust the size else we lose the bottom buttons! Why?
QSize sz = AdvSearchBaseLayout->sizeHint();
@@ -198,39 +217,52 @@ void AdvSearch::searchPB_clicked()
RefCntr sdata(new SearchData(SCLT_AND));
bool hasnotnot = false;
bool hasnot = false;
- if (!andWordsLE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseSimple(SCLT_AND,
- (const char *)andWordsLE->text().utf8()));
- hasnotnot = true;
+ SearchDataClause *cl;
+
+ if ((cl = andWords->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
- if (!orWordsLE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
- (const char *)orWordsLE->text().utf8()));
- hasnotnot = true;
+ if ((cl = phrase->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
- if (!orWords1LE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
- (const char *)orWords1LE->text().utf8()));
- hasnotnot = true;
+ if ((cl = orWords->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
- if (!noWordsLE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseSimple(SCLT_EXCL,
- (const char *)noWordsLE->text().utf8()));
- hasnot = true;
+ if ((cl = orWords1->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
- if (!fileNameLE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseFilename(
- (const char *)fileNameLE->text().utf8()));
- hasnotnot = true;
+ if ((cl = noWords->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
- if (!phraseLE->text().isEmpty()) {
- sdata->addClause(new SearchDataClauseDist(SCLT_PHRASE,
- (const char *)phraseLE->text().utf8(), 0));
- hasnotnot = true;
+ if ((cl = fileName->getClause())) {
+ switch (cl->m_tp) {
+ case SCLT_EXCL: hasnot = true; break;
+ default: hasnotnot = true; break;
+ }
+ sdata->addClause(cl);
}
for (list::iterator it = m_clauseWins.begin();
it != m_clauseWins.end(); it++) {
- SearchDataClause *cl;
if ((cl = (*it)->getClause())) {
switch (cl->m_tp) {
case SCLT_EXCL: hasnot = true; break;
diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h
index bbf32c7d..744b418e 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.4 2006-11-14 13:55:43 dockes Exp $ (C) 2005 J.F.Dockes */
+/* @(#$Id: advsearch_w.h,v 1.5 2006-11-14 17:41:12 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
@@ -31,9 +31,18 @@ class AdvSearch : public AdvSearchBase
Q_OBJECT
public:
- AdvSearch(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0) : AdvSearchBase(parent,name,modal,fl)
- {init();}
- ~AdvSearch(){}
+ AdvSearch(QWidget* parent = 0, const char* name = 0, bool modal = FALSE,
+ WFlags fl = 0)
+ : AdvSearchBase(parent,name,modal,fl)
+ {init();}
+ ~AdvSearch(){}
+ SearchClauseW* andWords;
+ SearchClauseW* phrase;
+ SearchClauseW* orWords;
+ SearchClauseW* orWords1;
+ SearchClauseW* noWords;
+ SearchClauseW* fileName;
+
public slots:
virtual void delFiltypPB_clicked();
virtual void delAFiltypPB_clicked();
diff --git a/src/qtgui/searchclause_w.cpp b/src/qtgui/searchclause_w.cpp
index 35770044..4576a4b5 100644
--- a/src/qtgui/searchclause_w.cpp
+++ b/src/qtgui/searchclause_w.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: searchclause_w.cpp,v 1.1 2006-11-14 13:55:43 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: searchclause_w.cpp,v 1.2 2006-11-14 17:41:12 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -130,14 +130,19 @@ SearchClauseW::getClause()
// Handle combobox change: may need to enable/disable the distance spinbox
void SearchClauseW::tpChange(int index)
{
+ if (index < 0 || index > 5)
+ return;
+ if (sTpCMB->currentItem() != index)
+ sTpCMB->setCurrentItem(index);
switch (index) {
case 3:
case 4:
+ proxSlackSB->show();
proxSlackSB->setEnabled(true);
if (index == 4)
proxSlackSB->setValue(10);
break;
default:
- proxSlackSB->setEnabled(false);
+ proxSlackSB->close();
}
}
diff --git a/src/qtgui/searchclause_w.h b/src/qtgui/searchclause_w.h
index 5d085508..37e7fdda 100644
--- a/src/qtgui/searchclause_w.h
+++ b/src/qtgui/searchclause_w.h
@@ -45,10 +45,10 @@ public:
protected:
QVBoxLayout* searchClauseLayout;
QHBoxLayout* hLayout;
-
+public slots:
+ virtual void tpChange(int);
protected slots:
virtual void languageChange();
- virtual void tpChange(int);
};
#endif // SEARCHCLAUSE_H
diff --git a/src/rcldb/searchdata.cpp b/src/rcldb/searchdata.cpp
index 9c97dad2..210e5aa8 100644
--- a/src/rcldb/searchdata.cpp
+++ b/src/rcldb/searchdata.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.2 2006-11-14 13:55:43 dockes Exp $ (C) 2006 J.F.Dockes";
+static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.3 2006-11-14 17:41:12 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -146,6 +146,7 @@ class wsQData : public TextSplitCB {
static void maybeStemExp(Db& db, const string& stemlang, const string& term,
list& exp)
{
+ LOGDEB(("maybeStemExp: [%s]\n", term.c_str()));
string term1;
dumb_string(term, term1);
if (!stemlang.empty()) {
@@ -242,10 +243,16 @@ static bool stringToXapianQueries(const string &iq,
Xapian::Query::op op = useNear ? Xapian::Query::OP_NEAR :
Xapian::Query::OP_PHRASE;
list orqueries;
+ bool hadmultiple = false;
+ string nolang, lang;
for (vector::iterator it = splitData.terms.begin();
it != splitData.terms.end(); it++) {
listexp;
- maybeStemExp(db, stemlang, *it, exp);
+ lang = (op == Xapian::Query::OP_PHRASE || hadmultiple) ?
+ nolang : stemlang;
+ maybeStemExp(db, lang, *it, exp);
+ if (exp.size() > 1)
+ hadmultiple = true;
orqueries.push_back(Xapian::Query(Xapian::Query::OP_OR,
exp.begin(), exp.end()));
}