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> <cstring>dismissPB</cstring>
</property> </property>
<property name="text"> <property name="text">
<string>Dismiss</string> <string>Close</string>
</property> </property>
<property name="autoDefault"> <property name="autoDefault">
<bool>false</bool> <bool>false</bool>

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #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
@ -91,11 +91,6 @@ bool maybeOpenDb(string &reason, bool force)
} }
int qopts = Rcl::Db::QO_NONE; 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) if (prefs.queryStemLang.length() > 0)
qopts |= Rcl::Db::QO_STEM; qopts |= Rcl::Db::QO_STEM;
if (force) if (force)

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #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
@ -101,11 +101,11 @@ void RclMain::init()
resList->setFont(nfont); resList->setFont(nfont);
} }
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)), connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>))); this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
// signals and slots connections // signals and slots connections
connect(sSearch, SIGNAL(clearSearch()), connect(sSearch, SIGNAL(clearSearch()),
resList, SLOT(resetSearch())); this, SLOT(resetSearch()));
connect(prevPageAction, SIGNAL(activated()), connect(prevPageAction, SIGNAL(activated()),
resList, SLOT(resultPageBack())); resList, SLOT(resultPageBack()));
connect(nextPageAction, SIGNAL(activated()), connect(nextPageAction, SIGNAL(activated()),
@ -165,9 +165,7 @@ void RclMain::init()
// created over the main form). // created over the main form).
bool RclMain::close(bool) bool RclMain::close(bool)
{ {
prefs.mainwidth = width(); LOGDEB(("RclMain::close\n"));
prefs.mainheight = height();
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
fileExit(); fileExit();
return false; return false;
} }
@ -261,6 +259,9 @@ static const char *eventTypeToStr(int tp)
void RclMain::fileExit() void RclMain::fileExit()
{ {
LOGDEB1(("RclMain: fileExit\n")); LOGDEB1(("RclMain: fileExit\n"));
prefs.mainwidth = width();
prefs.mainheight = height();
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
if (asearchform) if (asearchform)
delete asearchform; delete asearchform;
// Let the exit handler clean up things // 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 // 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 // The db may have been closed at the end of indexing
string reason; string reason;
if (!maybeOpenDb(reason)) { if (!maybeOpenDb(reason)) {
@ -350,11 +351,6 @@ void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
resList->resetSearch(); resList->resetSearch();
int qopts = 0; 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) if (!prefs.queryStemLang.length() == 0)
qopts |= Rcl::Db::QO_STEM; qopts |= Rcl::Db::QO_STEM;
@ -364,17 +360,31 @@ void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
return; return;
} }
curPreview = 0; curPreview = 0;
m_searchData = sdata;
m_docSource = RefCntr<DocSequence>(new DocSequenceDb(rcldb, string(tr("Query results").utf8())));
setDocSequence();
}
DocSequence *docsource; void RclMain::resetSearch()
if (sortspecs.sortwidth > 0) { {
DocSequenceDb myseq(rcldb, string(tr("Query results").utf8())); resList->resetSearch();
docsource = new DocSeqSorted(myseq, sortspecs, m_searchData = RefCntr<Rcl::SearchData>();
string(tr("Query results (sorted)").utf8())); }
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 { } else {
docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8())); docsource = m_docSource;
} }
m_searchId++; m_searchId++;
resList->setDocSource(docsource, sdata); resList->setDocSource(docsource, m_searchData);
} }
// Open advanced search dialog. // Open advanced search dialog.
@ -383,7 +393,7 @@ void RclMain::showAdvSearchDialog()
if (asearchform == 0) { if (asearchform == 0) {
asearchform = new AdvSearch(0); asearchform = new AdvSearch(0);
connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)), connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>))); this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
asearchform->show(); asearchform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
@ -398,6 +408,8 @@ void RclMain::showSortDialog()
sortform = new SortForm(0); sortform = new SortForm(0);
connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)), connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)),
this, SLOT(sortDataChanged(DocSeqSortSpec))); this, SLOT(sortDataChanged(DocSeqSortSpec)));
connect(sortform, SIGNAL(applySortData()),
this, SLOT(setDocSequence()));
sortform->show(); sortform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
@ -722,31 +734,24 @@ void RclMain::showDocHistory()
QMessageBox::critical(0, "Recoll", QString(reason.c_str())); QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
exit(1); 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++; 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) void RclMain::sortDataChanged(DocSeqSortSpec spec)
{ {
LOGDEB(("RclMain::sortDataChanged\n")); LOGDEB(("RclMain::sortDataChanged\n"));
sortspecs = spec; m_sortspecs = spec;
} }
// Called when the uiprefs dialog is ok'd // Called when the uiprefs dialog is ok'd

View File

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

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
#include <time.h> #include <time.h>
@ -65,15 +65,18 @@ ResList::ResList(QWidget* parent, const char* name)
connect(this, SIGNAL(doubleClicked(int,int)), connect(this, SIGNAL(doubleClicked(int,int)),
this, SLOT(doubleClicked(int, int))); this, SLOT(doubleClicked(int, int)));
m_winfirst = -1; m_winfirst = -1;
m_docsource = 0;
m_curPvDoc = -1; m_curPvDoc = -1;
m_lstClckMod = 0; m_lstClckMod = 0;
} }
ResList::~ResList() ResList::~ResList()
{ {
if (m_docsource) }
delete m_docsource;
void ResList::resetSearch()
{
m_winfirst = -1;
clear();
} }
void ResList::languageChange() void ResList::languageChange()
@ -82,13 +85,11 @@ void ResList::languageChange()
} }
// Acquire new docsource // Acquire new docsource
void ResList::setDocSource(DocSequence *docsource, void ResList::setDocSource(RefCntr<DocSequence> docsource,
RefCntr<Rcl::SearchData> sdt) RefCntr<Rcl::SearchData> sdt)
{ {
if (m_docsource)
delete m_docsource;
m_winfirst = -1; m_winfirst = -1;
m_docsource = docsource; m_docSource = docsource;
m_searchData = sdt; m_searchData = sdt;
m_curPvDoc = -1; m_curPvDoc = -1;
@ -185,9 +186,9 @@ void ResList::contentsMouseReleaseEvent(QMouseEvent *e)
// Return total result list count // Return total result list count
int ResList::getResCnt() int ResList::getResCnt()
{ {
if (!m_docsource) if (m_docSource.getcnt() == 0)
return -1; 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 // Fill up result list window with next screen of hits
void ResList::resultPageNext() void ResList::resultPageNext()
{ {
if (!m_docsource) if (m_docSource.getcnt() == 0)
return; return;
int resCnt = m_docsource->getResCnt(); int resCnt = m_docSource->getResCnt();
m_pageParaToReldocnums.clear(); m_pageParaToReldocnums.clear();
LOGDEB(("resultPageNext: rescnt %d, winfirst %d\n", resCnt, LOGDEB(("resultPageNext: rescnt %d, winfirst %d\n", resCnt,
@ -302,7 +303,7 @@ void ResList::resultPageNext()
string sh; string sh;
Rcl::Doc doc; Rcl::Doc doc;
int percent; 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. // Error or end of docs, stop.
break; break;
} }
@ -323,7 +324,7 @@ void ResList::resultPageNext()
QString chunk = "<qt><head></head><body><p>"; QString chunk = "<qt><head></head><body><p>";
chunk += "<font size=+1><b>"; 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 += ".</b></font>";
chunk += "&nbsp;&nbsp;&nbsp;"; chunk += "&nbsp;&nbsp;&nbsp;";
@ -404,9 +405,21 @@ void ResList::resultPageNext()
sizebuf = displayableBytes(fsize); sizebuf = displayableBytes(fsize);
} }
// Abstract // Abstract. The docsequence should deal with this as we don't
string abst; // know if a query is open or if we're displaying
plaintorich(doc.abstract, abst, m_searchData, true); // 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; // Links;
string linksbuf; string linksbuf;
@ -436,7 +449,7 @@ void ResList::resultPageNext()
// Configurable stuff // Configurable stuff
map<char,string> subs; map<char,string> subs;
subs['A'] = !abst.empty() ? abst + "<br>" : ""; subs['A'] = !richabst.empty() ? richabst + "<br>" : "";
subs['D'] = datebuf; subs['D'] = datebuf;
subs['K'] = !doc.keywords.empty() ? doc.keywords + "<br>" : ""; subs['K'] = !doc.keywords.empty() ? doc.keywords + "<br>" : "";
subs['L'] = linksbuf; subs['L'] = linksbuf;
@ -489,7 +502,7 @@ void ResList::resultPageNext()
} else { } else {
// Restore first in win parameter that we shouln't have incremented // Restore first in win parameter that we shouln't have incremented
QString chunk = "<p><font size=+1><b>"; 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 += "</b></font><br>";
chunk += "<a href=\"H-1\">"; chunk += "<a href=\"H-1\">";
chunk += tr("Show query details"); chunk += tr("Show query details");

View File

@ -1,6 +1,6 @@
#ifndef _RESLIST_H_INCLUDED_ #ifndef _RESLIST_H_INCLUDED_
#define _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> #include <list>
@ -40,7 +40,7 @@ class ResList : public QTEXTBROWSER
// num is inside the current page or its immediate neighbours. // num is inside the current page or its immediate neighbours.
virtual bool getDoc(int docnum, Rcl::Doc &); virtual bool getDoc(int docnum, Rcl::Doc &);
virtual void setDocSource(DocSequence *, virtual void setDocSource(RefCntr<DocSequence> source,
RefCntr<Rcl::SearchData> qdata); RefCntr<Rcl::SearchData> qdata);
virtual RCLPOPUP *createPopupMenu(const QPoint& pos); virtual RCLPOPUP *createPopupMenu(const QPoint& pos);
virtual QString getDescription(); // Printable actual query performed on db 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;} virtual RefCntr<Rcl::SearchData> getSearchData() {return m_searchData;}
public slots: public slots:
virtual void resetSearch() {m_winfirst = -1;clear();} virtual void resetSearch();
virtual void clicked(int, int); virtual void clicked(int, int);
virtual void doubleClicked(int, int); virtual void doubleClicked(int, int);
virtual void resPageUpOrBack(); // Page up pressed virtual void resPageUpOrBack(); // Page up pressed
@ -82,10 +82,10 @@ class ResList : public QTEXTBROWSER
virtual void showQueryDetails(); virtual void showQueryDetails();
private: private:
std::map<int,int> m_pageParaToReldocnums; std::map<int,int> m_pageParaToReldocnums;
RefCntr<Rcl::SearchData> m_searchData; RefCntr<Rcl::SearchData> m_searchData;
DocSequence *m_docsource; RefCntr<DocSequence> m_docSource;
std::vector<Rcl::Doc> m_curDocs; std::vector<Rcl::Doc> m_curDocs;
int m_winfirst; int m_winfirst;
int m_popDoc; // Docnum for the popup menu. int m_popDoc; // Docnum for the popup menu.
int m_curPvDoc;// Docnum for current preview int m_curPvDoc;// Docnum for current preview

View File

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

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #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
@ -67,7 +67,7 @@ void SortForm::init()
sortCB->setChecked(false); sortCB->setChecked(false);
// signals and slots connections // 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(closePB, SIGNAL(clicked()), this, SLOT(close()));
connect(mcntSB, SIGNAL(valueChanged(int)), this, SLOT(setData())); connect(mcntSB, SIGNAL(valueChanged(int)), this, SLOT(setData()));
connect(fldCMB1, SIGNAL(activated(const QString&)), 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())); 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(); setData();
emit applySortData();
} }
void SortForm::setData() 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 * 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
@ -57,12 +57,12 @@ public:
public slots: public slots:
virtual void reset(); virtual void apply();
virtual void setData(); virtual void setData();
signals: signals:
void sortDataChanged(DocSeqSortSpec); void sortDataChanged(DocSeqSortSpec);
void applySortData();
private: private:
virtual void init(); virtual void init();
}; };