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