ckpt
This commit is contained in:
parent
75628a18bc
commit
6cfe82ad3e
@ -44,6 +44,24 @@ class myTextSplitCB : public TextSplitCB {
|
||||
}
|
||||
};
|
||||
|
||||
// Just strip/escape things that would look like markup
|
||||
string stripMarkup(const string &in)
|
||||
{
|
||||
string out;
|
||||
for (string::size_type pos = 0; pos < in.length(); pos++) {
|
||||
switch(in.at(pos)) {
|
||||
case '<':
|
||||
out += "<";
|
||||
break;
|
||||
case '&':
|
||||
out += "&";
|
||||
break;
|
||||
default:
|
||||
out += in.at(pos);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// Fix result text for display inside the gui text window.
|
||||
//
|
||||
@ -117,6 +135,11 @@ string plaintorich(const string &in, const list<string>& terms,
|
||||
out += "<";
|
||||
outcpos++;
|
||||
break;
|
||||
case '&':
|
||||
ateol = 0;
|
||||
out += "&";
|
||||
outcpos++;
|
||||
break;
|
||||
default:
|
||||
// We don't change the eol status for whitespace, want a real line
|
||||
if (*chariter == ' ' || *chariter == ' ') {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#ifndef _PLAINTORICH_H_INCLUDED_
|
||||
#define _PLAINTORICH_H_INCLUDED_
|
||||
/* @(#$Id: plaintorich.h,v 1.1 2005-09-22 16:22:34 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: plaintorich.h,v 1.2 2005-10-10 13:24:53 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -15,4 +15,6 @@ extern string plaintorich(const string &in,
|
||||
const list<string>& terms,
|
||||
list<pair<int, int> >&termoffsets);
|
||||
|
||||
extern string stripMarkup(const string &in);
|
||||
|
||||
#endif /* _PLAINTORICH_H_INCLUDED_ */
|
||||
|
||||
@ -60,6 +60,9 @@
|
||||
<property name="name">
|
||||
<cstring>pvEdit</cstring>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>WheelFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
** destructor.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "debuglog.h"
|
||||
|
||||
void Preview::init()
|
||||
{
|
||||
connect(pvTab, SIGNAL(currentChanged(QWidget *)),
|
||||
@ -19,14 +21,18 @@ void Preview::init()
|
||||
canBeep = true;
|
||||
}
|
||||
|
||||
extern int recollNeedsExit;
|
||||
|
||||
bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
if (event->type() != QEvent::KeyPress)
|
||||
return QWidget::eventFilter(target, event);
|
||||
|
||||
fprintf(stderr, "Preview::eventFilter: keyEvent\n");
|
||||
LOGDEB(("Preview::eventFilter: keyEvent\n"));
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (dynSearchActive) {
|
||||
if (keyEvent->key() == Key_Q && (keyEvent->state() & ControlButton)) {
|
||||
recollNeedsExit = 1;
|
||||
} else if (dynSearchActive) {
|
||||
if (keyEvent->key() == Key_F3) {
|
||||
doSearch(true, false);
|
||||
return true;
|
||||
@ -38,7 +44,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
QWidget *e = 0;
|
||||
if (tw)
|
||||
e = (QTextEdit *)tw->child("pvEdit");
|
||||
fprintf(stderr, "Widget: %p, edit %p, target %p\n", tw, e, target);
|
||||
LOGDEB(("Widget: %p, edit %p, target %p\n", tw, e, target));
|
||||
if (e && target == tw && keyEvent->key() == Key_Slash) {
|
||||
dynSearchActive = true;
|
||||
return true;
|
||||
@ -50,7 +56,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
|
||||
void Preview::searchTextLine_textChanged(const QString & text)
|
||||
{
|
||||
fprintf(stderr, "search line text changed. text: '%s'\n", text.ascii());
|
||||
LOGDEB(("search line text changed. text: '%s'\n", text.ascii()));
|
||||
if (text.isEmpty()) {
|
||||
dynSearchActive = false;
|
||||
} else {
|
||||
@ -66,8 +72,8 @@ void Preview::searchTextLine_textChanged(const QString & text)
|
||||
// starting from the current position
|
||||
void Preview::doSearch(bool next, bool reverse)
|
||||
{
|
||||
//fprintf(stderr, "Preview::doSearch: next %d rev %d\n",
|
||||
// int(next), int(reverse));
|
||||
//LOGDEB(("Preview::doSearch: next %d rev %d\n",
|
||||
// int(next), int(reverse)));
|
||||
QWidget *tw = pvTab->currentPage();
|
||||
QTextEdit *edit = 0;
|
||||
if (tw) {
|
||||
@ -97,7 +103,7 @@ void Preview::doSearch(bool next, bool reverse)
|
||||
int bogus;
|
||||
mspara = mepara;
|
||||
msindex = meindex;
|
||||
//fprintf(stderr, "New para: %d index %d\n", mspara, msindex);
|
||||
//LOGDEB(("New para: %d index %d\n", mspara, msindex));
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,14 +145,14 @@ void Preview::prevPressed()
|
||||
|
||||
void Preview::currentChanged(QWidget * tw)
|
||||
{
|
||||
QObject *o;
|
||||
o = tw->child("pvEdit");
|
||||
fprintf(stderr, "Preview::currentChanged(). Edit %p\n", o);
|
||||
QObject *o = tw->child("pvEdit");
|
||||
LOGDEB(("Preview::currentChanged(). Edit %p\n", o));
|
||||
|
||||
if (o == 0) {
|
||||
fprintf(stderr, "Editor child not found\n");
|
||||
LOGDEB(("Editor child not found\n"));
|
||||
} else {
|
||||
tw->installEventFilter(this);
|
||||
o->installEventFilter(this);
|
||||
((QWidget*)o)->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>160</width>
|
||||
<width>549</width>
|
||||
<height>750</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -22,8 +22,8 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<width>549</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="caption">
|
||||
@ -307,6 +307,7 @@
|
||||
</slots>
|
||||
<functions>
|
||||
<function access="private">init()</function>
|
||||
<function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
|
||||
</functions>
|
||||
<pixmapinproject/>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
|
||||
@ -47,6 +47,17 @@ void RecollMain::init()
|
||||
curPreview = 0;
|
||||
}
|
||||
|
||||
bool RecollMain::eventFilter( QObject * target, QEvent * event )
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (keyEvent->key() == Key_Q && (keyEvent->state() & ControlButton)) {
|
||||
recollNeedsExit = 1;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
void RecollMain::fileExit()
|
||||
{
|
||||
LOGDEB1(("RecollMain: fileExit\n"));
|
||||
@ -125,6 +136,7 @@ void RecollMain::reslistTE_doubleClicked(int par, int)
|
||||
system(ncmd.c_str());
|
||||
}
|
||||
|
||||
|
||||
// Display preview for the selected document, and highlight entry. The
|
||||
// paragraph number is doc number in window + 1
|
||||
void RecollMain::reslistTE_clicked(int par, int car)
|
||||
@ -222,7 +234,7 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
// first page of results
|
||||
void RecollMain::queryText_returnPressed()
|
||||
{
|
||||
LOGDEB1(("RecollMain::queryText_returnPressed()\n"));
|
||||
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
|
||||
if (!rcldb->isopen()) {
|
||||
string dbdir;
|
||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
@ -344,12 +356,13 @@ void RecollMain::listNextPB_clicked()
|
||||
struct tm *tm = localtime(&mtime);
|
||||
strftime(datebuf, 99, "<i>Modified:</i> %F %T", tm);
|
||||
}
|
||||
LOGDEB1(("Abstract: %s\n", doc.abstract.c_str()));
|
||||
string abst = stripMarkup(doc.abstract);
|
||||
LOGDEB(("Abstract: {%s}\n", abst.c_str()));
|
||||
string result = "<p>" +
|
||||
string(perbuf) + " <b>" + doc.title + "</b><br>" +
|
||||
doc.mimetype + " " +
|
||||
(!doc.mtime.empty() ? string(datebuf) + "<br>" : string("")) +
|
||||
(!doc.abstract.empty() ? doc.abstract + "<br>" : string("")) +
|
||||
(!doc.mtime.empty() ? string(datebuf) + "<br>" : string("<br>")) +
|
||||
(!abst.empty() ? abst + "<br>" : string("")) +
|
||||
(!doc.keywords.empty() ? doc.keywords + "<br>" : string("")) +
|
||||
"<i>" + doc.url + +"</i><br>" +
|
||||
"</p>";
|
||||
@ -358,6 +371,8 @@ void RecollMain::listNextPB_clicked()
|
||||
reslistTE->append(str);
|
||||
}
|
||||
|
||||
reslist_current = -1;
|
||||
|
||||
if (gotone) {
|
||||
reslistTE->append("</body></qt>");
|
||||
reslistTE->setCursorPosition(0,0);
|
||||
@ -366,6 +381,7 @@ void RecollMain::listNextPB_clicked()
|
||||
// reslistTE_clicked(1, 0);
|
||||
} else {
|
||||
// Restore first in win parameter that we shouln't have incremented
|
||||
reslistTE->append("<p><b>No results found</b><br>");
|
||||
reslist_winfirst -= respagesize;
|
||||
if (reslist_winfirst < 0)
|
||||
reslist_winfirst = -1;
|
||||
@ -400,3 +416,5 @@ void RecollMain::advSearchPB_clicked()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user