use SearchClauseW for all advsearch fields
This commit is contained in:
parent
f29f7eafb2
commit
9c68941431
@ -118,121 +118,6 @@
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout10</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>andWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>All of these</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>andWordsLE</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words, and/or quoted phrases.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>phraseTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>This exact phrase</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>phraseLE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>orWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>orWordsLE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words, and/or quoted phrases.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>orWords1TL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="3" column="1">
|
||||
<property name="name">
|
||||
<cstring>orWords1LE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words, and/or quoted phrases.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="4" column="0">
|
||||
<property name="name">
|
||||
<cstring>noWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>None of these</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="4" column="1">
|
||||
<property name="name">
|
||||
<cstring>noWordsLE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words, and/or quoted phrases.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="5" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File name matching</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="5" column="1">
|
||||
<property name="name">
|
||||
<cstring>fileNameLE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter file name. * and ? are wildcards.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="Line">
|
||||
<property name="name">
|
||||
<cstring>clauseline</cstring>
|
||||
|
||||
@ -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<string> 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<SearchData> 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<SearchClauseW*>::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;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<string>& 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<Xapian::Query> orqueries;
|
||||
bool hadmultiple = false;
|
||||
string nolang, lang;
|
||||
for (vector<string>::iterator it = splitData.terms.begin();
|
||||
it != splitData.terms.end(); it++) {
|
||||
list<string>exp;
|
||||
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()));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user