no space in query -> phrase
This commit is contained in:
parent
22c844324d
commit
27b41b3911
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.19 2007-01-25 15:46:38 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.20 2007-02-06 10:19:40 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -80,6 +80,10 @@ void SSearch::startSimpleSearch()
|
|||||||
string u8 = (const char *)queryText->currentText().utf8();
|
string u8 = (const char *)queryText->currentText().utf8();
|
||||||
LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str()));
|
LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str()));
|
||||||
|
|
||||||
|
trimstring(u8);
|
||||||
|
if (u8.length() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
SSearchType tp = (SSearchType)searchTypCMB->currentItem();
|
SSearchType tp = (SSearchType)searchTypCMB->currentItem();
|
||||||
Rcl::SearchData *sdata = 0;
|
Rcl::SearchData *sdata = 0;
|
||||||
|
|
||||||
@ -98,27 +102,39 @@ void SSearch::startSimpleSearch()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is no white space inside the query, then the user
|
||||||
|
// certainly means it as a phrase.
|
||||||
|
bool isreallyaphrase = false;
|
||||||
|
if (u8.find_first_of(" \t") == string::npos)
|
||||||
|
isreallyaphrase = true;
|
||||||
|
|
||||||
// Maybe add automatic phrase ? For ALL and ANY, and not if
|
// Maybe add automatic phrase ? For ALL and ANY, and not if
|
||||||
// there is already a phrase or wildcard terms.
|
// there is already a phrase or wildcard terms.
|
||||||
if (prefs.ssearchAutoPhrase && (tp == SST_ANY || tp == SST_ALL) &&
|
if (!isreallyaphrase &&
|
||||||
|
prefs.ssearchAutoPhrase && (tp == SST_ANY || tp == SST_ALL) &&
|
||||||
u8.find_first_of("\"*[]?") == string::npos &&
|
u8.find_first_of("\"*[]?") == string::npos &&
|
||||||
TextSplit::countWords(u8) > 1) {
|
TextSplit::countWords(u8) > 1) {
|
||||||
sdata->addClause(new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE,
|
sdata->addClause(new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE,
|
||||||
u8, 0));
|
u8, 0));
|
||||||
}
|
}
|
||||||
|
Rcl::SearchDataClause *clp = 0;
|
||||||
switch (tp) {
|
switch (tp) {
|
||||||
case SST_ANY:
|
case SST_ANY:
|
||||||
default:
|
default:
|
||||||
sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_OR,u8));
|
clp = isreallyaphrase ?
|
||||||
|
new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, u8, 0) :
|
||||||
|
new Rcl::SearchDataClauseSimple(Rcl::SCLT_OR, u8);
|
||||||
break;
|
break;
|
||||||
case SST_ALL:
|
case SST_ALL:
|
||||||
sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND,u8));
|
clp = isreallyaphrase ?
|
||||||
|
new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, u8, 0) :
|
||||||
|
new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, u8);
|
||||||
break;
|
break;
|
||||||
case SST_FNM:
|
case SST_FNM:
|
||||||
sdata->addClause(new Rcl::SearchDataClauseFilename(u8));
|
clp = new Rcl::SearchDataClauseFilename(u8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sdata->addClause(clp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search terms history
|
// Search terms history
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user