use SearchClauseW for all advsearch fields
This commit is contained in:
parent
f29f7eafb2
commit
9c68941431
@ -118,121 +118,6 @@
|
|||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>unnamed</cstring>
|
<cstring>unnamed</cstring>
|
||||||
</property>
|
</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">
|
<widget class="Line">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>clauseline</cstring>
|
<cstring>clauseline</cstring>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#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
|
||||||
@ -59,13 +59,7 @@ void AdvSearch::init()
|
|||||||
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
connect(browsePB, SIGNAL(clicked()), this, SLOT(browsePB_clicked()));
|
connect(browsePB, SIGNAL(clicked()), this, SLOT(browsePB_clicked()));
|
||||||
connect(addFiltypPB, SIGNAL(clicked()), this, SLOT(addFiltypPB_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()),
|
connect(subtreeCMB->lineEdit(), SIGNAL(returnPressed()),
|
||||||
this, SLOT(searchPB_clicked()));
|
this, SLOT(searchPB_clicked()));
|
||||||
connect(delAFiltypPB, SIGNAL(clicked()),
|
connect(delAFiltypPB, SIGNAL(clicked()),
|
||||||
@ -76,6 +70,31 @@ void AdvSearch::init()
|
|||||||
this, SLOT(saveFileTypes()));
|
this, SLOT(saveFileTypes()));
|
||||||
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
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
|
// Initialize lists of accepted and ignored mime types from config
|
||||||
// and settings
|
// and settings
|
||||||
list<string> types = rclconfig->getAllMimeTypes();
|
list<string> types = rclconfig->getAllMimeTypes();
|
||||||
@ -145,7 +164,7 @@ void AdvSearch::addClause()
|
|||||||
m_clauseWins.push_back(w);
|
m_clauseWins.push_back(w);
|
||||||
connect(w->wordsLE, SIGNAL(returnPressed()),
|
connect(w->wordsLE, SIGNAL(returnPressed()),
|
||||||
this, SLOT(searchPB_clicked()));
|
this, SLOT(searchPB_clicked()));
|
||||||
clauseVBox->insertWidget(-1, w);
|
clauseVBox->addWidget(w);
|
||||||
w->show();
|
w->show();
|
||||||
// Have to adjust the size else we lose the bottom buttons! Why?
|
// Have to adjust the size else we lose the bottom buttons! Why?
|
||||||
QSize sz = AdvSearchBaseLayout->sizeHint();
|
QSize sz = AdvSearchBaseLayout->sizeHint();
|
||||||
@ -198,39 +217,52 @@ void AdvSearch::searchPB_clicked()
|
|||||||
RefCntr<SearchData> sdata(new SearchData(SCLT_AND));
|
RefCntr<SearchData> sdata(new SearchData(SCLT_AND));
|
||||||
bool hasnotnot = false;
|
bool hasnotnot = false;
|
||||||
bool hasnot = false;
|
bool hasnot = false;
|
||||||
if (!andWordsLE->text().isEmpty()) {
|
SearchDataClause *cl;
|
||||||
sdata->addClause(new SearchDataClauseSimple(SCLT_AND,
|
|
||||||
(const char *)andWordsLE->text().utf8()));
|
if ((cl = andWords->getClause())) {
|
||||||
hasnotnot = true;
|
switch (cl->m_tp) {
|
||||||
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
if (!orWordsLE->text().isEmpty()) {
|
if ((cl = phrase->getClause())) {
|
||||||
sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
|
switch (cl->m_tp) {
|
||||||
(const char *)orWordsLE->text().utf8()));
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
hasnotnot = true;
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
if (!orWords1LE->text().isEmpty()) {
|
if ((cl = orWords->getClause())) {
|
||||||
sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
|
switch (cl->m_tp) {
|
||||||
(const char *)orWords1LE->text().utf8()));
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
hasnotnot = true;
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
if (!noWordsLE->text().isEmpty()) {
|
if ((cl = orWords1->getClause())) {
|
||||||
sdata->addClause(new SearchDataClauseSimple(SCLT_EXCL,
|
switch (cl->m_tp) {
|
||||||
(const char *)noWordsLE->text().utf8()));
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
hasnot = true;
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
if (!fileNameLE->text().isEmpty()) {
|
if ((cl = noWords->getClause())) {
|
||||||
sdata->addClause(new SearchDataClauseFilename(
|
switch (cl->m_tp) {
|
||||||
(const char *)fileNameLE->text().utf8()));
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
hasnotnot = true;
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
if (!phraseLE->text().isEmpty()) {
|
if ((cl = fileName->getClause())) {
|
||||||
sdata->addClause(new SearchDataClauseDist(SCLT_PHRASE,
|
switch (cl->m_tp) {
|
||||||
(const char *)phraseLE->text().utf8(), 0));
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
hasnotnot = true;
|
default: hasnotnot = true; break;
|
||||||
|
}
|
||||||
|
sdata->addClause(cl);
|
||||||
}
|
}
|
||||||
for (list<SearchClauseW*>::iterator it = m_clauseWins.begin();
|
for (list<SearchClauseW*>::iterator it = m_clauseWins.begin();
|
||||||
it != m_clauseWins.end(); it++) {
|
it != m_clauseWins.end(); it++) {
|
||||||
SearchDataClause *cl;
|
|
||||||
if ((cl = (*it)->getClause())) {
|
if ((cl = (*it)->getClause())) {
|
||||||
switch (cl->m_tp) {
|
switch (cl->m_tp) {
|
||||||
case SCLT_EXCL: hasnot = true; break;
|
case SCLT_EXCL: hasnot = true; break;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _ADVSEARCH_W_H_INCLUDED_
|
#ifndef _ADVSEARCH_W_H_INCLUDED_
|
||||||
#define _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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,9 +31,18 @@ class AdvSearch : public AdvSearchBase
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AdvSearch(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0) : AdvSearchBase(parent,name,modal,fl)
|
AdvSearch(QWidget* parent = 0, const char* name = 0, bool modal = FALSE,
|
||||||
{init();}
|
WFlags fl = 0)
|
||||||
~AdvSearch(){}
|
: AdvSearchBase(parent,name,modal,fl)
|
||||||
|
{init();}
|
||||||
|
~AdvSearch(){}
|
||||||
|
SearchClauseW* andWords;
|
||||||
|
SearchClauseW* phrase;
|
||||||
|
SearchClauseW* orWords;
|
||||||
|
SearchClauseW* orWords1;
|
||||||
|
SearchClauseW* noWords;
|
||||||
|
SearchClauseW* fileName;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void delFiltypPB_clicked();
|
virtual void delFiltypPB_clicked();
|
||||||
virtual void delAFiltypPB_clicked();
|
virtual void delAFiltypPB_clicked();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#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
|
||||||
@ -130,14 +130,19 @@ SearchClauseW::getClause()
|
|||||||
// Handle combobox change: may need to enable/disable the distance spinbox
|
// Handle combobox change: may need to enable/disable the distance spinbox
|
||||||
void SearchClauseW::tpChange(int index)
|
void SearchClauseW::tpChange(int index)
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index > 5)
|
||||||
|
return;
|
||||||
|
if (sTpCMB->currentItem() != index)
|
||||||
|
sTpCMB->setCurrentItem(index);
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
|
proxSlackSB->show();
|
||||||
proxSlackSB->setEnabled(true);
|
proxSlackSB->setEnabled(true);
|
||||||
if (index == 4)
|
if (index == 4)
|
||||||
proxSlackSB->setValue(10);
|
proxSlackSB->setValue(10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
proxSlackSB->setEnabled(false);
|
proxSlackSB->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,10 +45,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
QVBoxLayout* searchClauseLayout;
|
QVBoxLayout* searchClauseLayout;
|
||||||
QHBoxLayout* hLayout;
|
QHBoxLayout* hLayout;
|
||||||
|
public slots:
|
||||||
|
virtual void tpChange(int);
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void languageChange();
|
virtual void languageChange();
|
||||||
virtual void tpChange(int);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SEARCHCLAUSE_H
|
#endif // SEARCHCLAUSE_H
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#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
|
||||||
@ -146,6 +146,7 @@ class wsQData : public TextSplitCB {
|
|||||||
static void maybeStemExp(Db& db, const string& stemlang, const string& term,
|
static void maybeStemExp(Db& db, const string& stemlang, const string& term,
|
||||||
list<string>& exp)
|
list<string>& exp)
|
||||||
{
|
{
|
||||||
|
LOGDEB(("maybeStemExp: [%s]\n", term.c_str()));
|
||||||
string term1;
|
string term1;
|
||||||
dumb_string(term, term1);
|
dumb_string(term, term1);
|
||||||
if (!stemlang.empty()) {
|
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 op = useNear ? Xapian::Query::OP_NEAR :
|
||||||
Xapian::Query::OP_PHRASE;
|
Xapian::Query::OP_PHRASE;
|
||||||
list<Xapian::Query> orqueries;
|
list<Xapian::Query> orqueries;
|
||||||
|
bool hadmultiple = false;
|
||||||
|
string nolang, lang;
|
||||||
for (vector<string>::iterator it = splitData.terms.begin();
|
for (vector<string>::iterator it = splitData.terms.begin();
|
||||||
it != splitData.terms.end(); it++) {
|
it != splitData.terms.end(); it++) {
|
||||||
list<string>exp;
|
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,
|
orqueries.push_back(Xapian::Query(Xapian::Query::OP_OR,
|
||||||
exp.begin(), exp.end()));
|
exp.begin(), exp.end()));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user