";
- line += docsource->title().c_str();
- line += "
";
- reslistTE->append(line);
- line = tr("Displaying results starting at index"
- " %1 (maximum set size %2)
");
- if (!img_name.empty()) {
- result += "";
- }
- result += string(perbuf) + " " + doc.title + "
" +
- doc.mimetype + " " +
- (datebuf[0] ? string(datebuf) + "
" : string("
")) +
- (!abst.empty() ? abst + "
" : string("")) +
- (!doc.keywords.empty() ? doc.keywords + "
" : string("")) +
- "" + doc.url + +"
" +
- "
"
- /*""*/
- "No results found"
- "
"));
- reslist_winfirst -= respagesize;
- if (reslist_winfirst < 0)
- reslist_winfirst = -1;
- }
-
- if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize >= resCnt)) {
- listNextPB->setEnabled(false);
- } else {
- listNextPB->setEnabled(true);
- }
-}
-
-// If a preview (toplevel) window gets closed by the user, we need to
-// clean up because there is no way to reopen it. And check the case
-// where the current one is closed
-void RecollMain::previewClosed(Preview *w)
-{
- if (w == curPreview) {
- LOGDEB(("Active preview closed\n"));
- curPreview = 0;
- } else {
- LOGDEB(("Old preview closed\n"));
- }
- delete w;
-}
-
-// Open advanced search dialog.
-void RecollMain::showAdvSearchDialog()
-{
- if (asearchform == 0) {
- asearchform = new advsearch(0, tr("Advanced search"), FALSE,
- WStyle_Customize | WStyle_NormalBorder |
- WStyle_Title | WStyle_SysMenu);
- asearchform->setSizeGripEnabled(FALSE);
- connect(asearchform, SIGNAL(startSearch(Rcl::AdvSearchData)),
- this, SLOT(startAdvSearch(Rcl::AdvSearchData)));
- asearchform->show();
- } else {
- asearchform->show();
- }
-}
-
-void RecollMain::showSortDialog()
-{
- if (sortform == 0) {
- sortform = new SortForm(0, tr("Sort criteria"), FALSE,
- WStyle_Customize | WStyle_NormalBorder |
- WStyle_Title | WStyle_SysMenu);
- sortform->setSizeGripEnabled(FALSE);
- connect(sortform, SIGNAL(sortDataChanged(int, RclSortSpec)),
- this, SLOT(sortDataChanged(int, RclSortSpec)));
- sortform->show();
- } else {
- sortform->show();
- }
-
+ sdata.orwords = u8;
+ startAdvSearch(sdata);
}
// Execute an advanced search query. The parameters normally come from
@@ -633,9 +409,230 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
docsource = new DocSequenceDb(rcldb);
}
- listNextPB_clicked();
+ showResultPage();
}
+void RecollMain::resultPageBack()
+{
+ if (reslist_winfirst <= 0)
+ return;
+ reslist_winfirst -= 2*respagesize;
+ showResultPage();
+}
+
+
+// Fill up result list window with next screen of hits
+void RecollMain::showResultPage()
+{
+ if (!docsource)
+ return;
+
+ int percent;
+ Rcl::Doc doc;
+
+ int resCnt = docsource->getResCnt();
+
+ LOGDEB(("showResultPage: rescnt %d, winfirst %d\n", resCnt,
+ reslist_winfirst));
+
+ pageParaToReldocnums.clear();
+
+ // If we are already on the last page, nothing to do:
+ if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt)) {
+ nextPageAction->setEnabled(false);
+ return;
+ }
+
+ if (reslist_winfirst < 0) {
+ reslist_winfirst = 0;
+ prevPageAction->setEnabled(false);
+ } else {
+ prevPageAction->setEnabled(true);
+ reslist_winfirst += respagesize;
+ }
+
+ bool gotone = false;
+ reslistTE->clear();
+
+ int last = MIN(resCnt-reslist_winfirst, respagesize);
+
+ string alltext;
+
+ // Insert results if any in result list window
+ for (int i = 0; i < last; i++) {
+ string sh;
+ doc.erase();
+
+ if (!docsource->getDoc(reslist_winfirst + i, doc, &percent, &sh)) {
+ if (i == 0)
+ reslist_winfirst = -1;
+ break;
+ }
+ if (i == 0) {
+ // Display header
+ // We could use a
";
+ line += docsource->title().c_str();
+ line += "
";
+ //alltext.append(line.utf8());
+ reslistTE->append(line);
+ line = tr("Displaying results starting at index"
+ " %1 (maximum set size %2)
") + sh + "
\n"; + else + result = "
";
+
+ string img_name;
+ if (showicons) {
+ string iconname = rclconfig->getMimeIconName(doc.mimetype);
+ if (iconname.empty())
+ iconname = "document";
+ string imgfile = iconsdir + "/" + iconname + ".png";
+
+ LOGDEB1(("Img file; %s\n", imgfile.c_str()));
+ QImage image(imgfile.c_str());
+ if (!image.isNull()) {
+ img_name = string("img_") + iconname;
+ QMimeSourceFactory::defaultFactory()->
+ setImage(img_name.c_str(), image);
+ }
+ }
+
+ char perbuf[10];
+ sprintf(perbuf, "%3d%%", percent);
+ if (doc.title.empty())
+ doc.title = path_getsimple(doc.url);
+ char datebuf[100];
+ datebuf[0] = 0;
+ if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
+ time_t mtime = doc.dmtime.empty() ?
+ atol(doc.fmtime.c_str()) : atol(doc.dmtime.c_str());
+ struct tm *tm = localtime(&mtime);
+ strftime(datebuf, 99, "Modified: %F %T", tm);
+ }
+ string abst = stripMarkup(doc.abstract);
+ LOGDEB1(("Abstract: {%s}\n", abst.c_str()));
+ if (!img_name.empty()) {
+ result += "";
+ }
+ result += string(perbuf) + " " + doc.title + "
" +
+ doc.mimetype + " " +
+ (datebuf[0] ? string(datebuf) + "
" : string("
")) +
+ (!abst.empty() ? abst + "
" : string("")) +
+ (!doc.keywords.empty() ? doc.keywords + "
" : string("")) +
+ "" + doc.url + +"
"
+ /*""*/
+ "No results found"
+ "
"));
+ reslist_winfirst -= respagesize;
+ if (reslist_winfirst < 0)
+ reslist_winfirst = -1;
+ }
+
+#if 0
+ {
+ FILE *fp = fopen("/tmp/reslistdebug", "w");
+ if (fp) {
+ const char *text = (const char *)reslistTE->text().utf8();
+ //const char *text = alltext.c_str();
+ fwrite(text, 1, strlen(text), fp);
+ fclose(fp);
+ }
+ }
+#endif
+
+ if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize >= resCnt)) {
+ nextPageAction->setEnabled(false);
+ } else {
+ nextPageAction->setEnabled(true);
+ }
+}
+
+// If a preview (toplevel) window gets closed by the user, we need to
+// clean up because there is no way to reopen it. And check the case
+// where the current one is closed
+void RecollMain::previewClosed(Preview *w)
+{
+ if (w == curPreview) {
+ LOGDEB(("Active preview closed\n"));
+ curPreview = 0;
+ } else {
+ LOGDEB(("Old preview closed\n"));
+ }
+ delete w;
+}
+
+// Open advanced search dialog.
+void RecollMain::showAdvSearchDialog()
+{
+ if (asearchform == 0) {
+ asearchform = new advsearch(0, tr("Advanced search"), FALSE,
+ WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu);
+ asearchform->setSizeGripEnabled(FALSE);
+ connect(asearchform, SIGNAL(startSearch(Rcl::AdvSearchData)),
+ this, SLOT(startAdvSearch(Rcl::AdvSearchData)));
+ asearchform->show();
+ } else {
+ // Close and reopen, in hope that makes us visible...
+ asearchform->close();
+ asearchform->show();
+ }
+}
+
+void RecollMain::showSortDialog()
+{
+ if (sortform == 0) {
+ sortform = new SortForm(0, tr("Sort criteria"), FALSE,
+ WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu);
+ sortform->setSizeGripEnabled(FALSE);
+ connect(sortform, SIGNAL(sortDataChanged(int, RclSortSpec)),
+ this, SLOT(sortDataChanged(int, RclSortSpec)));
+ sortform->show();
+ } else {
+ // Close and reopen, in hope that makes us visible...
+ sortform->close();
+ sortform->show();
+ }
+
+}
/**
* Open a preview window for a given document, or load it into new tab of
@@ -706,8 +703,14 @@ void RecollMain::showDocHistory()
if (docsource)
delete docsource;
- docsource = new DocSequenceHistory(rcldb, history);
- listNextPB_clicked();
+
+ if (sortwidth > 0) {
+ DocSequenceHistory myseq(rcldb, history);
+ docsource = new DocSeqSorted(myseq, sortwidth, sortspecs);
+ } else {
+ docsource = new DocSequenceHistory(rcldb, history);
+ }
+ showResultPage();
}
diff --git a/src/qtgui/sort.ui.h b/src/qtgui/sort.ui.h
index 9e57e262..42a62594 100644
--- a/src/qtgui/sort.ui.h
+++ b/src/qtgui/sort.ui.h
@@ -33,6 +33,8 @@ void SortForm::reset()
fldCMB2->setCurrentItem(0);
descCB1->setChecked(false);
descCB1->setChecked(false);
+ sortCB->setChecked(false);
+ setData();
}
void SortForm::setData()
diff --git a/src/query/docseq.cpp b/src/query/docseq.cpp
index 82c04314..d304be3e 100644
--- a/src/query/docseq.cpp
+++ b/src/query/docseq.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: docseq.cpp,v 1.2 2005-11-28 15:31:01 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: docseq.cpp,v 1.3 2005-12-05 12:02:01 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include