added dynamic clauses to adv search. Still needs work
This commit is contained in:
+185
-106
@@ -21,7 +21,7 @@
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout12</cstring>
|
||||
<cstring>layout18</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
@@ -29,146 +29,225 @@
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout11</cstring>
|
||||
<cstring>layout17</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel2</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Plain</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search for files<br>having all of:</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>All non blank fields will be combined with AND conjunctions. <br>All fields except "exact phrase" can accept a mix of simple words, and phrases enclosed in double quotes.<br>There are two <em>Any of these</em> fields so you can search for things like: <br><em>(apple OR pear) AND (green OR sour)</em></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout10</cstring>
|
||||
<cstring>layout16</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>andWordsTL</cstring>
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>All of these</string>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>andWordsLE</cstring>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
<width>20</width>
|
||||
<height>40</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">
|
||||
</spacer>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>phraseTL</cstring>
|
||||
<cstring>textLabel2</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Plain</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>This exact phrase</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>phraseLE</cstring>
|
||||
<string>Search for files<br>having all of:</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words.</string>
|
||||
<string>All non blank fields will be combined with AND conjunctions. <br>All fields except "exact phrase" can accept a mix of simple words, and phrases enclosed in double quotes.<br>There are two <em>Any of these</em> fields so you can search for things like: <br><em>(apple OR pear) AND (green OR sour)</em></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>orWordsTL</cstring>
|
||||
<cstring>spacer2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addClausePB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these</string>
|
||||
<string>Add clause</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="2" column="1">
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>clauseVBox</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>orWordsLE</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter words, and/or quoted phrases.</string>
|
||||
<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="QLabel" row="3" column="0">
|
||||
<widget class="Line">
|
||||
<property name="name">
|
||||
<cstring>orWords1TL</cstring>
|
||||
<cstring>line4</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these</string>
|
||||
<property name="frameShape">
|
||||
<enum>HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</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>
|
||||
</vbox>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
@@ -385,7 +464,7 @@
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout18</cstring>
|
||||
<cstring>layoutFT</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
@@ -465,7 +544,7 @@
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout25</cstring>
|
||||
<cstring>layout26</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.5 2006-11-13 08:58:47 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.6 2006-11-14 13:55:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -74,6 +74,7 @@ void AdvSearch::init()
|
||||
this, SLOT(addAFiltypPB_clicked()));
|
||||
connect(saveFileTypesPB, SIGNAL(clicked()),
|
||||
this, SLOT(saveFileTypes()));
|
||||
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
||||
|
||||
// Initialize lists of accepted and ignored mime types from config
|
||||
// and settings
|
||||
@@ -132,6 +133,19 @@ void AdvSearch::saveFileTypes()
|
||||
rwSettings(true);
|
||||
}
|
||||
|
||||
void AdvSearch::addClause()
|
||||
{
|
||||
SearchClauseW *w = new SearchClauseW(this);
|
||||
m_clauseWins.push_back(w);
|
||||
connect(w->wordsLE, SIGNAL(returnPressed()),
|
||||
this, SLOT(searchPB_clicked()));
|
||||
clauseVBox->insertWidget(-1, w);
|
||||
w->show();
|
||||
// Have to adjust the size else we lose the bottom buttons! Why?
|
||||
QSize sz = AdvSearchBaseLayout->sizeHint();
|
||||
resize(QSize(sz.width()+20, sz.height()+40));
|
||||
}
|
||||
|
||||
// Move selected file types from the ignored to the searched box
|
||||
void AdvSearch::addFiltypPB_clicked()
|
||||
{
|
||||
@@ -208,7 +222,17 @@ void AdvSearch::searchPB_clicked()
|
||||
(const char *)phraseLE->text().utf8(), 0));
|
||||
hasnotnot = true;
|
||||
}
|
||||
|
||||
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;
|
||||
default: hasnotnot = true; break;
|
||||
}
|
||||
sdata->addClause(cl);
|
||||
}
|
||||
}
|
||||
if (!hasnotnot) {
|
||||
if (!hasnot)
|
||||
return;
|
||||
@@ -248,4 +272,3 @@ void AdvSearch::browsePB_clicked()
|
||||
QString dir = QFileDialog::getExistingDirectory();
|
||||
subtreeCMB->setEditText(dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef _ADVSEARCH_W_H_INCLUDED_
|
||||
#define _ADVSEARCH_W_H_INCLUDED_
|
||||
/* @(#$Id: advsearch_w.h,v 1.3 2006-11-13 08:58:47 dockes Exp $ (C) 2005 J.F.Dockes */
|
||||
/* @(#$Id: advsearch_w.h,v 1.4 2006-11-14 13:55:43 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
|
||||
@@ -17,12 +17,13 @@
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <list>
|
||||
#include <qvariant.h>
|
||||
#include <qdialog.h>
|
||||
#include "advsearch.h"
|
||||
#include "refcntr.h"
|
||||
|
||||
#include "searchclause_w.h"
|
||||
#include "recoll.h"
|
||||
#include "refcntr.h"
|
||||
#include "searchdata.h"
|
||||
|
||||
class AdvSearch : public AdvSearchBase
|
||||
@@ -30,7 +31,7 @@ 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)
|
||||
AdvSearch(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0) : AdvSearchBase(parent,name,modal,fl)
|
||||
{init();}
|
||||
~AdvSearch(){}
|
||||
public slots:
|
||||
@@ -38,17 +39,18 @@ public slots:
|
||||
virtual void delAFiltypPB_clicked();
|
||||
virtual void addFiltypPB_clicked();
|
||||
virtual void addAFiltypPB_clicked();
|
||||
virtual void restrictFtCB_toggled( bool on );
|
||||
virtual void restrictFtCB_toggled(bool on);
|
||||
virtual void searchPB_clicked();
|
||||
virtual void browsePB_clicked();
|
||||
virtual void saveFileTypes();
|
||||
virtual void addClause();
|
||||
|
||||
signals:
|
||||
void startSearch(RefCntr<Rcl::SearchData>);
|
||||
|
||||
private:
|
||||
virtual void init();
|
||||
|
||||
std::list<SearchClauseW *> m_clauseWins;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.6 2006-11-13 08:58:47 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.7 2006-11-14 13:55:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -317,8 +317,7 @@ static string urltolocalpath(string url)
|
||||
return url.substr(7, string::npos);
|
||||
}
|
||||
|
||||
// Execute an advanced search query. The parameters normally come from
|
||||
// the advanced search dialog
|
||||
// Start a db query and set the reslist docsource
|
||||
void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
{
|
||||
LOGDEB(("RclMain::startAdvSearch\n"));
|
||||
@@ -340,8 +339,11 @@ void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
if (!prefs.queryStemLang.length() == 0)
|
||||
qopts |= Rcl::Db::QO_STEM;
|
||||
|
||||
if (!rcldb->setQuery(sdata, qopts, prefs.queryStemLang.ascii()))
|
||||
if (!rcldb->setQuery(sdata, qopts, prefs.queryStemLang.ascii())) {
|
||||
QMessageBox::warning(0, "Recoll", tr("Cant start query: ") +
|
||||
QString::fromAscii(rcldb->getReason().c_str()));
|
||||
return;
|
||||
}
|
||||
curPreview = 0;
|
||||
|
||||
DocSequence *docsource;
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
#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";
|
||||
#endif
|
||||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "searchclause_w.h"
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qspinbox.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtooltip.h>
|
||||
#include <qwhatsthis.h>
|
||||
|
||||
/*
|
||||
* Constructs a SearchClauseW as a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'.
|
||||
*/
|
||||
SearchClauseW::SearchClauseW(QWidget* parent, const char* name, WFlags fl)
|
||||
: QWidget(parent, name, fl)
|
||||
{
|
||||
if (!name)
|
||||
setName("SearchClauseW");
|
||||
searchClauseLayout = new QVBoxLayout(this);
|
||||
|
||||
hLayout = new QHBoxLayout(0, 0, 6, "hLayout");
|
||||
|
||||
sTpCMB = new QComboBox(FALSE, this, "sTpCMB");
|
||||
hLayout->addWidget(sTpCMB);
|
||||
|
||||
proxSlackSB = new QSpinBox(this, "proxSlackSB");
|
||||
hLayout->addWidget(proxSlackSB);
|
||||
|
||||
wordsLE = new QLineEdit(this, "wordsLE");
|
||||
wordsLE->setMinimumSize(QSize(250, 0));
|
||||
hLayout->addWidget(wordsLE);
|
||||
searchClauseLayout->addLayout(hLayout);
|
||||
languageChange();
|
||||
resize(QSize(0, 0).expandedTo(minimumSizeHint()));
|
||||
clearWState(WState_Polished);
|
||||
|
||||
connect(sTpCMB, SIGNAL(activated(int)),
|
||||
this, SLOT(tpChange(int)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
SearchClauseW::~SearchClauseW()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the strings of the subwidgets using the current
|
||||
* language.
|
||||
*/
|
||||
void SearchClauseW::languageChange()
|
||||
{
|
||||
setCaption(tr("SearchClauseW"));
|
||||
sTpCMB->clear();
|
||||
sTpCMB->insertItem(tr("Any of these")); // 0
|
||||
sTpCMB->insertItem(tr("All of these")); //1
|
||||
sTpCMB->insertItem(tr("None of these"));//2
|
||||
sTpCMB->insertItem(tr("This phrase"));//3
|
||||
sTpCMB->insertItem(tr("Terms in proximity"));//4
|
||||
sTpCMB->insertItem(tr("File name matching"));//5
|
||||
// sTpCMB->insertItem(tr("Complex clause"));//6
|
||||
|
||||
// Ensure that the spinbox will be enabled/disabled depending on
|
||||
// combobox state
|
||||
tpChange(0);
|
||||
|
||||
QToolTip::add(sTpCMB, tr("Select the type of query that will be performed with the words"));
|
||||
QToolTip::add(proxSlackSB, tr("Number of additional words that may be interspersed with the chosen ones"));
|
||||
}
|
||||
|
||||
using namespace Rcl;
|
||||
|
||||
// Translate my window state into an Rcl search clause
|
||||
SearchDataClause *
|
||||
SearchClauseW::getClause()
|
||||
{
|
||||
if (wordsLE->text().isEmpty())
|
||||
return 0;
|
||||
switch (sTpCMB->currentItem()) {
|
||||
case 0:
|
||||
return new SearchDataClauseSimple(SCLT_OR,
|
||||
(const char *)wordsLE->text().utf8());
|
||||
case 1:
|
||||
return new SearchDataClauseSimple(SCLT_AND,
|
||||
(const char *)wordsLE->text().utf8());
|
||||
case 2:
|
||||
return new SearchDataClauseSimple(SCLT_EXCL,
|
||||
(const char *)wordsLE->text().utf8());
|
||||
case 3:
|
||||
return new SearchDataClauseDist(SCLT_PHRASE,
|
||||
(const char *)wordsLE->text().utf8(),
|
||||
proxSlackSB->value());
|
||||
case 4:
|
||||
fprintf(stderr, "NEAR\n");
|
||||
return new SearchDataClauseDist(SCLT_NEAR,
|
||||
(const char *)wordsLE->text().utf8(),
|
||||
proxSlackSB->value());
|
||||
case 5:
|
||||
return new SearchDataClauseFilename((const char *)wordsLE->text().utf8());
|
||||
case 6:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle combobox change: may need to enable/disable the distance spinbox
|
||||
void SearchClauseW::tpChange(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 3:
|
||||
case 4:
|
||||
proxSlackSB->setEnabled(true);
|
||||
if (index == 4)
|
||||
proxSlackSB->setValue(10);
|
||||
break;
|
||||
default:
|
||||
proxSlackSB->setEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef SEARCHCLAUSE_H
|
||||
#define SEARCHCLAUSE_H
|
||||
// A class for entry of a search clause: type (OR/AND/etc.), distance
|
||||
// for PHRASE or NEAR, and text
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <qwidget.h>
|
||||
#include "searchdata.h"
|
||||
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class QComboBox;
|
||||
class QSpinBox;
|
||||
class QLineEdit;
|
||||
|
||||
class SearchClauseW : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SearchClauseW( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~SearchClauseW();
|
||||
Rcl::SearchDataClause *getClause();
|
||||
|
||||
QComboBox* sTpCMB;
|
||||
QSpinBox* proxSlackSB;
|
||||
QLineEdit* wordsLE;
|
||||
|
||||
protected:
|
||||
QVBoxLayout* searchClauseLayout;
|
||||
QHBoxLayout* hLayout;
|
||||
|
||||
protected slots:
|
||||
virtual void languageChange();
|
||||
virtual void tpChange(int);
|
||||
};
|
||||
|
||||
#endif // SEARCHCLAUSE_H
|
||||
Reference in New Issue
Block a user