most of adv search working. Still need subtree/filename filters
This commit is contained in:
@@ -413,7 +413,7 @@
|
||||
<include location="local" impldecl="in implementation">advsearch.ui.h</include>
|
||||
</includes>
|
||||
<signals>
|
||||
<signal>startSearch(AdvSearchData)</signal>
|
||||
<signal>startSearch(Rcl::AdvSearchData)</signal>
|
||||
</signals>
|
||||
<slots>
|
||||
<slot>delFiltypPB_clicked()</slot>
|
||||
|
||||
@@ -91,14 +91,14 @@ void advsearch::restrictFtCB_toggled(bool on)
|
||||
|
||||
void advsearch::searchPB_clicked()
|
||||
{
|
||||
AdvSearchData mydata;
|
||||
Rcl::AdvSearchData mydata;
|
||||
mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
|
||||
mydata.phrase = string((const char*)(phraseLE->text().utf8()));
|
||||
mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
|
||||
mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
|
||||
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
|
||||
for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
|
||||
QCString ctext = noFiltypsLB->item(i)->text().utf8();
|
||||
QCString ctext = yesFiltypsLB->item(i)->text().utf8();
|
||||
mydata.filetypes.push_back(string((const char *)ctext));
|
||||
}
|
||||
}
|
||||
|
||||
+36
-3
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.9 2005-10-10 12:29:42 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.10 2005-10-19 10:21:48 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -10,8 +10,9 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.9 2005-10-10 12:29:42 dockes Exp $ (
|
||||
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include "recollmain.h"
|
||||
#include "rcldb.h"
|
||||
using Rcl::AdvSearchData;
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "pathut.h"
|
||||
#include "recoll.h"
|
||||
@@ -19,11 +20,43 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.9 2005-10-10 12:29:42 dockes Exp $ (
|
||||
#include "wipedir.h"
|
||||
#include "rclinit.h"
|
||||
|
||||
#include "recollmain.h"
|
||||
|
||||
RclConfig *rclconfig;
|
||||
Rcl::Db *rcldb;
|
||||
int recollNeedsExit;
|
||||
string tmpdir;
|
||||
|
||||
void getQueryStemming(bool &dostem, std::string &stemlang)
|
||||
{
|
||||
string param;
|
||||
if (rclconfig->getConfParam("querystemming", param))
|
||||
dostem = ConfTree::stringToBool(param);
|
||||
else
|
||||
dostem = false;
|
||||
if (!rclconfig->getConfParam("querystemminglanguage", stemlang))
|
||||
stemlang = "english";
|
||||
}
|
||||
|
||||
bool maybeOpenDb(string &reason)
|
||||
{
|
||||
if (!rcldb)
|
||||
return false;
|
||||
if (!rcldb->isopen()) {
|
||||
string dbdir;
|
||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
reason = "No db directory in configuration";
|
||||
return false;
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
|
||||
reason = "Could not open database in " +
|
||||
dbdir + " wait for indexing to complete?";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void recollCleanup()
|
||||
{
|
||||
@@ -86,7 +119,7 @@ int main( int argc, char ** argv )
|
||||
|
||||
rcldb = new Rcl::Db;
|
||||
|
||||
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
|
||||
if (!rcldb || !rcldb->open(dbdir, Rcl::Db::DbRO)) {
|
||||
startindexing = 1;
|
||||
QMessageBox::information(0, "Recoll",
|
||||
QString("Could not open database in ") +
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.3 2005-10-19 10:21:48 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
+7
-14
@@ -1,29 +1,22 @@
|
||||
#ifndef _RECOLL_H_INCLUDED_
|
||||
#define _RECOLL_H_INCLUDED_
|
||||
/* @(#$Id: recoll.h,v 1.3 2005-10-17 13:36:53 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: recoll.h,v 1.4 2005-10-19 10:21:48 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "rclconfig.h"
|
||||
#include "rcldb.h"
|
||||
#include "idxthread.h"
|
||||
|
||||
extern void recollCleanup();
|
||||
|
||||
// Misc declarations in need of sharing between the UI files
|
||||
|
||||
extern void recollCleanup();
|
||||
extern bool maybeOpenDb(std::string &reason);
|
||||
extern void getQueryStemming(bool &dostem, std::string &stemlang);
|
||||
|
||||
extern RclConfig *rclconfig;
|
||||
extern Rcl::Db *rcldb;
|
||||
extern string tmpdir;
|
||||
extern std::string tmpdir;
|
||||
|
||||
extern int recollNeedsExit;
|
||||
|
||||
// Holder for data collected by the advanced search dialog
|
||||
struct AdvSearchData {
|
||||
std::string allwords;
|
||||
std::string phrase;
|
||||
std::string orwords;
|
||||
std::string nowords;
|
||||
std::list<std::string> filetypes; // restrict to types. Empty if inactive
|
||||
std::string topdir; // restrict to subtree. Empty if inactive
|
||||
};
|
||||
|
||||
#endif /* _RECOLL_H_INCLUDED_ */
|
||||
|
||||
@@ -282,6 +282,7 @@
|
||||
<includes>
|
||||
<include location="local" impldecl="in declaration">preview/.ui/preview.h</include>
|
||||
<include location="local" impldecl="in declaration">recoll.h</include>
|
||||
<include location="local" impldecl="in declaration">advsearch.h</include>
|
||||
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
|
||||
</includes>
|
||||
<variables>
|
||||
@@ -290,6 +291,7 @@
|
||||
<variable>bool dostem;</variable>
|
||||
<variable>std::string stemlang;</variable>
|
||||
<variable>Preview *curPreview;</variable>
|
||||
<variable>advsearch *asearchform;</variable>
|
||||
</variables>
|
||||
<slots>
|
||||
<slot>fileExit()</slot>
|
||||
@@ -304,7 +306,7 @@
|
||||
<slot>listNextPB_clicked()</slot>
|
||||
<slot>advSearchPB_clicked()</slot>
|
||||
<slot>previewClosed( Preview * w )</slot>
|
||||
<slot>startAdvSearch( AdvSearchData sdata )</slot>
|
||||
<slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot>
|
||||
</slots>
|
||||
<functions>
|
||||
<function access="private">init()</function>
|
||||
|
||||
+29
-50
@@ -32,6 +32,8 @@ using std::pair;
|
||||
#include "smallut.h"
|
||||
#include "plaintorich.h"
|
||||
#include "unacpp.h"
|
||||
#include "advsearch.h"
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
@@ -45,6 +47,7 @@ static const int respagesize = 8;
|
||||
void RecollMain::init()
|
||||
{
|
||||
curPreview = 0;
|
||||
asearchform = 0;
|
||||
}
|
||||
|
||||
// We want to catch ^Q everywhere to mean quit.
|
||||
@@ -266,31 +269,13 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
void RecollMain::queryText_returnPressed()
|
||||
{
|
||||
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
|
||||
if (!rcldb->isopen()) {
|
||||
string dbdir;
|
||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
QMessageBox::critical(0, "Recoll",
|
||||
QString("No db directory in configuration"));
|
||||
exit(1);
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
|
||||
QMessageBox::information(0, "Recoll",
|
||||
QString("Could not open database in ") +
|
||||
QString(dbdir) + " wait for indexing " +
|
||||
"to complete?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (stemlang.empty()) {
|
||||
string param;
|
||||
if (rclconfig->getConfParam("querystemming", param))
|
||||
dostem = ConfTree::stringToBool(param);
|
||||
else
|
||||
dostem = false;
|
||||
if (!rclconfig->getConfParam("querystemminglanguage", stemlang))
|
||||
stemlang = "english";
|
||||
string reason;
|
||||
if (!maybeOpenDb(reason)) {
|
||||
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
||||
return;
|
||||
}
|
||||
if (stemlang.empty())
|
||||
getQueryStemming(dostem, stemlang);
|
||||
|
||||
reslist_current = -1;
|
||||
reslist_winfirst = -1;
|
||||
@@ -388,7 +373,7 @@ void RecollMain::listNextPB_clicked()
|
||||
strftime(datebuf, 99, "<i>Modified:</i> %F %T", tm);
|
||||
}
|
||||
string abst = stripMarkup(doc.abstract);
|
||||
LOGDEB(("Abstract: {%s}\n", abst.c_str()));
|
||||
LOGDEB1(("Abstract: {%s}\n", abst.c_str()));
|
||||
string result = "<p>" +
|
||||
string(perbuf) + " <b>" + doc.title + "</b><br>" +
|
||||
doc.mimetype + " " +
|
||||
@@ -433,46 +418,40 @@ void RecollMain::previewClosed(Preview *w)
|
||||
delete w;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "advsearch.h"
|
||||
|
||||
advsearch *asearchform;
|
||||
|
||||
// Open advanced search dialog.
|
||||
void RecollMain::advSearchPB_clicked()
|
||||
{
|
||||
if (asearchform == 0) {
|
||||
// Couldn't find way to have a normal wm frame
|
||||
asearchform = new advsearch(this, "Advanced search", FALSE,
|
||||
WStyle_Customize | WStyle_NormalBorder |
|
||||
WStyle_Title | WStyle_SysMenu);
|
||||
asearchform->setSizeGripEnabled(FALSE);
|
||||
connect(asearchform, SIGNAL(startSearch(AdvSearchData)),
|
||||
this, SLOT(startAdvSearch(AdvSearchData)));
|
||||
connect(asearchform, SIGNAL(startSearch(Rcl::AdvSearchData)),
|
||||
this, SLOT(startAdvSearch(Rcl::AdvSearchData)));
|
||||
asearchform->show();
|
||||
} else {
|
||||
asearchform->show();
|
||||
}
|
||||
}
|
||||
|
||||
void RecollMain::startAdvSearch(AdvSearchData sdata)
|
||||
// Execute and advanced search query
|
||||
void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
|
||||
{
|
||||
LOGDEB(("RecollMain::startAdvSearch\n"));
|
||||
LOGDEB((" allwords: %s\n", sdata.allwords.c_str()));
|
||||
LOGDEB((" phrase: %s\n", sdata.phrase.c_str()));
|
||||
LOGDEB((" orwords: %s\n", sdata.orwords.c_str()));
|
||||
LOGDEB((" nowords: %s\n", sdata.nowords.c_str()));
|
||||
string ft;
|
||||
for (list<string>::iterator it = sdata.filetypes.begin();
|
||||
it != sdata.filetypes.end(); it++) {
|
||||
ft += *it + " ";
|
||||
string reason;
|
||||
if (!maybeOpenDb(reason)) {
|
||||
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
||||
return;
|
||||
}
|
||||
if (!ft.empty())
|
||||
LOGDEB(("Searched file types: %s\n", ft.c_str()));
|
||||
if (!sdata.topdir.empty())
|
||||
LOGDEB(("Restricted to: %s\n", sdata.topdir.c_str()));
|
||||
|
||||
if (stemlang.empty())
|
||||
getQueryStemming(dostem, stemlang);
|
||||
|
||||
reslist_current = -1;
|
||||
reslist_winfirst = -1;
|
||||
|
||||
if (!rcldb->setQuery(sdata, stemlang))
|
||||
return;
|
||||
curPreview = 0;
|
||||
listNextPB_clicked();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user