implement experimental testbed for table-based result list
This commit is contained in:
parent
e1b699d794
commit
7d06dcd5a9
@ -196,6 +196,43 @@ void rwSettings(bool writing)
|
||||
prefs.asearchIgnFilTyps =
|
||||
settings.value("/Recoll/prefs/query/asearchIgnFilTyps").toStringList();
|
||||
}
|
||||
|
||||
|
||||
// Field list for the restable
|
||||
if (writing) {
|
||||
settings.setValue("/Recoll/prefs/query/restableFields",
|
||||
prefs.restableFields);
|
||||
} else {
|
||||
prefs.restableFields =
|
||||
settings.value("/Recoll/prefs/query/restableFields").toStringList();
|
||||
if (prefs.restableFields.empty()) {
|
||||
prefs.restableFields.push_back("filename");
|
||||
prefs.restableFields.push_back("title");
|
||||
prefs.restableFields.push_back("url");
|
||||
}
|
||||
}
|
||||
|
||||
// restable col widths
|
||||
QString rtcw;
|
||||
if (writing) {
|
||||
for (vector<int>::iterator it = prefs.restableColWidths.begin();
|
||||
it != prefs.restableColWidths.end(); it++) {
|
||||
char buf[20];
|
||||
sprintf(buf, "%d ", *it);
|
||||
rtcw += QString::fromAscii(buf);
|
||||
}
|
||||
}
|
||||
SETTING_RW(rtcw, "/Recoll/prefs/query/restableWidths", String,
|
||||
"");
|
||||
if (!writing) {
|
||||
vector<string> widths;
|
||||
stringToStrings((const char *)rtcw.toUtf8(), widths);
|
||||
for (vector<string>::iterator it = widths.begin();
|
||||
it != widths.end(); it++) {
|
||||
prefs.restableColWidths.push_back(atoi(it->c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
|
||||
Bool, false);
|
||||
|
||||
|
||||
@ -104,6 +104,9 @@ class PrefsPack {
|
||||
QString autoSuffs;
|
||||
bool autoSuffsEnable;
|
||||
|
||||
QStringList restableFields;
|
||||
vector<int> restableColWidths;
|
||||
|
||||
// Synthetized abstract length and word context size
|
||||
int syntAbsLen;
|
||||
int syntAbsCtx;
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ResList" name="resList" native="true">
|
||||
<widget class="ResList" name="reslist" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
|
||||
@ -70,6 +70,8 @@ using std::pair;
|
||||
#include "docseqdb.h"
|
||||
#include "docseqhist.h"
|
||||
#include "confguiindex.h"
|
||||
#include "restable.h"
|
||||
|
||||
using namespace confgui;
|
||||
|
||||
#include "rclmain_w.h"
|
||||
@ -96,7 +98,6 @@ void RclMain::init()
|
||||
indexConfig = 0;
|
||||
spellform = 0;
|
||||
m_idxStatusAck = false;
|
||||
|
||||
periodictimer = new QTimer(this);
|
||||
|
||||
// At least some versions of qt4 don't display the status bar if
|
||||
@ -142,11 +143,6 @@ void RclMain::init()
|
||||
}
|
||||
curid->setChecked(true);
|
||||
|
||||
// A shortcut to get the focus back to the search entry.
|
||||
QKeySequence seq("Ctrl+Shift+s");
|
||||
QShortcut *sc = new QShortcut(seq, this);
|
||||
connect(sc, SIGNAL (activated()), this, SLOT (focusToSearch()));
|
||||
|
||||
// Toolbar+combobox version of the category selector
|
||||
QComboBox *catgCMB = 0;
|
||||
if (prefs.catgToolBar) {
|
||||
@ -189,45 +185,34 @@ void RclMain::init()
|
||||
if (prefs.catgToolBar)
|
||||
catgBGRP->hide();
|
||||
|
||||
// Connections
|
||||
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
||||
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
||||
sSearch->queryText->installEventFilter(this);
|
||||
|
||||
if (prefs.keepSort && prefs.sortActive) {
|
||||
if (prefs.sortDesc)
|
||||
actionSortByDateDesc->setChecked(true);
|
||||
else
|
||||
actionSortByDateAsc->setChecked(true);
|
||||
onSortCtlChanged();
|
||||
}
|
||||
|
||||
restable = new ResTable();
|
||||
|
||||
// A shortcut to get the focus back to the search entry.
|
||||
QKeySequence seq("Ctrl+Shift+s");
|
||||
QShortcut *sc = new QShortcut(seq, this);
|
||||
|
||||
connect(sc, SIGNAL (activated()),
|
||||
this, SLOT (focusToSearch()));
|
||||
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
||||
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
||||
connect(preferencesMenu, SIGNAL(triggered(QAction*)),
|
||||
this, SLOT(setStemLang(QAction*)));
|
||||
connect(preferencesMenu, SIGNAL(aboutToShow()),
|
||||
this, SLOT(adjustPrefsMenu()));
|
||||
// signals and slots connections
|
||||
connect(sSearch, SIGNAL(clearSearch()), this, SLOT(resetSearch()));
|
||||
connect(firstPageAction, SIGNAL(activated()),
|
||||
resList, SLOT(resultPageFirst()));
|
||||
connect(prevPageAction, SIGNAL(activated()),
|
||||
resList, SLOT(resPageUpOrBack()));
|
||||
connect(nextPageAction, SIGNAL(activated()),
|
||||
resList, SLOT(resPageDownOrNext()));
|
||||
|
||||
connect(resList, SIGNAL(docExpand(Rcl::Doc)),
|
||||
this, SLOT(docExpand(Rcl::Doc)));
|
||||
connect(resList, SIGNAL(wordSelect(QString)),
|
||||
sSearch, SLOT(addTerm(QString)));
|
||||
connect(resList, SIGNAL(nextPageAvailable(bool)),
|
||||
this, SLOT(enableNextPage(bool)));
|
||||
connect(resList, SIGNAL(prevPageAvailable(bool)),
|
||||
this, SLOT(enablePrevPage(bool)));
|
||||
connect(resList, SIGNAL(docEditClicked(Rcl::Doc)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||
connect(resList, SIGNAL(docSaveToFileClicked(Rcl::Doc)),
|
||||
this, SLOT(saveDocToFile(Rcl::Doc)));
|
||||
connect(resList, SIGNAL(editRequested(Rcl::Doc)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||
|
||||
connect(resList, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
|
||||
this, SLOT(startPreview(int, Rcl::Doc, int)));
|
||||
connect(resList, SIGNAL(previewRequested(Rcl::Doc)),
|
||||
this, SLOT(startPreview(Rcl::Doc)));
|
||||
|
||||
connect(fileExitAction, SIGNAL(activated() ), this, SLOT(fileExit() ) );
|
||||
connect(sSearch, SIGNAL(clearSearch()),
|
||||
this, SLOT(resetSearch()));
|
||||
connect(fileExitAction, SIGNAL(activated() ),
|
||||
this, SLOT(fileExit() ) );
|
||||
connect(fileToggleIndexingAction, SIGNAL(activated()),
|
||||
this, SLOT(toggleIndexing()));
|
||||
connect(fileEraseDocHistoryAction, SIGNAL(activated()),
|
||||
@ -236,7 +221,8 @@ void RclMain::init()
|
||||
this, SLOT(showAboutDialog()));
|
||||
connect(showMissingHelpers_Action, SIGNAL(activated()),
|
||||
this, SLOT(showMissingHelpers()));
|
||||
connect(userManualAction, SIGNAL(activated()), this, SLOT(startManual()));
|
||||
connect(userManualAction, SIGNAL(activated()),
|
||||
this, SLOT(startManual()));
|
||||
connect(toolsDoc_HistoryAction, SIGNAL(activated()),
|
||||
this, SLOT(showDocHistory()));
|
||||
connect(toolsAdvanced_SearchAction, SIGNAL(activated()),
|
||||
@ -245,29 +231,69 @@ void RclMain::init()
|
||||
this, SLOT(showSpellDialog()));
|
||||
connect(indexConfigAction, SIGNAL(activated()),
|
||||
this, SLOT(showIndexConfig()));
|
||||
connect(queryPrefsAction, SIGNAL(activated()), this, SLOT(showUIPrefs()));
|
||||
connect(extIdxAction, SIGNAL(activated()), this, SLOT(showExtIdxDialog()));
|
||||
connect(queryPrefsAction, SIGNAL(activated()),
|
||||
this, SLOT(showUIPrefs()));
|
||||
connect(extIdxAction, SIGNAL(activated()),
|
||||
this, SLOT(showExtIdxDialog()));
|
||||
if (prefs.catgToolBar && catgCMB)
|
||||
connect(catgCMB, SIGNAL(activated(int)), this, SLOT(catgFilter(int)));
|
||||
connect(catgCMB, SIGNAL(activated(int)),
|
||||
this, SLOT(catgFilter(int)));
|
||||
connect(toggleFullScreenAction, SIGNAL(activated()),
|
||||
this, SLOT(toggleFullScreen()));
|
||||
connect(periodictimer, SIGNAL(timeout()), this, SLOT(periodic100()));
|
||||
connect(periodictimer, SIGNAL(timeout()),
|
||||
this, SLOT(periodic100()));
|
||||
|
||||
connect(this, SIGNAL(docSourceChanged(RefCntr<DocSequence>)),
|
||||
restable, SLOT(setDocSource(RefCntr<DocSequence>)));
|
||||
connect(this, SIGNAL(searchReset()),
|
||||
restable, SLOT(resetSource()));
|
||||
connect(restable, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||
this, SLOT(onResTableSortBy(DocSeqSortSpec)));
|
||||
connect(this, SIGNAL(applyFiltSortData()),
|
||||
restable, SLOT(readDocSource()));
|
||||
|
||||
connect(this, SIGNAL(docSourceChanged(RefCntr<DocSequence>)),
|
||||
reslist, SLOT(setDocSource(RefCntr<DocSequence>)));
|
||||
connect(firstPageAction, SIGNAL(activated()),
|
||||
reslist, SLOT(resultPageFirst()));
|
||||
connect(prevPageAction, SIGNAL(activated()),
|
||||
reslist, SLOT(resPageUpOrBack()));
|
||||
connect(nextPageAction, SIGNAL(activated()),
|
||||
reslist, SLOT(resPageDownOrNext()));
|
||||
connect(this, SIGNAL(searchReset()),
|
||||
reslist, SLOT(resetList()));
|
||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||
reslist, SLOT(setSortParams(DocSeqSortSpec)));
|
||||
connect(this, SIGNAL(filtDataChanged(DocSeqFiltSpec)),
|
||||
reslist, SLOT(setFilterParams(DocSeqFiltSpec)));
|
||||
connect(this, SIGNAL(applyFiltSortData()),
|
||||
reslist, SLOT(readDocSource()));
|
||||
|
||||
connect(reslist, SIGNAL(hasResults(int)),
|
||||
this, SLOT(resultCount(int)));
|
||||
connect(reslist, SIGNAL(docExpand(Rcl::Doc)),
|
||||
this, SLOT(docExpand(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(wordSelect(QString)),
|
||||
sSearch, SLOT(addTerm(QString)));
|
||||
connect(reslist, SIGNAL(nextPageAvailable(bool)),
|
||||
this, SLOT(enableNextPage(bool)));
|
||||
connect(reslist, SIGNAL(prevPageAvailable(bool)),
|
||||
this, SLOT(enablePrevPage(bool)));
|
||||
connect(reslist, SIGNAL(docEditClicked(Rcl::Doc)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(docSaveToFileClicked(Rcl::Doc)),
|
||||
this, SLOT(saveDocToFile(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(editRequested(Rcl::Doc)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
|
||||
this, SLOT(startPreview(int, Rcl::Doc, int)));
|
||||
connect(reslist, SIGNAL(previewRequested(Rcl::Doc)),
|
||||
this, SLOT(startPreview(Rcl::Doc)));
|
||||
|
||||
// Start timer on a slow period (used for checking ^C). Will be
|
||||
// speeded up during indexing
|
||||
periodictimer->start(1000);
|
||||
|
||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||
resList, SLOT(setSortParams(DocSeqSortSpec)));
|
||||
connect(resList, SIGNAL(hasResults(int)), this, SLOT(resultCount(int)));
|
||||
connect(this, SIGNAL(applySortData()), resList, SLOT(readDocSource()));
|
||||
if (prefs.keepSort && prefs.sortActive) {
|
||||
if (prefs.sortDesc)
|
||||
actionSortByDateDesc->setChecked(true);
|
||||
else
|
||||
actionSortByDateAsc->setChecked(true);
|
||||
onSortDataChanged();
|
||||
}
|
||||
|
||||
restable->show();
|
||||
}
|
||||
|
||||
void RclMain::resultCount(int n)
|
||||
@ -524,6 +550,8 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
{
|
||||
LOGDEB(("RclMain::startSearch. Indexing %s\n",
|
||||
idxthread_getStatus() == IDXTS_NULL?"on":"off"));
|
||||
emit searchReset();
|
||||
|
||||
// The db may have been closed at the end of indexing
|
||||
string reason;
|
||||
// If indexing is being performed, we reopen the db at each query.
|
||||
@ -532,7 +560,6 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
return;
|
||||
}
|
||||
|
||||
resList->resetList();
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
|
||||
string stemLang = (const char *)prefs.queryStemLang.toAscii();
|
||||
@ -557,16 +584,16 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
src->setAbstractParams(prefs.queryBuildAbstract,
|
||||
prefs.queryReplaceAbstract);
|
||||
|
||||
resList->setDocSource(RefCntr<DocSequence>(src));
|
||||
resList->setSortParams(m_sortspec);
|
||||
resList->setFilterParams(m_filtspec);
|
||||
resList->readDocSource();
|
||||
emit docSourceChanged(RefCntr<DocSequence>(src));
|
||||
emit sortDataChanged(m_sortspec);
|
||||
emit filtDataChanged(m_filtspec);
|
||||
emit applyFiltSortData();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void RclMain::resetSearch()
|
||||
{
|
||||
resList->resetList();
|
||||
emit searchReset();
|
||||
}
|
||||
|
||||
// Open advanced search dialog.
|
||||
@ -690,8 +717,8 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
||||
}
|
||||
if (curPreview == 0) {
|
||||
HiliteData hdata;
|
||||
resList->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||
curPreview = new Preview(resList->listId(), hdata);
|
||||
reslist->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||
curPreview = new Preview(reslist->listId(), hdata);
|
||||
if (curPreview == 0) {
|
||||
QMessageBox::warning(0, tr("Warning"),
|
||||
tr("Can't create preview window"),
|
||||
@ -709,7 +736,7 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
||||
this, SLOT(previewPrevInTab(Preview *, int, int)));
|
||||
connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
|
||||
this, SLOT(previewExposed(Preview *, int, int)));
|
||||
curPreview->setWindowTitle(resList->getDescription());
|
||||
curPreview->setWindowTitle(reslist->getDescription());
|
||||
curPreview->show();
|
||||
}
|
||||
curPreview->makeDocCurrent(doc, docnum);
|
||||
@ -754,12 +781,12 @@ void RclMain::previewPrevInTab(Preview * w, int sid, int docnum)
|
||||
void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
|
||||
{
|
||||
LOGDEB(("RclMain::previewNextInTab sid %d docnum %d, listId %d\n",
|
||||
sid, docnum, resList->listId()));
|
||||
sid, docnum, reslist->listId()));
|
||||
|
||||
if (w == 0) // ??
|
||||
return;
|
||||
|
||||
if (sid != resList->listId()) {
|
||||
if (sid != reslist->listId()) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("This search is not active any more"));
|
||||
return;
|
||||
@ -769,13 +796,13 @@ void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
|
||||
docnum++;
|
||||
else
|
||||
docnum--;
|
||||
if (docnum < 0 || docnum >= resList->getResCnt()) {
|
||||
if (docnum < 0 || docnum >= reslist->getResCnt()) {
|
||||
QApplication::beep();
|
||||
return;
|
||||
}
|
||||
|
||||
Rcl::Doc doc;
|
||||
if (!resList->getDoc(docnum, doc)) {
|
||||
if (!reslist->getDoc(docnum, doc)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Cannot retrieve document info from database"));
|
||||
return;
|
||||
@ -789,32 +816,39 @@ void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
|
||||
void RclMain::previewExposed(Preview *, int sid, int docnum)
|
||||
{
|
||||
LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n",
|
||||
sid, docnum, resList->listId()));
|
||||
if (sid != resList->listId()) {
|
||||
sid, docnum, reslist->listId()));
|
||||
if (sid != reslist->listId()) {
|
||||
return;
|
||||
}
|
||||
resList->previewExposed(docnum);
|
||||
reslist->previewExposed(docnum);
|
||||
}
|
||||
|
||||
void RclMain::onSortDataChanged()
|
||||
void RclMain::onSortCtlChanged()
|
||||
{
|
||||
LOGDEB(("RclMain::onSortDataChanged()\n"));
|
||||
LOGDEB(("RclMain::onCtlDataChanged()\n"));
|
||||
m_sortspec.reset();
|
||||
if (actionSortByDateAsc->isChecked()) {
|
||||
m_sortspec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, false);
|
||||
m_sortspec.sortdepth = 1000000;
|
||||
m_sortspec.field = "mtime";
|
||||
m_sortspec.desc = false;
|
||||
prefs.sortActive = true;
|
||||
prefs.sortDesc = false;
|
||||
} else if (actionSortByDateDesc->isChecked()) {
|
||||
m_sortspec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, true);
|
||||
m_sortspec.sortdepth = 1000000;
|
||||
m_sortspec.field = "mtime";
|
||||
m_sortspec.desc = true;
|
||||
prefs.sortActive = true;
|
||||
prefs.sortDesc = true;
|
||||
} else {
|
||||
prefs.sortActive = prefs.sortDesc = false;
|
||||
}
|
||||
LOGDEB(("RclMain::onCtlDataChanged(): emitting change signals\n"));
|
||||
emit sortDataChanged(m_sortspec);
|
||||
emit applySortData();
|
||||
emit applyFiltSortData();
|
||||
}
|
||||
|
||||
void RclMain::onResTableSortBy(DocSeqSortSpec)
|
||||
{
|
||||
// TOBEDONE: do something about the up down arrows !
|
||||
emit applyFiltSortData();
|
||||
}
|
||||
|
||||
void RclMain::on_actionSortByDateAsc_toggled(bool on)
|
||||
@ -827,7 +861,7 @@ void RclMain::on_actionSortByDateAsc_toggled(bool on)
|
||||
return;
|
||||
}
|
||||
}
|
||||
onSortDataChanged();
|
||||
onSortCtlChanged();
|
||||
}
|
||||
|
||||
void RclMain::on_actionSortByDateDesc_toggled(bool on)
|
||||
@ -840,7 +874,7 @@ void RclMain::on_actionSortByDateDesc_toggled(bool on)
|
||||
return;
|
||||
}
|
||||
}
|
||||
onSortDataChanged();
|
||||
onSortCtlChanged();
|
||||
}
|
||||
|
||||
void RclMain::saveDocToFile(Rcl::Doc doc)
|
||||
@ -1122,7 +1156,7 @@ void RclMain::docExpand(Rcl::Doc doc)
|
||||
if (!rcldb)
|
||||
return;
|
||||
list<string> terms;
|
||||
terms = resList->expand(doc);
|
||||
terms = reslist->expand(doc);
|
||||
if (terms.empty())
|
||||
return;
|
||||
// Do we keep the original query. I think we'd better not.
|
||||
@ -1142,7 +1176,8 @@ void RclMain::docExpand(Rcl::Doc doc)
|
||||
void RclMain::showDocHistory()
|
||||
{
|
||||
LOGDEB(("RclMain::showDocHistory\n"));
|
||||
resList->resetList();
|
||||
emit searchReset();
|
||||
|
||||
curPreview = 0;
|
||||
|
||||
string reason;
|
||||
@ -1161,10 +1196,10 @@ void RclMain::showDocHistory()
|
||||
new DocSequenceHistory(rcldb, g_dynconf,
|
||||
string(tr("Document history").toUtf8()));
|
||||
src->setDescription((const char *)tr("History data").toUtf8());
|
||||
resList->setDocSource(RefCntr<DocSequence>(src));
|
||||
resList->setSortParams(m_sortspec);
|
||||
resList->setFilterParams(m_filtspec);
|
||||
resList->readDocSource();
|
||||
reslist->setDocSource(RefCntr<DocSequence>(src));
|
||||
emit sortDataChanged(m_sortspec);
|
||||
emit filtDataChanged(m_filtspec);
|
||||
emit applyFiltSortData();
|
||||
}
|
||||
|
||||
// Erase all memory of documents viewed
|
||||
@ -1174,7 +1209,7 @@ void RclMain::eraseDocHistory()
|
||||
if (g_dynconf)
|
||||
g_dynconf->eraseAll(docHistSubKey);
|
||||
// Clear possibly displayed history
|
||||
if (resList->displayingHistory()) {
|
||||
if (reslist->displayingHistory()) {
|
||||
showDocHistory();
|
||||
}
|
||||
}
|
||||
@ -1187,9 +1222,9 @@ void RclMain::setUIPrefs()
|
||||
LOGDEB(("Recollmain::setUIPrefs\n"));
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||
resList->setFont(nfont);
|
||||
reslist->setFont(nfont);
|
||||
} else {
|
||||
resList->setFont(this->font());
|
||||
reslist->setFont(this->font());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1221,9 +1256,8 @@ void RclMain::catgFilter(int id)
|
||||
it != tps.end(); it++)
|
||||
m_filtspec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
|
||||
}
|
||||
|
||||
resList->setFilterParams(m_filtspec);
|
||||
resList->readDocSource();
|
||||
emit filtDataChanged(m_filtspec);
|
||||
emit applyFiltSortData();
|
||||
}
|
||||
|
||||
void RclMain::toggleFullScreen()
|
||||
@ -1246,7 +1280,7 @@ bool RclMain::eventFilter(QObject *, QEvent *event)
|
||||
if (ke->key() == Qt::Key_Home &&
|
||||
(ke->modifiers() & Qt::ShiftModifier)) {
|
||||
// Shift-Home -> first page of results
|
||||
resList->resultPageFirst();
|
||||
reslist->resultPageFirst();
|
||||
return true;
|
||||
}
|
||||
} else if (event->type() == QEvent::Show) {
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
class ExecCmd;
|
||||
class Preview;
|
||||
class ResTable;
|
||||
|
||||
#include "ui_rclmain.h"
|
||||
|
||||
@ -96,11 +97,15 @@ public slots:
|
||||
virtual void on_actionSortByDateAsc_toggled(bool on);
|
||||
virtual void on_actionSortByDateDesc_toggled(bool on);
|
||||
virtual void resultCount(int);
|
||||
virtual void onResTableSortBy(DocSeqSortSpec);
|
||||
|
||||
signals:
|
||||
void docSourceChanged(RefCntr<DocSequence>);
|
||||
void stemLangChanged(const QString& lang);
|
||||
void sortDataChanged(DocSeqSortSpec);
|
||||
void applySortData();
|
||||
void filtDataChanged(DocSeqFiltSpec);
|
||||
void applyFiltSortData();
|
||||
void searchReset();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent( QCloseEvent * );
|
||||
@ -112,6 +117,7 @@ private:
|
||||
ConfIndexW *indexConfig;
|
||||
SpellW *spellform;
|
||||
QTimer *periodictimer;
|
||||
ResTable *restable;
|
||||
|
||||
vector<TempFile> m_tempfiles;
|
||||
vector<ExecCmd*> m_viewers;
|
||||
@ -127,7 +133,7 @@ private:
|
||||
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
|
||||
bool next);
|
||||
virtual void setStemLang(const QString& lang);
|
||||
virtual void onSortDataChanged();
|
||||
virtual void onSortCtlChanged();
|
||||
};
|
||||
|
||||
#endif // RCLMAIN_W_H
|
||||
|
||||
@ -4,36 +4,38 @@ LANGUAGE = C++
|
||||
CONFIG += qt warn_on thread release
|
||||
|
||||
HEADERS += \
|
||||
../qtgui/advsearch_w.h \
|
||||
../qtgui/confgui/confgui.h \
|
||||
../qtgui/confgui/confguiindex.h \
|
||||
../qtgui/preview_w.h \
|
||||
../qtgui/rclhelp.h \
|
||||
../qtgui/rclmain_w.h \
|
||||
../qtgui/reslist.h \
|
||||
../qtgui/searchclause_w.h \
|
||||
../qtgui/spell_w.h \
|
||||
../qtgui/ssearch_w.h \
|
||||
../qtgui/uiprefs_w.h \
|
||||
../qtgui/viewaction_w.h \
|
||||
advsearch_w.h \
|
||||
confgui/confgui.h \
|
||||
confgui/confguiindex.h \
|
||||
preview_w.h \
|
||||
rclhelp.h \
|
||||
rclmain_w.h \
|
||||
reslist.h \
|
||||
restable.h \
|
||||
searchclause_w.h \
|
||||
spell_w.h \
|
||||
ssearch_w.h \
|
||||
uiprefs_w.h \
|
||||
viewaction_w.h \
|
||||
|
||||
|
||||
SOURCES += \
|
||||
../qtgui/advsearch_w.cpp \
|
||||
../qtgui/confgui/confgui.cpp \
|
||||
../qtgui/confgui/confguiindex.cpp \
|
||||
../qtgui/guiutils.cpp \
|
||||
../qtgui/idxthread.cpp \
|
||||
../qtgui/main.cpp \
|
||||
../qtgui/preview_w.cpp \
|
||||
../qtgui/rclhelp.cpp \
|
||||
../qtgui/rclmain_w.cpp \
|
||||
../qtgui/reslist.cpp \
|
||||
../qtgui/searchclause_w.cpp \
|
||||
../qtgui/spell_w.cpp \
|
||||
../qtgui/ssearch_w.cpp \
|
||||
../qtgui/uiprefs_w.cpp \
|
||||
../qtgui/viewaction_w.cpp \
|
||||
advsearch_w.cpp \
|
||||
confgui/confgui.cpp \
|
||||
confgui/confguiindex.cpp \
|
||||
guiutils.cpp \
|
||||
idxthread.cpp \
|
||||
main.cpp \
|
||||
preview_w.cpp \
|
||||
rclhelp.cpp \
|
||||
rclmain_w.cpp \
|
||||
reslist.cpp \
|
||||
restable.cpp \
|
||||
searchclause_w.cpp \
|
||||
spell_w.cpp \
|
||||
ssearch_w.cpp \
|
||||
uiprefs_w.cpp \
|
||||
viewaction_w.cpp \
|
||||
|
||||
|
||||
|
||||
@ -60,7 +62,7 @@ unix {
|
||||
INCLUDEPATH += ../common ../index ../internfile ../query ../unac \
|
||||
../utils ../aspell ../rcldb \
|
||||
../qtgui ../../qtgui \
|
||||
../qtgui/confgui ../../qtgui/confgui
|
||||
confgui ../confgui
|
||||
|
||||
POST_TARGETDEPS = ../lib/librcl.a
|
||||
}
|
||||
@ -75,12 +77,12 @@ contains( UNAME, SunOS ) {
|
||||
}
|
||||
|
||||
TRANSLATIONS = \
|
||||
../qtgui/i18n/recoll_de.ts \
|
||||
../qtgui/i18n/recoll_fr.ts \
|
||||
../qtgui/i18n/recoll_it.ts \
|
||||
../qtgui/i18n/recoll_lt.ts \
|
||||
../qtgui/i18n/recoll_ru.ts \
|
||||
../qtgui/i18n/recoll_tr.ts \
|
||||
../qtgui/i18n/recoll_uk.ts \
|
||||
../qtgui/i18n/recoll_xx.ts \
|
||||
i18n/recoll_de.ts \
|
||||
i18n/recoll_fr.ts \
|
||||
i18n/recoll_it.ts \
|
||||
i18n/recoll_lt.ts \
|
||||
i18n/recoll_ru.ts \
|
||||
i18n/recoll_tr.ts \
|
||||
i18n/recoll_uk.ts \
|
||||
i18n/recoll_xx.ts \
|
||||
|
||||
|
||||
@ -276,6 +276,7 @@ void ResList::setDocSource(RefCntr<DocSequence> nsource)
|
||||
// Reapply parameters. Sort params probably changed
|
||||
void ResList::readDocSource()
|
||||
{
|
||||
LOGDEB(("ResList::readDocSource\n"));
|
||||
if (m_source.isNull())
|
||||
return;
|
||||
resetList();
|
||||
@ -290,11 +291,13 @@ void ResList::readDocSource()
|
||||
|
||||
void ResList::setSortParams(DocSeqSortSpec spec)
|
||||
{
|
||||
LOGDEB(("ResList::setSortParams\n"));
|
||||
m_source->setSortSpec(spec);
|
||||
}
|
||||
|
||||
void ResList::setFilterParams(const DocSeqFiltSpec& spec)
|
||||
{
|
||||
LOGDEB(("ResList::setFilterParams\n"));
|
||||
m_source->setFiltSpec(spec);
|
||||
}
|
||||
|
||||
|
||||
@ -3,9 +3,11 @@
|
||||
/* @(#$Id: reslist.h,v 1.17 2008-12-16 14:20:10 dockes Exp $ (C) 2005 J.F.Dockes */
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::list;
|
||||
using std::pair;
|
||||
#endif
|
||||
|
||||
#include <qtextbrowser.h>
|
||||
@ -48,7 +50,6 @@ class ResList : public QTextBrowser
|
||||
|
||||
QString getDescription(); // Printable actual query performed on db
|
||||
int getResCnt(); // Return total result list size
|
||||
void setDocSource(RefCntr<DocSequence> nsource);
|
||||
bool displayingHistory();
|
||||
bool getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups, vector<int>& gslks);
|
||||
@ -56,6 +57,7 @@ class ResList : public QTextBrowser
|
||||
int listId() const {return m_listId;}
|
||||
|
||||
public slots:
|
||||
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
||||
virtual void resetList(); // Erase current list
|
||||
virtual void resPageUpOrBack(); // Page up pressed
|
||||
virtual void resPageDownOrNext(); // Page down pressed
|
||||
|
||||
@ -6,23 +6,230 @@ static char rcsid[] = "@(#$Id: reslist.cpp,v 1.52 2008-12-17 15:12:08 dockes Exp
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Qt>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include "refcntr.h"
|
||||
#include "docseq.h"
|
||||
#include "debuglog.h"
|
||||
#include "restable.h"
|
||||
#include "guiutils.h"
|
||||
#include "reslistpager.h"
|
||||
#include "reslist.h"
|
||||
#include "rclconfig.h"
|
||||
#include "plaintorich.h"
|
||||
|
||||
class RecollModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
//////////////////////////////////
|
||||
// Restable "pager". We use it to display doc details in the detail area
|
||||
///
|
||||
class ResTablePager : public ResListPager {
|
||||
public:
|
||||
RecollModel(QObject *parent = 0)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ResTablePager(ResTable *p)
|
||||
: ResListPager(1), m_parent(p)
|
||||
{}
|
||||
virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
|
||||
virtual string trans(const string& in);
|
||||
virtual const string &parFormat();
|
||||
virtual string iconPath(const string& mt);
|
||||
private:
|
||||
|
||||
ResTable *m_parent;
|
||||
};
|
||||
|
||||
bool ResTablePager::append(const string& data, int docnum, const Rcl::Doc&)
|
||||
{
|
||||
m_parent->textBrowser->moveCursor(QTextCursor::End,
|
||||
QTextCursor::MoveAnchor);
|
||||
m_parent->textBrowser->textCursor().insertBlock();
|
||||
m_parent->textBrowser->insertHtml(QString::fromUtf8(data.c_str()));
|
||||
m_parent->m_detaildocnum = docnum;
|
||||
return true;
|
||||
}
|
||||
|
||||
string ResTablePager::trans(const string& in)
|
||||
{
|
||||
return string((const char*)ResList::tr(in.c_str()).toUtf8());
|
||||
}
|
||||
|
||||
const string& ResTablePager::parFormat()
|
||||
{
|
||||
return prefs.creslistformat;
|
||||
}
|
||||
|
||||
string ResTablePager::iconPath(const string& mtype)
|
||||
{
|
||||
string iconpath;
|
||||
RclConfig::getMainConfig()->getMimeIconName(mtype, &iconpath);
|
||||
return iconpath;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//// Data model methods
|
||||
////
|
||||
RecollModel::RecollModel(const QStringList fields, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
for (QStringList::const_iterator it = fields.begin();
|
||||
it != fields.end(); it++)
|
||||
m_fields.push_back((const char *)(it->toUtf8()));
|
||||
}
|
||||
|
||||
int RecollModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
LOGDEB(("RecollModel::rowCount\n"));
|
||||
if (m_source.isNull())
|
||||
return 0;
|
||||
return m_source->getResCnt();
|
||||
}
|
||||
|
||||
int RecollModel::columnCount(const QModelIndex&) const
|
||||
{
|
||||
LOGDEB(("RecollModel::columnCount\n"));
|
||||
return m_fields.size();
|
||||
}
|
||||
|
||||
void RecollModel::setDocSource(RefCntr<DocSequence> nsource)
|
||||
{
|
||||
LOGDEB(("RecollModel::setDocSource\n"));
|
||||
if (nsource.isNull())
|
||||
m_source = RefCntr<DocSequence>();
|
||||
else
|
||||
m_source = RefCntr<DocSequence>(new DocSource(nsource));
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
bool RecollModel::getdoc(int index, Rcl::Doc &doc)
|
||||
{
|
||||
LOGDEB(("RecollModel::getDoc\n"));
|
||||
if (m_source.isNull())
|
||||
return false;
|
||||
return m_source->getDoc(index, doc);
|
||||
}
|
||||
|
||||
QVariant RecollModel::headerData(int col, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
LOGDEB(("RecollModel::headerData: col %d\n", col));
|
||||
if (orientation != Qt::Horizontal || role != Qt::DisplayRole ||
|
||||
col >= int(m_fields.size())) {
|
||||
return QVariant();
|
||||
}
|
||||
return QString::fromUtf8(m_fields[col].c_str());
|
||||
}
|
||||
|
||||
QVariant RecollModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
LOGDEB(("RecollModel::data: row %d col %d\n", index.row(),
|
||||
index.column()));
|
||||
if (m_source.isNull() || role != Qt::DisplayRole || !index.isValid() ||
|
||||
index.column() >= int(m_fields.size())) {
|
||||
return QVariant();
|
||||
}
|
||||
Rcl::Doc doc;
|
||||
if (!m_source->getDoc(index.row(), doc)) {
|
||||
return QVariant();
|
||||
}
|
||||
map<string, string>::const_iterator it =
|
||||
doc.meta.find(m_fields[index.column()]);
|
||||
if (it == doc.meta.end()) {
|
||||
return QVariant();
|
||||
}
|
||||
return QString::fromUtf8(it->second.c_str());
|
||||
}
|
||||
|
||||
void RecollModel::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
LOGDEB(("RecollModel::sort(%d, %d)\n", column, int(order)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// ResTable panel methods
|
||||
void ResTable::init()
|
||||
{
|
||||
if (!(m_model = new RecollModel(prefs.restableFields)))
|
||||
return;
|
||||
tableView->setModel(m_model);
|
||||
m_pager = new ResTablePager(this);
|
||||
|
||||
// Set up the columns according to the list of fields we are displaying
|
||||
QHeaderView *header = tableView->horizontalHeader();
|
||||
if (header) {
|
||||
if (int(prefs.restableColWidths.size()) == header->count()) {
|
||||
for (int i = 0; i < header->count(); i++) {
|
||||
header->resizeSection(i, prefs.restableColWidths[i]);
|
||||
}
|
||||
}
|
||||
header->setSortIndicatorShown(true);
|
||||
header->setSortIndicator(-1, Qt::AscendingOrder);
|
||||
connect(header, SIGNAL(sectionResized(int,int,int)),
|
||||
this, SLOT(saveColWidths()));
|
||||
connect(header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
|
||||
this, SLOT(sortByColumn(int, Qt::SortOrder)));
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::on_tableView_clicked(const QModelIndex& index)
|
||||
{
|
||||
LOGDEB(("ResTable::on_tableView_clicked(%d, %d)\n",
|
||||
index.row(), index.column()));
|
||||
|
||||
if (!m_model || m_model->m_source.isNull())
|
||||
return;
|
||||
HiliteData hdata;
|
||||
m_model->m_source->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||
Rcl::Doc doc;
|
||||
if (m_model->getdoc(index.row(), doc)) {
|
||||
textBrowser->clear();
|
||||
m_detaildocnum = index.row();
|
||||
m_pager->displayDoc(index.row(), doc, hdata);
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::setDocSource(RefCntr<DocSequence> nsource)
|
||||
{
|
||||
LOGDEB(("ResTable::setDocSource\n"));
|
||||
if (m_model)
|
||||
m_model->setDocSource(nsource);
|
||||
if (m_pager)
|
||||
m_pager->setDocSource(nsource);
|
||||
if (textBrowser)
|
||||
textBrowser->clear();
|
||||
}
|
||||
|
||||
void ResTable::resetSource()
|
||||
{
|
||||
LOGDEB(("ResTable::resetSource\n"));
|
||||
setDocSource(RefCntr<DocSequence>());
|
||||
}
|
||||
|
||||
void ResTable::saveColWidths()
|
||||
{
|
||||
LOGDEB(("ResTable::saveColWidths()\n"));
|
||||
QHeaderView *header = tableView->horizontalHeader();
|
||||
if (!header)
|
||||
return;
|
||||
prefs.restableColWidths.clear();
|
||||
for (int i = 0; i < header->count(); i++) {
|
||||
prefs.restableColWidths.push_back(header->sectionSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::sortByColumn(int column, Qt::SortOrder order)
|
||||
{
|
||||
LOGDEB(("ResTable::sortByColumn(%d,%d)\n", column, int(order)));
|
||||
|
||||
if (column >= 0 && m_model && column < int(m_model->m_fields.size())) {
|
||||
DocSeqSortSpec spec;
|
||||
spec.field = m_model->m_fields[column];
|
||||
spec.desc = order == Qt::AscendingOrder ? false : true;
|
||||
m_model->m_source->setSortSpec(spec);
|
||||
readDocSource();
|
||||
emit sortDataChanged(spec);
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::readDocSource()
|
||||
{
|
||||
m_model->setDocSource(m_model->m_source);
|
||||
}
|
||||
|
||||
@ -18,27 +18,73 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "ui_restable.h"
|
||||
#include <Qt>
|
||||
|
||||
class ResTable : public Ui::ResTable
|
||||
#include "ui_restable.h"
|
||||
#include "refcntr.h"
|
||||
#include "docseq.h"
|
||||
|
||||
class ResTable;
|
||||
|
||||
class RecollModel : public QAbstractTableModel {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RecollModel(const QStringList fields, QObject *parent = 0);
|
||||
virtual int rowCount (const QModelIndex& = QModelIndex()) const;
|
||||
virtual int columnCount(const QModelIndex& = QModelIndex()) const;
|
||||
virtual QVariant headerData (int col,
|
||||
Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole ) const;
|
||||
virtual QVariant data(const QModelIndex& index,
|
||||
int role = Qt::DisplayRole ) const;
|
||||
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
||||
virtual bool getdoc(int index, Rcl::Doc &doc);
|
||||
|
||||
friend class ResTable;
|
||||
private:
|
||||
mutable RefCntr<DocSequence> m_source;
|
||||
vector<string> m_fields;
|
||||
};
|
||||
|
||||
class ResTablePager;
|
||||
|
||||
class ResTable : public QWidget, public Ui::ResTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ResTable(QWidget* parent = 0)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
m_model(0), m_pager(0), m_detaildocnum(-1)
|
||||
{
|
||||
setupUi(this);
|
||||
init();
|
||||
}
|
||||
|
||||
~ResTable(){}
|
||||
virtual ~ResTable() {}
|
||||
|
||||
public slots:
|
||||
virtual void on_tableView_clicked(const QModelIndex&);
|
||||
virtual void saveColWidths();
|
||||
virtual void sortByColumn(int column, Qt::SortOrder order);
|
||||
|
||||
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
||||
virtual void resetSource();
|
||||
virtual void readDocSource();
|
||||
|
||||
signals:
|
||||
void sortDataChanged(DocSeqSortSpec);
|
||||
|
||||
friend class ResTablePager;
|
||||
private:
|
||||
void init();
|
||||
RecollModel *m_model;
|
||||
ResTablePager *m_pager;
|
||||
int m_detaildocnum;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,14 +6,17 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>291</height>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user