avoid generating abstracts before theyre needed (ie: not during sort). have the sort tools redisplay the results when sort criteria are applied

This commit is contained in:
dockes 2006-12-05 15:23:50 +00:00
parent a6018c428a
commit 9a7d469e18
9 changed files with 102 additions and 88 deletions

View File

@ -506,7 +506,7 @@
<cstring>dismissPB</cstring>
</property>
<property name="text">
<string>Dismiss</string>
<string>Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.55 2006-12-04 09:56:26 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: main.cpp,v 1.56 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -91,11 +91,6 @@ bool maybeOpenDb(string &reason, bool force)
}
int qopts = Rcl::Db::QO_NONE;
if (prefs.queryBuildAbstract) {
qopts |= Rcl::Db::QO_BUILD_ABSTRACT;
if (prefs.queryReplaceAbstract)
qopts |= Rcl::Db::QO_REPLACE_ABSTRACT;
}
if (prefs.queryStemLang.length() > 0)
qopts |= Rcl::Db::QO_STEM;
if (force)

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.11 2006-12-04 09:56:26 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.12 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -101,11 +101,11 @@ void RclMain::init()
resList->setFont(nfont);
}
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>)));
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
// signals and slots connections
connect(sSearch, SIGNAL(clearSearch()),
resList, SLOT(resetSearch()));
this, SLOT(resetSearch()));
connect(prevPageAction, SIGNAL(activated()),
resList, SLOT(resultPageBack()));
connect(nextPageAction, SIGNAL(activated()),
@ -165,9 +165,7 @@ void RclMain::init()
// created over the main form).
bool RclMain::close(bool)
{
prefs.mainwidth = width();
prefs.mainheight = height();
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
LOGDEB(("RclMain::close\n"));
fileExit();
return false;
}
@ -261,6 +259,9 @@ static const char *eventTypeToStr(int tp)
void RclMain::fileExit()
{
LOGDEB1(("RclMain: fileExit\n"));
prefs.mainwidth = width();
prefs.mainheight = height();
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
if (asearchform)
delete asearchform;
// Let the exit handler clean up things
@ -337,9 +338,9 @@ static string urltolocalpath(string url)
}
// Start a db query and set the reslist docsource
void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
{
LOGDEB(("RclMain::startAdvSearch\n"));
LOGDEB(("RclMain::startSearch\n"));
// The db may have been closed at the end of indexing
string reason;
if (!maybeOpenDb(reason)) {
@ -350,11 +351,6 @@ void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
resList->resetSearch();
int qopts = 0;
if (prefs.queryBuildAbstract && !sdata->fileNameOnly()) {
qopts |= Rcl::Db::QO_BUILD_ABSTRACT;
if (prefs.queryReplaceAbstract)
qopts |= Rcl::Db::QO_REPLACE_ABSTRACT;
}
if (!prefs.queryStemLang.length() == 0)
qopts |= Rcl::Db::QO_STEM;
@ -364,17 +360,31 @@ void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
return;
}
curPreview = 0;
m_searchData = sdata;
m_docSource = RefCntr<DocSequence>(new DocSequenceDb(rcldb, string(tr("Query results").utf8())));
setDocSequence();
}
DocSequence *docsource;
if (sortspecs.sortwidth > 0) {
DocSequenceDb myseq(rcldb, string(tr("Query results").utf8()));
docsource = new DocSeqSorted(myseq, sortspecs,
string(tr("Query results (sorted)").utf8()));
void RclMain::resetSearch()
{
resList->resetSearch();
m_searchData = RefCntr<Rcl::SearchData>();
}
void RclMain::setDocSequence()
{
if (m_searchData.getcnt() == 0)
return;
RefCntr<DocSequence> docsource;
if (m_sortspecs.sortwidth > 0) {
docsource = RefCntr<DocSequence>(new DocSeqSorted(m_docSource,
m_sortspecs,
string(tr("Query results (sorted)").utf8())));
} else {
docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8()));
docsource = m_docSource;
}
m_searchId++;
resList->setDocSource(docsource, sdata);
resList->setDocSource(docsource, m_searchData);
}
// Open advanced search dialog.
@ -383,7 +393,7 @@ void RclMain::showAdvSearchDialog()
if (asearchform == 0) {
asearchform = new AdvSearch(0);
connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>)));
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
asearchform->show();
} else {
// Close and reopen, in hope that makes us visible...
@ -398,6 +408,8 @@ void RclMain::showSortDialog()
sortform = new SortForm(0);
connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)),
this, SLOT(sortDataChanged(DocSeqSortSpec)));
connect(sortform, SIGNAL(applySortData()),
this, SLOT(setDocSequence()));
sortform->show();
} else {
// Close and reopen, in hope that makes us visible...
@ -722,31 +734,24 @@ void RclMain::showDocHistory()
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
exit(1);
}
// Construct a bogus SearchData structure
m_searchData =
RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND));
m_searchData->setDescription((const char *)tr("History data").utf8());
DocSequence *docsource;
if (sortspecs.sortwidth > 0) {
DocSequenceHistory myseq(rcldb, g_dynconf,
string(tr("Document history").utf8()));
docsource = new
DocSeqSorted(myseq, sortspecs,
string(tr("Document history (sorted)").utf8()));
} else {
docsource = new
DocSequenceHistory(rcldb, g_dynconf,
string(tr("Document history").utf8()));
}
// Construct a bogus SearchData
RefCntr<Rcl::SearchData> sdata(new Rcl::SearchData(Rcl::SCLT_AND));
sdata->setDescription((const char *)tr("History data").utf8());
m_searchId++;
resList->setDocSource(docsource, sdata);
m_docSource = RefCntr<DocSequence>(new DocSequenceHistory(rcldb,
g_dynconf,
string(tr("Document history").utf8())));
setDocSequence();
}
void RclMain::sortDataChanged(DocSeqSortSpec spec)
{
LOGDEB(("RclMain::sortDataChanged\n"));
sortspecs = spec;
m_sortspecs = spec;
}
// Called when the uiprefs dialog is ok'd

View File

@ -70,7 +70,8 @@ public slots:
virtual void fileExit();
virtual void periodic100();
virtual void startIndexing();
virtual void startAdvSearch(RefCntr<Rcl::SearchData> sdata);
virtual void startSearch(RefCntr<Rcl::SearchData> sdata);
virtual void setDocSequence();
virtual void previewClosed(QWidget * w);
virtual void showAdvSearchDialog();
virtual void showSortDialog();
@ -90,6 +91,7 @@ public slots:
virtual void previewNextInTab(int sid, int docnum);
virtual void previewPrevInTab(int sid, int docnum);
virtual void previewExposed(int sid, int docnum);
virtual void resetSearch();
private:
Preview *curPreview;
@ -98,9 +100,13 @@ private:
UIPrefsDialog *uiprefs;
SpellW *spellform;
DocSeqSortSpec sortspecs;
int m_searchId; // Serial number of current search for this process.
// Used to match to preview windows
RefCntr<Rcl::SearchData> m_searchData;
DocSeqSortSpec m_sortspecs;
RefCntr<DocSequence> m_docSource;
// Serial number of current search for this process.
// Used to match to preview windows
int m_searchId;
virtual void init();
};

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.14 2006-12-04 06:19:11 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.15 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@ -65,15 +65,18 @@ ResList::ResList(QWidget* parent, const char* name)
connect(this, SIGNAL(doubleClicked(int,int)),
this, SLOT(doubleClicked(int, int)));
m_winfirst = -1;
m_docsource = 0;
m_curPvDoc = -1;
m_lstClckMod = 0;
}
ResList::~ResList()
{
if (m_docsource)
delete m_docsource;
}
void ResList::resetSearch()
{
m_winfirst = -1;
clear();
}
void ResList::languageChange()
@ -82,13 +85,11 @@ void ResList::languageChange()
}
// Acquire new docsource
void ResList::setDocSource(DocSequence *docsource,
void ResList::setDocSource(RefCntr<DocSequence> docsource,
RefCntr<Rcl::SearchData> sdt)
{
if (m_docsource)
delete m_docsource;
m_winfirst = -1;
m_docsource = docsource;
m_docSource = docsource;
m_searchData = sdt;
m_curPvDoc = -1;
@ -185,9 +186,9 @@ void ResList::contentsMouseReleaseEvent(QMouseEvent *e)
// Return total result list count
int ResList::getResCnt()
{
if (!m_docsource)
if (m_docSource.getcnt() == 0)
return -1;
return m_docsource->getResCnt();
return m_docSource->getResCnt();
}
@ -248,10 +249,10 @@ static string displayableBytes(long size)
// Fill up result list window with next screen of hits
void ResList::resultPageNext()
{
if (!m_docsource)
if (m_docSource.getcnt() == 0)
return;
int resCnt = m_docsource->getResCnt();
int resCnt = m_docSource->getResCnt();
m_pageParaToReldocnums.clear();
LOGDEB(("resultPageNext: rescnt %d, winfirst %d\n", resCnt,
@ -302,7 +303,7 @@ void ResList::resultPageNext()
string sh;
Rcl::Doc doc;
int percent;
if (!m_docsource->getDoc(m_winfirst + i, doc, &percent, &sh)) {
if (!m_docSource->getDoc(m_winfirst + i, doc, &percent, &sh)) {
// Error or end of docs, stop.
break;
}
@ -323,7 +324,7 @@ void ResList::resultPageNext()
QString chunk = "<qt><head></head><body><p>";
chunk += "<font size=+1><b>";
chunk += QString::fromUtf8(m_docsource->title().c_str());
chunk += QString::fromUtf8(m_docSource->title().c_str());
chunk += ".</b></font>";
chunk += "&nbsp;&nbsp;&nbsp;";
@ -404,9 +405,21 @@ void ResList::resultPageNext()
sizebuf = displayableBytes(fsize);
}
// Abstract
string abst;
plaintorich(doc.abstract, abst, m_searchData, true);
// Abstract. The docsequence should deal with this as we don't
// know if a query is open or if we're displaying
// history. OTOH, if the docsequence does it, we're going to
// generate a lot of unneeded abstracts for sorted sequences
// (for all the queried for but undisplayed entries)
string richabst;
string abstract;
if (m_searchData->clauseCount() > 0 && prefs.queryBuildAbstract &&
(doc.syntabs || prefs.queryReplaceAbstract)) {
rcldb->makeDocAbstract(doc, abstract);
} else {
abstract = doc.abstract;
}
plaintorich(doc.abstract, richabst, m_searchData, true);
// Links;
string linksbuf;
@ -436,7 +449,7 @@ void ResList::resultPageNext()
// Configurable stuff
map<char,string> subs;
subs['A'] = !abst.empty() ? abst + "<br>" : "";
subs['A'] = !richabst.empty() ? richabst + "<br>" : "";
subs['D'] = datebuf;
subs['K'] = !doc.keywords.empty() ? doc.keywords + "<br>" : "";
subs['L'] = linksbuf;
@ -489,7 +502,7 @@ void ResList::resultPageNext()
} else {
// Restore first in win parameter that we shouln't have incremented
QString chunk = "<p><font size=+1><b>";
chunk += QString::fromUtf8(m_docsource->title().c_str());
chunk += QString::fromUtf8(m_docSource->title().c_str());
chunk += "</b></font><br>";
chunk += "<a href=\"H-1\">";
chunk += tr("Show query details");

View File

@ -1,6 +1,6 @@
#ifndef _RESLIST_H_INCLUDED_
#define _RESLIST_H_INCLUDED_
/* @(#$Id: reslist.h,v 1.5 2006-12-04 06:19:11 dockes Exp $ (C) 2005 J.F.Dockes */
/* @(#$Id: reslist.h,v 1.6 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes */
#include <list>
@ -40,7 +40,7 @@ class ResList : public QTEXTBROWSER
// num is inside the current page or its immediate neighbours.
virtual bool getDoc(int docnum, Rcl::Doc &);
virtual void setDocSource(DocSequence *,
virtual void setDocSource(RefCntr<DocSequence> source,
RefCntr<Rcl::SearchData> qdata);
virtual RCLPOPUP *createPopupMenu(const QPoint& pos);
virtual QString getDescription(); // Printable actual query performed on db
@ -48,7 +48,7 @@ class ResList : public QTEXTBROWSER
virtual RefCntr<Rcl::SearchData> getSearchData() {return m_searchData;}
public slots:
virtual void resetSearch() {m_winfirst = -1;clear();}
virtual void resetSearch();
virtual void clicked(int, int);
virtual void doubleClicked(int, int);
virtual void resPageUpOrBack(); // Page up pressed
@ -82,10 +82,10 @@ class ResList : public QTEXTBROWSER
virtual void showQueryDetails();
private:
std::map<int,int> m_pageParaToReldocnums;
std::map<int,int> m_pageParaToReldocnums;
RefCntr<Rcl::SearchData> m_searchData;
DocSequence *m_docsource;
std::vector<Rcl::Doc> m_curDocs;
RefCntr<DocSequence> m_docSource;
std::vector<Rcl::Doc> m_curDocs;
int m_winfirst;
int m_popDoc; // Docnum for the popup menu.
int m_curPvDoc;// Docnum for current preview

View File

@ -135,13 +135,13 @@
</property>
<widget class="QPushButton">
<property name="name">
<cstring>resetPB</cstring>
<cstring>applyPB</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Reset</string>
<string>Apply</string>
</property>
</widget>
<widget class="QPushButton">

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: sort_w.cpp,v 1.3 2006-12-04 08:17:24 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: sort_w.cpp,v 1.4 2006-12-05 15:23:50 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -67,7 +67,7 @@ void SortForm::init()
sortCB->setChecked(false);
// signals and slots connections
connect(resetPB, SIGNAL(clicked()), this, SLOT(reset()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(apply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
connect(mcntSB, SIGNAL(valueChanged(int)), this, SLOT(setData()));
connect(fldCMB1, SIGNAL(activated(const QString&)), this, SLOT(setData()));
@ -77,15 +77,10 @@ void SortForm::init()
connect(sortCB, SIGNAL(toggled(bool)), this, SLOT(setData()));
}
void SortForm::reset()
void SortForm::apply()
{
mcntSB->setValue(100);
fldCMB1->setCurrentItem(0);
fldCMB2->setCurrentItem(0);
descCB1->setChecked(false);
descCB1->setChecked(false);
sortCB->setChecked(false);
setData();
emit applySortData();
}
void SortForm::setData()

View File

@ -1,4 +1,4 @@
/* @(#$Id: sort_w.h,v 1.4 2006-12-04 09:56:26 dockes Exp $ (C) 2005 J.F.Dockes */
/* @(#$Id: sort_w.h,v 1.5 2006-12-05 15:23:50 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
@ -57,12 +57,12 @@ public:
public slots:
virtual void reset();
virtual void apply();
virtual void setData();
signals:
void sortDataChanged(DocSeqSortSpec);
void applySortData();
private:
virtual void init();
};