fixed next/prev screen pb + pb with accents when matching in preview
This commit is contained in:
parent
4588803281
commit
3649eb415b
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: textsplit.cpp,v 1.7 2005-02-08 10:56:13 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: textsplit.cpp,v 1.8 2005-02-08 11:59:08 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
#ifndef TEST_TEXTSPLIT
|
#ifndef TEST_TEXTSPLIT
|
||||||
|
|
||||||
@ -295,13 +295,46 @@ static string teststring =
|
|||||||
"\n"
|
"\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
static string thisprog;
|
||||||
|
|
||||||
|
static string usage =
|
||||||
|
" textsplit [opts] [filename]\n"
|
||||||
|
" -q: query mode\n"
|
||||||
|
" \n\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
static void
|
||||||
|
Usage(void)
|
||||||
|
{
|
||||||
|
cerr << thisprog << ": usage:\n" << usage;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int op_flags;
|
||||||
|
#define OPT_q 0x1
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
thisprog = argv[0];
|
||||||
|
argc--; argv++;
|
||||||
|
|
||||||
|
while (argc > 0 && **argv == '-') {
|
||||||
|
(*argv)++;
|
||||||
|
if (!(**argv))
|
||||||
|
/* Cas du "adb - core" */
|
||||||
|
Usage();
|
||||||
|
while (**argv)
|
||||||
|
switch (*(*argv)++) {
|
||||||
|
case 'q': op_flags |= OPT_q; break;
|
||||||
|
default: Usage(); break;
|
||||||
|
}
|
||||||
|
argc--; argv++;
|
||||||
|
}
|
||||||
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
||||||
DebugLog::setfilename("stderr");
|
DebugLog::setfilename("stderr");
|
||||||
mySplitterCB cb;
|
mySplitterCB cb;
|
||||||
TextSplit splitter(&cb, true);
|
TextSplit splitter(&cb, (op_flags&OPT_q) ? true: false);
|
||||||
if (argc == 2) {
|
if (argc == 1) {
|
||||||
string data;
|
string data;
|
||||||
if (!file_to_string(argv[1], data))
|
if (!file_to_string(argv[1], data))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
@ -32,6 +32,10 @@ using std::pair;
|
|||||||
#include "textsplit.h"
|
#include "textsplit.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||||
|
#endif
|
||||||
|
|
||||||
void RecollMain::fileExit()
|
void RecollMain::fileExit()
|
||||||
{
|
{
|
||||||
LOGDEB1(("RecollMain: fileExit\n"));
|
LOGDEB1(("RecollMain: fileExit\n"));
|
||||||
@ -68,7 +72,9 @@ class myTextSplitCB : public TextSplitCB {
|
|||||||
virtual bool takeword(const std::string& term, int, int bts, int bte) {
|
virtual bool takeword(const std::string& term, int, int bts, int bte) {
|
||||||
for (list<string>::const_iterator it = terms->begin();
|
for (list<string>::const_iterator it = terms->begin();
|
||||||
it != terms->end(); it++) {
|
it != terms->end(); it++) {
|
||||||
if (!stringlowercmp(*it, term)) {
|
string dumb = term;
|
||||||
|
Rcl::dumb_string(term, dumb);
|
||||||
|
if (!stringlowercmp(*it, dumb)) {
|
||||||
tboffs.push_back(pair<int, int>(bts, bte));
|
tboffs.push_back(pair<int, int>(bts, bte));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -280,46 +286,53 @@ void RecollMain::clearqPB_clicked()
|
|||||||
static const int respagesize = 10;
|
static const int respagesize = 10;
|
||||||
void RecollMain::listPrevPB_clicked()
|
void RecollMain::listPrevPB_clicked()
|
||||||
{
|
{
|
||||||
|
if (reslist_winfirst <= 0)
|
||||||
|
return;
|
||||||
reslist_winfirst -= 2*respagesize;
|
reslist_winfirst -= 2*respagesize;
|
||||||
listNextPB_clicked();
|
listNextPB_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fill up result list window with next screen of hits
|
// Fill up result list window with next screen of hits
|
||||||
void RecollMain::listNextPB_clicked()
|
void RecollMain::listNextPB_clicked()
|
||||||
{
|
{
|
||||||
LOGDEB1(("listNextPB_clicked: winfirst %d\n", reslist_winfirst));
|
if (!rcldb)
|
||||||
|
return;
|
||||||
|
int percent;
|
||||||
|
Rcl::Doc doc;
|
||||||
|
rcldb->getDoc(0, doc, &percent);
|
||||||
|
int resCnt = rcldb->getResCnt();
|
||||||
|
LOGDEB(("listNextPB_clicked: rescnt %d, winfirst %d\n", resCnt,
|
||||||
|
reslist_winfirst));
|
||||||
|
|
||||||
|
// If we are already on the last page, nothing to do:
|
||||||
|
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt))
|
||||||
|
return;
|
||||||
|
|
||||||
if (reslist_winfirst < 0)
|
if (reslist_winfirst < 0)
|
||||||
reslist_winfirst = 0;
|
reslist_winfirst = 0;
|
||||||
else
|
else
|
||||||
reslist_winfirst += respagesize;
|
reslist_winfirst += respagesize;
|
||||||
|
|
||||||
// Insert results if any in result list window
|
|
||||||
bool gotone = false;
|
bool gotone = false;
|
||||||
for (int i = 0; i < respagesize; i++) {
|
reslistTE->clear();
|
||||||
Rcl::Doc doc;
|
previewTextEdit->clear();
|
||||||
|
int last = MIN(resCnt-reslist_winfirst, respagesize);
|
||||||
|
|
||||||
|
// Insert results if any in result list window
|
||||||
|
for (int i = 0; i < last; i++) {
|
||||||
doc.erase();
|
doc.erase();
|
||||||
int percent;
|
|
||||||
if (i == 0) {
|
|
||||||
reslistTE->clear();
|
|
||||||
previewTextEdit->clear();
|
|
||||||
}
|
|
||||||
if (!rcldb->getDoc(reslist_winfirst + i, doc, &percent)) {
|
if (!rcldb->getDoc(reslist_winfirst + i, doc, &percent)) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
reslist_winfirst = -1;
|
reslist_winfirst = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int resCnt = rcldb->getResCnt();
|
|
||||||
int last = MIN(resCnt, reslist_winfirst+respagesize);
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
reslistTE->append("<qt><head></head><body><p>");
|
reslistTE->append("<qt><head></head><body><p>");
|
||||||
char line[80];
|
char line[80];
|
||||||
sprintf(line, "<p><b>Displaying results %d-%d out of %d</b><br>",
|
sprintf(line, "<p><b>Displaying results %d-%d out of %d</b><br>",
|
||||||
reslist_winfirst+1, last, resCnt);
|
reslist_winfirst+1, reslist_winfirst+last, resCnt);
|
||||||
reslistTE->append(line);
|
reslistTE->append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +378,7 @@ void RecollMain::listNextPB_clicked()
|
|||||||
// Restore first in win parameter that we shouln't have incremented
|
// Restore first in win parameter that we shouln't have incremented
|
||||||
reslist_winfirst -= respagesize;
|
reslist_winfirst -= respagesize;
|
||||||
if (reslist_winfirst < 0)
|
if (reslist_winfirst < 0)
|
||||||
reslist_winfirst = 0;
|
reslist_winfirst = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.21 2005-02-08 10:56:12 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.22 2005-02-08 11:59:08 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -205,7 +205,7 @@ bool mySplitterCB::takeword(const std::string &term, int pos, int, int)
|
|||||||
// for accents, and do it by hand for upper / lower. Note lowercasing is
|
// for accents, and do it by hand for upper / lower. Note lowercasing is
|
||||||
// only for ascii letters anyway, so it's just A-Z -> a-z
|
// only for ascii letters anyway, so it's just A-Z -> a-z
|
||||||
// Removing crlfs is so that we can use the text in the document data fields.
|
// Removing crlfs is so that we can use the text in the document data fields.
|
||||||
bool dumb_string(const string &in, string &out)
|
bool Rcl::dumb_string(const string &in, string &out)
|
||||||
{
|
{
|
||||||
string inter;
|
string inter;
|
||||||
out.erase();
|
out.erase();
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
#ifndef _DB_H_INCLUDED_
|
#ifndef _DB_H_INCLUDED_
|
||||||
#define _DB_H_INCLUDED_
|
#define _DB_H_INCLUDED_
|
||||||
/* @(#$Id: rcldb.h,v 1.9 2005-02-07 13:17:47 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: rcldb.h,v 1.10 2005-02-08 11:59:08 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#ifndef NO_NAMESPACES
|
||||||
|
using std::string;
|
||||||
|
#endif
|
||||||
|
|
||||||
// rcldb defines an interface for a 'real' text database. The current
|
// rcldb defines an interface for a 'real' text database. The current
|
||||||
// implementation uses xapian only, and xapian-related code is in rcldb.cpp
|
// implementation uses xapian only, and xapian-related code is in rcldb.cpp
|
||||||
// If support was added for other backend, the xapian code would be moved in
|
// If support was added for other backend, the xapian code would be moved in
|
||||||
@ -28,15 +32,15 @@ namespace Rcl {
|
|||||||
class Doc {
|
class Doc {
|
||||||
public:
|
public:
|
||||||
// This fields potentially go into the document data record
|
// This fields potentially go into the document data record
|
||||||
std::string url;
|
string url;
|
||||||
std::string mimetype;
|
string mimetype;
|
||||||
std::string mtime; // Modification time as decimal ascii
|
string mtime; // Modification time as decimal ascii
|
||||||
std::string origcharset;
|
string origcharset;
|
||||||
std::string title;
|
string title;
|
||||||
std::string keywords;
|
string keywords;
|
||||||
std::string abstract;
|
string abstract;
|
||||||
|
|
||||||
std::string text;
|
string text;
|
||||||
void erase() {
|
void erase() {
|
||||||
url.erase();
|
url.erase();
|
||||||
mimetype.erase();
|
mimetype.erase();
|
||||||
@ -60,20 +64,20 @@ class Db {
|
|||||||
Db();
|
Db();
|
||||||
~Db();
|
~Db();
|
||||||
enum OpenMode {DbRO, DbUpd, DbTrunc};
|
enum OpenMode {DbRO, DbUpd, DbTrunc};
|
||||||
bool open(const std::string &dbdir, OpenMode mode);
|
bool open(const string &dbdir, OpenMode mode);
|
||||||
bool close();
|
bool close();
|
||||||
bool isopen();
|
bool isopen();
|
||||||
|
|
||||||
// Update-related functions
|
// Update-related functions
|
||||||
bool add(const std::string &filename, const Doc &doc);
|
bool add(const string &filename, const Doc &doc);
|
||||||
bool needUpdate(const std::string &filename, const struct stat *stp);
|
bool needUpdate(const string &filename, const struct stat *stp);
|
||||||
bool purge();
|
bool purge();
|
||||||
|
|
||||||
// Query-related functions
|
// Query-related functions
|
||||||
|
|
||||||
// Parse query string and initialize query
|
// Parse query string and initialize query
|
||||||
bool setQuery(const std::string &q);
|
bool setQuery(const string &q);
|
||||||
bool getQueryTerms(std::list<std::string>& terms);
|
bool getQueryTerms(std::list<string>& terms);
|
||||||
|
|
||||||
// Get document at rank i. This is probably vastly inferior to the type
|
// Get document at rank i. This is probably vastly inferior to the type
|
||||||
// of interface in Xapian, but we have to start with something simple
|
// of interface in Xapian, but we have to start with something simple
|
||||||
@ -83,6 +87,8 @@ class Db {
|
|||||||
int getResCnt();
|
int getResCnt();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Unaccent and lowercase data.
|
||||||
|
extern bool dumb_string(const string &in, string &out);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user