ckpt
This commit is contained in:
+47
-93
@@ -23,13 +23,13 @@
|
||||
<property name="caption">
|
||||
<string>recoll</string>
|
||||
</property>
|
||||
<hbox>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout3</cstring>
|
||||
<cstring>layout10</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
@@ -37,7 +37,7 @@
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout2</cstring>
|
||||
<cstring>layout8</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
@@ -62,6 +62,22 @@
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listPrevPb</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Previous page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listNextPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
@@ -74,7 +90,7 @@
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>329</width>
|
||||
<width>346</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -83,21 +99,7 @@
|
||||
</widget>
|
||||
<widget class="QSplitter">
|
||||
<property name="name">
|
||||
<cstring>splitter9</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<cstring>splitter6</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
@@ -108,8 +110,8 @@
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -123,13 +125,13 @@
|
||||
</widget>
|
||||
<widget class="QSplitter">
|
||||
<property name="name">
|
||||
<cstring>splitter8</cstring>
|
||||
<cstring>splitter5</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>3</horstretch>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>5</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
@@ -145,7 +147,7 @@
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
@@ -178,7 +180,7 @@
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</widget>
|
||||
<menubar>
|
||||
<property name="name">
|
||||
@@ -190,10 +192,7 @@
|
||||
<action name="fileExitAction"/>
|
||||
</item>
|
||||
<item text="&Help" name="helpMenu">
|
||||
<action name="helpContentsAction"/>
|
||||
<action name="helpIndexAction"/>
|
||||
<separator/>
|
||||
<action name="helpAboutAction"/>
|
||||
</item>
|
||||
</menubar>
|
||||
<toolbars>
|
||||
@@ -213,48 +212,6 @@
|
||||
<string></string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>helpContentsAction</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Contents</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>&Contents...</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string></string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>helpIndexAction</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Index</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>&Index...</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string></string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>helpAboutAction</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string></string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
<connections>
|
||||
<connection>
|
||||
@@ -263,24 +220,6 @@
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>fileExit()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>helpIndexAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>helpIndex()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>helpContentsAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>helpContents()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>helpAboutAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>helpAbout()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>resTextEdit</sender>
|
||||
<signal>clicked(int,int)</signal>
|
||||
@@ -305,18 +244,33 @@
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>Search_clicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>listPrevPb</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>listPrevPB_clicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>listNextPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>listNextPB_clicked()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
|
||||
</includes>
|
||||
<variables>
|
||||
<variable>int reslist_current;</variable>
|
||||
<variable>int reslist_winfirst;</variable>
|
||||
</variables>
|
||||
<slots>
|
||||
<slot>fileExit()</slot>
|
||||
<slot>helpIndex()</slot>
|
||||
<slot>helpContents()</slot>
|
||||
<slot>helpAbout()</slot>
|
||||
<slot>resTextEdit_clicked( int par, int car )</slot>
|
||||
<slot>queryText_returnPressed()</slot>
|
||||
<slot>Search_clicked()</slot>
|
||||
<slot>listPrevPB_clicked()</slot>
|
||||
<slot>listNextPB_clicked()</slot>
|
||||
</slots>
|
||||
<pixmapinproject/>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
|
||||
+123
-48
@@ -16,22 +16,6 @@ void RecollMain::fileExit()
|
||||
}
|
||||
|
||||
|
||||
void RecollMain::helpIndex()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RecollMain::helpContents()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RecollMain::helpAbout()
|
||||
{
|
||||
|
||||
}
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include "rcldb.h"
|
||||
@@ -62,12 +46,27 @@ static string plaintorich(const string &in)
|
||||
return out;
|
||||
}
|
||||
|
||||
void RecollMain::resTextEdit_clicked( int par, int car )
|
||||
// Click in the result list window: display preview for selected document,
|
||||
// and highlight entry. The paragraph number is doc number in window + 1
|
||||
void RecollMain::resTextEdit_clicked(int par, int car)
|
||||
{
|
||||
fprintf(stderr, "Clicked at paragraph %d, char %d\n", par, car);
|
||||
LOGDEB(("RecollMain::resTextEdi_clicked: par %d, char %d\n", par, car));
|
||||
if (reslist_winfirst == -1)
|
||||
return;
|
||||
Rcl::Doc doc;
|
||||
doc.erase();
|
||||
if (rcldb->getDoc(par, doc)) {
|
||||
if (reslist_current != -1) {
|
||||
QColor color("white");
|
||||
resTextEdit->setParagraphBackgroundColor(reslist_current+1, color);
|
||||
}
|
||||
QColor color("lightblue");
|
||||
resTextEdit->setParagraphBackgroundColor(par, color);
|
||||
|
||||
int reldocnum = par-1;
|
||||
reslist_current = reldocnum;
|
||||
previewTextEdit->clear();
|
||||
|
||||
if (rcldb->getDoc(reslist_winfirst + reldocnum, doc, 0)) {
|
||||
|
||||
// Go to the file system to retrieve / convert the document text
|
||||
// for preview:
|
||||
@@ -86,7 +85,7 @@ void RecollMain::resTextEdit_clicked( int par, int car )
|
||||
Rcl::Doc fdoc;
|
||||
if (!fun(rclconfig, fn, doc.mimetype, fdoc)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
QString("Failed to convert document for preview!\n") +
|
||||
QString("Failed to convert document for preview!\n") +
|
||||
fn.c_str() + " mimetype " +
|
||||
doc.mimetype.c_str());
|
||||
return;
|
||||
@@ -108,46 +107,24 @@ void RecollMain::resTextEdit_clicked( int par, int car )
|
||||
item->setColor("red");
|
||||
item->setFontWeight(QFont::Bold);
|
||||
#endif
|
||||
QString str = QString::fromUtf8(rich.c_str(), rich.length());
|
||||
|
||||
QString str = QString::fromUtf8(rich.c_str(), rich.length());
|
||||
previewTextEdit->setTextFormat(RichText);
|
||||
previewTextEdit->setText(str);
|
||||
}
|
||||
}
|
||||
|
||||
#include "pathut.h"
|
||||
|
||||
void RecollMain::queryText_returnPressed()
|
||||
{
|
||||
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
|
||||
resTextEdit->clear();
|
||||
previewTextEdit->clear();
|
||||
reslist_current = -1;
|
||||
reslist_winfirst = -1;
|
||||
|
||||
string rawq = queryText->text();
|
||||
rcldb->setQuery(rawq);
|
||||
Rcl::Doc doc;
|
||||
|
||||
// Insert results if any in result list window
|
||||
QString result;
|
||||
resTextEdit->append("<qt><head></head><body>");
|
||||
for (int i = 0;; i++) {
|
||||
doc.erase();
|
||||
if (!rcldb->getDoc(i, doc))
|
||||
break;
|
||||
LOGDEB(("Url: %s\n", doc.url.c_str()));
|
||||
LOGDEB(("Mimetype: \n", doc.mimetype.c_str()));
|
||||
LOGDEB(("Mtime: \n", doc.mtime.c_str()));
|
||||
LOGDEB(("Origcharset: \n", doc.origcharset.c_str()));
|
||||
LOGDEB(("Title: \n", doc.title.c_str()));
|
||||
LOGDEB(("Text: \n", doc.text.c_str()));
|
||||
LOGDEB(("Keywords: \n", doc.keywords.c_str()));
|
||||
LOGDEB(("Abstract: \n", doc.abstract.c_str()));
|
||||
|
||||
result = "<p>" + doc.url + "</p>";
|
||||
resTextEdit->append(result);
|
||||
}
|
||||
resTextEdit->append("</body></qt>");
|
||||
|
||||
// Display preview for 1st doc in list
|
||||
resTextEdit_clicked(0, 0);
|
||||
listNextPB_clicked();
|
||||
}
|
||||
|
||||
|
||||
@@ -155,3 +132,101 @@ void RecollMain::Search_clicked()
|
||||
{
|
||||
queryText_returnPressed();
|
||||
}
|
||||
|
||||
|
||||
static const int respagesize = 10;
|
||||
void RecollMain::listPrevPB_clicked()
|
||||
{
|
||||
reslist_winfirst -= 2*respagesize;
|
||||
listNextPB_clicked();
|
||||
}
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
void RecollMain::listNextPB_clicked()
|
||||
{
|
||||
LOGDEB(("listNextPB_clicked: winfirst %d\n", reslist_winfirst));
|
||||
|
||||
if (reslist_winfirst < 0)
|
||||
reslist_winfirst = 0;
|
||||
else
|
||||
reslist_winfirst += respagesize;
|
||||
|
||||
// Insert results if any in result list window
|
||||
bool gotone = false;
|
||||
for (int i = 0; i < respagesize; i++) {
|
||||
Rcl::Doc doc;
|
||||
doc.erase();
|
||||
int percent;
|
||||
if (!rcldb->getDoc(reslist_winfirst + i, doc, &percent))
|
||||
break;
|
||||
int resCnt = rcldb->getResCnt();
|
||||
int last = MIN(resCnt, reslist_winfirst+respagesize);
|
||||
if (i == 0) {
|
||||
resTextEdit->clear();
|
||||
previewTextEdit->clear();
|
||||
resTextEdit->append("<qt><head></head><body><p>");
|
||||
char line[80];
|
||||
sprintf(line, "<p><b>Displaying results %d-%d out of %d</b><br>",
|
||||
reslist_winfirst+1, last, resCnt);
|
||||
resTextEdit->append(line);
|
||||
}
|
||||
|
||||
gotone = true;
|
||||
|
||||
LOGDEB1(("Url: %s\n", doc.url.c_str()));
|
||||
LOGDEB1(("Mimetype: %s\n", doc.mimetype.c_str()));
|
||||
LOGDEB1(("Mtime: %s\n", doc.mtime.c_str()));
|
||||
LOGDEB1(("Origcharset: %s\n", doc.origcharset.c_str()));
|
||||
LOGDEB1(("Title: %s\n", doc.title.c_str()));
|
||||
LOGDEB1(("Text: %s\n", doc.text.c_str()));
|
||||
LOGDEB1(("Keywords: %s\n", doc.keywords.c_str()));
|
||||
LOGDEB1(("Abstract: %s\n", doc.abstract.c_str()));
|
||||
|
||||
// Result list display. Standard Omega includes:
|
||||
// - title or simple file name or url
|
||||
// - abstract and keywords
|
||||
// - url
|
||||
// - relevancy percentage + keywords matched
|
||||
// - date de modification
|
||||
// - langue
|
||||
// - taille
|
||||
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.mtime.empty()) {
|
||||
time_t mtime = atol(doc.mtime.c_str());
|
||||
struct tm *tm = localtime(&mtime);
|
||||
strftime(datebuf, 99, "<i>Modified:</i> %F %T", tm);
|
||||
}
|
||||
|
||||
string result = "<p>" +
|
||||
string(perbuf) + " <b>" + doc.title + "</b><br>" +
|
||||
(!doc.mtime.empty() ? string(datebuf) + "<br>" : string("")) +
|
||||
(!doc.abstract.empty() ? doc.abstract + "<br>" : string("")) +
|
||||
(!doc.keywords.empty() ? doc.keywords + "<br>" : string("")) +
|
||||
"<i>" + doc.url + +"</i><br>" +
|
||||
"</p>";
|
||||
QString str = QString::fromUtf8(result.c_str(), result.length());
|
||||
|
||||
resTextEdit->append(str);
|
||||
}
|
||||
|
||||
if (gotone) {
|
||||
resTextEdit->append("</body></qt>");
|
||||
resTextEdit->setCursorPosition(0,0);
|
||||
resTextEdit->ensureCursorVisible();
|
||||
// Display preview for 1st doc in list
|
||||
resTextEdit_clicked(1, 0);
|
||||
} else {
|
||||
// Restore first in win parameter that we shouln't have incremented
|
||||
reslist_winfirst -= respagesize;
|
||||
if (reslist_winfirst < 0)
|
||||
reslist_winfirst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user