*** empty log message ***
This commit is contained in:
parent
e1c3dbfeb3
commit
dcb19d4fee
@ -1,14 +1,14 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** ui.h extension file, included from the uic-generated form implementation.
|
** ui.h extension file, included from the uic-generated form implementation.
|
||||||
**
|
**
|
||||||
** If you want to add, delete, or rename functions or slots, use
|
** If you want to add, delete, or rename functions or slots, use
|
||||||
** Qt Designer to update this file, preserving your code.
|
** Qt Designer to update this file, preserving your code.
|
||||||
**
|
**
|
||||||
** You should not define a constructor or destructor in this file.
|
** You should not define a constructor or destructor in this file.
|
||||||
** Instead, write your code in functions called init() and destroy().
|
** Instead, write your code in functions called init() and destroy().
|
||||||
** These will automatically be called by the form's constructor and
|
** These will automatically be called by the form's constructor and
|
||||||
** destructor.
|
** destructor.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -32,7 +32,9 @@ using std::pair;
|
|||||||
#include "textsplit.h"
|
#include "textsplit.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "utf8iter.h"
|
#include "utf8iter.h"
|
||||||
|
#include "transcode.h"
|
||||||
|
|
||||||
|
#include "unacpp.h"
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||||
#endif
|
#endif
|
||||||
@ -63,63 +65,110 @@ void RecollMain::fileStart_IndexingAction_activated()
|
|||||||
startindexing = 1;
|
startindexing = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text splitter callback used to take note of the query terms byte offsets
|
// Text splitter callback used to take note of the position of query terms
|
||||||
// inside the text. This is then used to post highlight tags.
|
// inside the result text. This is then used to post highlight tags.
|
||||||
class myTextSplitCB : public TextSplitCB {
|
class myTextSplitCB : public TextSplitCB {
|
||||||
public:
|
public:
|
||||||
list<pair<int, int> > tboffs;
|
const list<string> *terms; // in: query terms
|
||||||
const list<string> *terms;
|
list<pair<int, int> > tboffs; // out: begin and end positions of
|
||||||
myTextSplitCB(const list<string>& terms) : terms(&terms) {}
|
// query terms in text
|
||||||
virtual bool takeword(const std::string& term, int, int bts, int bte) {
|
|
||||||
|
myTextSplitCB(const list<string>& terms)
|
||||||
|
: terms(&terms) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callback called by the text-to-words breaker for each word
|
||||||
|
virtual bool takeword(const std::string& term, int pos, int bts, int bte) {
|
||||||
|
string dumb;
|
||||||
|
Rcl::dumb_string(term, dumb);
|
||||||
|
//LOGDEB(("Input dumbbed term: '%s' %d %d %d\n", dumb.c_str(),
|
||||||
|
// pos, bts, 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++) {
|
||||||
string dumb = term;
|
|
||||||
Rcl::dumb_string(term, dumb);
|
|
||||||
if (!stringlowercmp(*it, dumb)) {
|
if (!stringlowercmp(*it, dumb)) {
|
||||||
tboffs.push_back(pair<int, int>(bts, bte));
|
tboffs.push_back(pair<int, int>(bts, bte));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Fix result text for display inside the gui text window
|
||||||
static string plaintorich(const string &in, const list<string>& terms,
|
static string plaintorich(const string &in, const list<string>& terms,
|
||||||
list<pair<int, int> >&termoffsets)
|
list<pair<int, int> >&termoffsets)
|
||||||
{
|
{
|
||||||
LOGDEB(("plaintorich: terms: %s\n", stringlistdisp(terms).c_str()));
|
LOGDEB(("plaintorich: terms: %s\n",
|
||||||
|
stringlistdisp(terms).c_str()));
|
||||||
|
|
||||||
|
termoffsets.erase(termoffsets.begin(), termoffsets.end());
|
||||||
|
|
||||||
myTextSplitCB cb(terms);
|
myTextSplitCB cb(terms);
|
||||||
TextSplit splitter(&cb, true);
|
TextSplit splitter(&cb, true);
|
||||||
splitter.text_to_words(in);
|
splitter.text_to_words(in);
|
||||||
bool ateol = false;
|
|
||||||
|
for (list<pair<int, int> >::iterator li = cb.tboffs.begin();
|
||||||
|
li != cb.tboffs.end(); li++) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// State variable used to limitate the number of consecutive empty lines
|
||||||
|
int ateol = 0;
|
||||||
|
|
||||||
|
// Rich text output
|
||||||
string out = "<qt><head><title></title></head><body><p>";
|
string out = "<qt><head><title></title></head><body><p>";
|
||||||
|
|
||||||
|
// Iterator for the list of input term positions. We use it to
|
||||||
|
// output highlight tags and to compute term positions in the
|
||||||
|
// output text
|
||||||
list<pair<int, int> >::iterator it = cb.tboffs.begin();
|
list<pair<int, int> >::iterator it = cb.tboffs.begin();
|
||||||
for (unsigned int i = 0; i < in.length(); i++) {
|
|
||||||
|
// Storage for the current term position in output.
|
||||||
|
pair<int, int> opos;
|
||||||
|
int outbytepos; // This is the current position in output, excluding tags
|
||||||
|
for (unsigned int ibyteidx = 0; ibyteidx < in.length(); ibyteidx++) {
|
||||||
if (it != cb.tboffs.end()) {
|
if (it != cb.tboffs.end()) {
|
||||||
if (i == (unsigned int)it->first) {
|
if (ibyteidx == (unsigned int)it->first) {
|
||||||
out += "<termtag>";
|
out += "<termtag>";
|
||||||
} else if (i == (unsigned int)it->second) {
|
opos.first = outbytepos;
|
||||||
|
} else if (ibyteidx == (unsigned int)it->second) {
|
||||||
if (it != cb.tboffs.end())
|
if (it != cb.tboffs.end())
|
||||||
it++;
|
it++;
|
||||||
|
opos.second = outbytepos;
|
||||||
|
termoffsets.push_back(opos);
|
||||||
out += "</termtag>";
|
out += "</termtag>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (in[i] == '\n') {
|
switch(in[ibyteidx]) {
|
||||||
if (!ateol)
|
case '\n':
|
||||||
out += "<br>";
|
if (ateol < 2)
|
||||||
ateol = true;
|
out += "<br>\n";
|
||||||
} else {
|
ateol++;
|
||||||
ateol = false;
|
outbytepos++;
|
||||||
if (in[i] == '<') {
|
break;
|
||||||
out += "<";
|
case '\r': break;
|
||||||
} else
|
case '<':
|
||||||
out += in[i];
|
ateol = 0;
|
||||||
|
out += "<";
|
||||||
|
outbytepos++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ateol = 0;
|
||||||
|
out += in[ibyteidx];
|
||||||
|
outbytepos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
termoffsets = cb.tboffs;
|
{
|
||||||
LOGDEB(("plaintorich: text:\n%s\n", out.c_str()));
|
FILE *fp = fopen("/tmp/termsdeb", "w");
|
||||||
|
string unaced, ascii;
|
||||||
|
fprintf(fp, "plaintorich: text:\n%s\n", out.c_str());
|
||||||
|
unac_cpp(out, unaced);
|
||||||
|
fprintf(fp, "plaintorich: text:\n%s\n", unaced.c_str());
|
||||||
|
transcode(unaced, ascii, "UTF-8", "ASCII");
|
||||||
|
fprintf(fp, "plaintorich: text:\n%s\n", ascii.c_str());
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,13 +189,15 @@ void RecollMain::reslistTE_doubleClicked(int par, int)
|
|||||||
// Look for appropriate viewer
|
// Look for appropriate viewer
|
||||||
string cmd = getMimeViewer(doc.mimetype, rclconfig->getMimeConf());
|
string cmd = getMimeViewer(doc.mimetype, rclconfig->getMimeConf());
|
||||||
if (cmd.length() == 0) {
|
if (cmd.length() == 0) {
|
||||||
QMessageBox::warning(0, "Recoll", QString("No viewer for mime type ") +
|
QMessageBox::warning(0, "Recoll",
|
||||||
|
QString("No external viewer configured for mime"
|
||||||
|
" type ") +
|
||||||
doc.mimetype.c_str());
|
doc.mimetype.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fn = urltolocalpath(doc.url);
|
string fn = urltolocalpath(doc.url);
|
||||||
// substitute
|
// Substitute %u (url) and %f (file name) inside prototype command
|
||||||
string ncmd;
|
string ncmd;
|
||||||
string::const_iterator it1;
|
string::const_iterator it1;
|
||||||
for (it1 = cmd.begin(); it1 != cmd.end();it1++) {
|
for (it1 = cmd.begin(); it1 != cmd.end();it1++) {
|
||||||
@ -223,7 +274,7 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
|||||||
int para = 0, index = 1;
|
int para = 0, index = 1;
|
||||||
if (!termoffsets.empty()) {
|
if (!termoffsets.empty()) {
|
||||||
index = (termoffsets.begin())->first;
|
index = (termoffsets.begin())->first;
|
||||||
LOGDEB(("Byte index: %d\n", index));
|
LOGDEB(("Preview: Byte index for first term: %d\n", index));
|
||||||
// Translate byte to character offset
|
// Translate byte to character offset
|
||||||
string::size_type pos = 0;
|
string::size_type pos = 0;
|
||||||
Utf8Iter it(rich);
|
Utf8Iter it(rich);
|
||||||
@ -231,7 +282,7 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
|||||||
pos = it.getBpos();
|
pos = it.getBpos();
|
||||||
}
|
}
|
||||||
index = pos == string::npos ? 0 : it.getCpos();
|
index = pos == string::npos ? 0 : it.getCpos();
|
||||||
LOGDEB(("Setting cursor position to para %d, charindex %d\n",
|
LOGDEB(("Set cursor position: para %d, character index %d\n",
|
||||||
para,index));
|
para,index));
|
||||||
previewTextEdit->setCursorPosition(0, index);
|
previewTextEdit->setCursorPosition(0, index);
|
||||||
}
|
}
|
||||||
@ -403,3 +454,22 @@ void RecollMain::helpQuick_startAction_activated()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "advsearch.h"
|
||||||
|
|
||||||
|
advsearch *asearchform;
|
||||||
|
|
||||||
|
void RecollMain::advSearchPB_clicked()
|
||||||
|
{
|
||||||
|
if (asearchform == 0) {
|
||||||
|
// Couldn't find way to have a normal wm frame
|
||||||
|
asearchform = new advsearch(this, "Advanced search", FALSE,
|
||||||
|
WStyle_Customize | WStyle_NormalBorder |
|
||||||
|
WStyle_Title | WStyle_SysMenu);
|
||||||
|
asearchform->setSizeGripEnabled(FALSE);
|
||||||
|
asearchform->show();
|
||||||
|
} else {
|
||||||
|
asearchform->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user