Allow cancelling a long query (forces exiting the program because xapian provides no cancellation points)
This commit is contained in:
parent
57cd31636c
commit
4c3d728032
@ -49,6 +49,8 @@ using std::pair;
|
|||||||
#include <qcursor.h>
|
#include <qcursor.h>
|
||||||
#include <qevent.h>
|
#include <qevent.h>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
@ -247,8 +249,6 @@ void RclMain::init()
|
|||||||
this, SLOT(showUIPrefs()));
|
this, SLOT(showUIPrefs()));
|
||||||
connect(extIdxAction, SIGNAL(activated()),
|
connect(extIdxAction, SIGNAL(activated()),
|
||||||
this, SLOT(showExtIdxDialog()));
|
this, SLOT(showExtIdxDialog()));
|
||||||
connect(this, SIGNAL(applyFiltSortData()),
|
|
||||||
this, SLOT(onResultsChanged()));
|
|
||||||
|
|
||||||
if (prefs.catgToolBar && catgCMB)
|
if (prefs.catgToolBar && catgCMB)
|
||||||
connect(catgCMB, SIGNAL(activated(int)),
|
connect(catgCMB, SIGNAL(activated(int)),
|
||||||
@ -263,7 +263,7 @@ void RclMain::init()
|
|||||||
restable, SLOT(setDocSource(RefCntr<DocSequence>)));
|
restable, SLOT(setDocSource(RefCntr<DocSequence>)));
|
||||||
connect(this, SIGNAL(searchReset()),
|
connect(this, SIGNAL(searchReset()),
|
||||||
restable, SLOT(resetSource()));
|
restable, SLOT(resetSource()));
|
||||||
connect(this, SIGNAL(applyFiltSortData()),
|
connect(this, SIGNAL(resultsReady()),
|
||||||
restable, SLOT(readDocSource()));
|
restable, SLOT(readDocSource()));
|
||||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
@ -293,7 +293,7 @@ void RclMain::init()
|
|||||||
reslist, SLOT(resPageDownOrNext()));
|
reslist, SLOT(resPageDownOrNext()));
|
||||||
connect(this, SIGNAL(searchReset()),
|
connect(this, SIGNAL(searchReset()),
|
||||||
reslist, SLOT(resetList()));
|
reslist, SLOT(resetList()));
|
||||||
connect(this, SIGNAL(applyFiltSortData()),
|
connect(this, SIGNAL(resultsReady()),
|
||||||
reslist, SLOT(readDocSource()));
|
reslist, SLOT(readDocSource()));
|
||||||
|
|
||||||
connect(reslist, SIGNAL(hasResults(int)),
|
connect(reslist, SIGNAL(hasResults(int)),
|
||||||
@ -626,8 +626,6 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
|
||||||
|
|
||||||
string stemLang = (const char *)prefs.queryStemLang.toAscii();
|
string stemLang = (const char *)prefs.queryStemLang.toAscii();
|
||||||
if (stemLang == "ALL") {
|
if (stemLang == "ALL") {
|
||||||
theconfig->getConfParam("indexstemminglanguages", stemLang);
|
theconfig->getConfParam("indexstemminglanguages", stemLang);
|
||||||
@ -649,24 +647,76 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
|||||||
|
|
||||||
emit docSourceChanged(m_source);
|
emit docSourceChanged(m_source);
|
||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
emit applyFiltSortData();
|
initiateQuery();
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::onResultsChanged()
|
class QueryThread : public QThread {
|
||||||
{
|
int loglevel;
|
||||||
if (m_source.isNotNull()) {
|
RefCntr<DocSequence> m_source;
|
||||||
int cnt = m_source->getResCnt();
|
public:
|
||||||
QString msg;
|
QueryThread(RefCntr<DocSequence> source)
|
||||||
if (cnt > 0) {
|
: m_source(source)
|
||||||
QString str;
|
{
|
||||||
msg = tr("Result count (est.)") + ": " +
|
loglevel = DebugLog::getdbl()->getlevel();
|
||||||
str.setNum(cnt);
|
|
||||||
} else {
|
|
||||||
msg = tr("No results found");
|
|
||||||
}
|
|
||||||
statusBar()->showMessage(msg, 0);
|
|
||||||
}
|
}
|
||||||
|
~QueryThread() { }
|
||||||
|
virtual void run()
|
||||||
|
{
|
||||||
|
DebugLog::getdbl()->setloglevel(loglevel);
|
||||||
|
cnt = m_source->getResCnt();
|
||||||
|
}
|
||||||
|
int cnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RclMain::initiateQuery()
|
||||||
|
{
|
||||||
|
if (m_source.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
QueryThread qthr(m_source);
|
||||||
|
qthr.start();
|
||||||
|
|
||||||
|
QProgressDialog progress(this);
|
||||||
|
progress.setLabelText(tr("Query in progress.<br>"
|
||||||
|
"Due to limitations of the indexing library,<br>"
|
||||||
|
"cancelling will exit the program"));
|
||||||
|
progress.setWindowModality(Qt::WindowModal);
|
||||||
|
progress.setRange(0,0);
|
||||||
|
|
||||||
|
// For some reason setMinimumDuration() does not seem to work with
|
||||||
|
// a busy dialog (range 0,0) Have to call progress.show() inside
|
||||||
|
// the loop.
|
||||||
|
// progress.setMinimumDuration(2000);
|
||||||
|
// Also the multiple processEvents() seem to improve the responsiveness??
|
||||||
|
for (int i = 0;;i++) {
|
||||||
|
qApp->processEvents();
|
||||||
|
if (qthr.wait(100)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == 20)
|
||||||
|
progress.show();
|
||||||
|
qApp->processEvents();
|
||||||
|
if (progress.wasCanceled()) {
|
||||||
|
fileExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->processEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
int cnt = qthr.cnt;
|
||||||
|
QString msg;
|
||||||
|
if (cnt > 0) {
|
||||||
|
QString str;
|
||||||
|
msg = tr("Result count (est.)") + ": " +
|
||||||
|
str.setNum(cnt);
|
||||||
|
} else {
|
||||||
|
msg = tr("No results found");
|
||||||
|
}
|
||||||
|
|
||||||
|
statusBar()->showMessage(msg, 0);
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
emit(resultsReady());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::resetSearch()
|
void RclMain::resetSearch()
|
||||||
@ -1195,7 +1245,7 @@ void RclMain::onSortCtlChanged()
|
|||||||
if (m_source.isNotNull())
|
if (m_source.isNotNull())
|
||||||
m_source->setSortSpec(m_sortspec);
|
m_source->setSortSpec(m_sortspec);
|
||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
emit applyFiltSortData();
|
initiateQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::onSortDataChanged(DocSeqSortSpec spec)
|
void RclMain::onSortDataChanged(DocSeqSortSpec spec)
|
||||||
@ -1218,7 +1268,7 @@ void RclMain::onSortDataChanged(DocSeqSortSpec spec)
|
|||||||
prefs.sortDesc = spec.desc;
|
prefs.sortDesc = spec.desc;
|
||||||
prefs.sortActive = !spec.field.empty();
|
prefs.sortActive = !spec.field.empty();
|
||||||
|
|
||||||
emit applyFiltSortData();
|
initiateQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::on_actionShowResultsAsTable_toggled(bool on)
|
void RclMain::on_actionShowResultsAsTable_toggled(bool on)
|
||||||
@ -1582,7 +1632,7 @@ void RclMain::showDocHistory()
|
|||||||
m_source->setFiltSpec(m_filtspec);
|
m_source->setFiltSpec(m_filtspec);
|
||||||
emit docSourceChanged(m_source);
|
emit docSourceChanged(m_source);
|
||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
emit applyFiltSortData();
|
initiateQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase all memory of documents viewed
|
// Erase all memory of documents viewed
|
||||||
@ -1669,7 +1719,7 @@ void RclMain::catgFilter(int id)
|
|||||||
}
|
}
|
||||||
if (m_source.isNotNull())
|
if (m_source.isNotNull())
|
||||||
m_source->setFiltSpec(m_filtspec);
|
m_source->setFiltSpec(m_filtspec);
|
||||||
emit applyFiltSortData();
|
initiateQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::toggleFullScreen()
|
void RclMain::toggleFullScreen()
|
||||||
|
|||||||
@ -130,13 +130,12 @@ public slots:
|
|||||||
virtual void onSortDataChanged(DocSeqSortSpec);
|
virtual void onSortDataChanged(DocSeqSortSpec);
|
||||||
virtual void resultCount(int);
|
virtual void resultCount(int);
|
||||||
virtual void showQueryDetails();
|
virtual void showQueryDetails();
|
||||||
virtual void onResultsChanged();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void docSourceChanged(RefCntr<DocSequence>);
|
void docSourceChanged(RefCntr<DocSequence>);
|
||||||
void stemLangChanged(const QString& lang);
|
void stemLangChanged(const QString& lang);
|
||||||
void sortDataChanged(DocSeqSortSpec);
|
void sortDataChanged(DocSeqSortSpec);
|
||||||
void applyFiltSortData();
|
void resultsReady();
|
||||||
void searchReset();
|
void searchReset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -178,6 +177,7 @@ private:
|
|||||||
virtual void showCronTool(bool modal);
|
virtual void showCronTool(bool modal);
|
||||||
virtual void showRTITool(bool modal);
|
virtual void showRTITool(bool modal);
|
||||||
virtual void updateIdxForDocs(vector<Rcl::Doc>&);
|
virtual void updateIdxForDocs(vector<Rcl::Doc>&);
|
||||||
|
virtual void initiateQuery();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RCLMAIN_W_H
|
#endif // RCLMAIN_W_H
|
||||||
|
|||||||
@ -302,7 +302,6 @@ void RecollModel::setDocSource(RefCntr<DocSequence> nsource)
|
|||||||
m_hdata.reset();
|
m_hdata.reset();
|
||||||
m_source->getTerms(m_hdata.terms, m_hdata.groups, m_hdata.gslks);
|
m_source->getTerms(m_hdata.terms, m_hdata.groups, m_hdata.gslks);
|
||||||
}
|
}
|
||||||
readDocSource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecollModel::deleteColumn(int col)
|
void RecollModel::deleteColumn(int col)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user