|
a/src/qtgui/recollmain.ui.h |
|
b/src/qtgui/recollmain.ui.h |
|
... |
|
... |
12 |
|
12 |
|
13 |
#include <regex.h>
|
13 |
#include <regex.h>
|
14 |
#include <stdlib.h>
|
14 |
#include <stdlib.h>
|
15 |
#include <unistd.h>
|
15 |
#include <unistd.h>
|
16 |
#include <fcntl.h>
|
16 |
#include <fcntl.h>
|
|
|
17 |
#include <sys/stat.h>
|
17 |
|
18 |
|
18 |
#include <utility>
|
19 |
#include <utility>
|
19 |
using std::pair;
|
20 |
using std::pair;
|
20 |
|
21 |
|
21 |
#include <qmessagebox.h>
|
22 |
#include <qmessagebox.h>
|
22 |
#include <qcstring.h>
|
23 |
#include <qcstring.h>
|
23 |
#include <qtabwidget.h>
|
24 |
#include <qtabwidget.h>
|
24 |
#include <qtimer.h>
|
25 |
#include <qtimer.h>
|
|
|
26 |
#include <qstatusbar.h>
|
|
|
27 |
#include <qwindowdefs.h>
|
25 |
|
28 |
|
26 |
#include "rcldb.h"
|
29 |
#include "rcldb.h"
|
27 |
#include "rclconfig.h"
|
30 |
#include "rclconfig.h"
|
28 |
#include "debuglog.h"
|
31 |
#include "debuglog.h"
|
29 |
#include "mimehandler.h"
|
32 |
#include "mimehandler.h"
|
|
... |
|
... |
33 |
#include "smallut.h"
|
36 |
#include "smallut.h"
|
34 |
#include "plaintorich.h"
|
37 |
#include "plaintorich.h"
|
35 |
#include "unacpp.h"
|
38 |
#include "unacpp.h"
|
36 |
#include "advsearch.h"
|
39 |
#include "advsearch.h"
|
37 |
|
40 |
|
|
|
41 |
extern "C" int XFlush(void *);
|
38 |
|
42 |
|
39 |
#ifndef MIN
|
43 |
#ifndef MIN
|
40 |
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
44 |
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
41 |
#endif
|
45 |
#endif
|
42 |
|
46 |
|
|
... |
|
... |
261 |
ncmd += *it1;
|
265 |
ncmd += *it1;
|
262 |
}
|
266 |
}
|
263 |
}
|
267 |
}
|
264 |
|
268 |
|
265 |
ncmd += " &";
|
269 |
ncmd += " &";
|
266 |
LOGDEB(("Executing: '%s'\n", ncmd.c_str()));
|
270 |
QStatusBar *stb = statusBar();
|
|
|
271 |
if (stb) {
|
|
|
272 |
string msg = string("Executing: [") + ncmd.c_str() + "]";
|
|
|
273 |
stb->message(msg.c_str(), 5000);
|
|
|
274 |
stb->repaint(false);
|
|
|
275 |
XFlush(qt_xdisplay());
|
|
|
276 |
}
|
267 |
system(ncmd.c_str());
|
277 |
system(ncmd.c_str());
|
268 |
}
|
278 |
}
|
269 |
|
279 |
|
270 |
|
280 |
|
271 |
// Display preview for the selected document, and highlight entry. The
|
281 |
// Display preview for the selected document, and highlight entry. The
|
272 |
// paragraph number is doc number in window + 1
|
282 |
// paragraph number is doc number in window + 1
|
|
|
283 |
// We don't actually do anything but start a timer because we want to
|
|
|
284 |
// check first if this might be a double click
|
273 |
void RecollMain::reslistTE_clicked(int par, int car)
|
285 |
void RecollMain::reslistTE_clicked(int par, int car)
|
274 |
{
|
286 |
{
|
275 |
if (reslistTE_waitingdbl)
|
287 |
if (reslistTE_waitingdbl)
|
276 |
return;
|
288 |
return;
|
277 |
LOGDEB(("RecollMain::reslistTE_clckd:winfirst %d par %d char %d drg %d\n",
|
289 |
LOGDEB(("RecollMain::reslistTE_clckd:winfirst %d par %d char %d drg %d\n",
|
|
... |
|
... |
283 |
reslistTE_par = par;
|
295 |
reslistTE_par = par;
|
284 |
reslistTE_car = car;
|
296 |
reslistTE_car = car;
|
285 |
reslistTE_waitingdbl = true;
|
297 |
reslistTE_waitingdbl = true;
|
286 |
reslistTE_dblclck = false;
|
298 |
reslistTE_dblclck = false;
|
287 |
// Wait to see if there's going to be a dblclck
|
299 |
// Wait to see if there's going to be a dblclck
|
288 |
QTimer::singleShot(100, this, SLOT(reslistTE_delayedclick()) );
|
300 |
QTimer::singleShot(150, this, SLOT(reslistTE_delayedclick()) );
|
289 |
|
|
|
290 |
}
|
301 |
}
|
291 |
|
302 |
|
292 |
|
303 |
|
293 |
// User asked to start query. Run it and call listNextPB_clicked to display
|
304 |
// User asked to start query. Send it to the db aand call
|
294 |
// first page of results
|
305 |
// listNextPB_clicked to fetch and display the first page of results
|
295 |
void RecollMain::queryText_returnPressed()
|
306 |
void RecollMain::queryText_returnPressed()
|
296 |
{
|
307 |
{
|
297 |
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
|
308 |
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
|
298 |
string reason;
|
309 |
string reason;
|
299 |
if (!maybeOpenDb(reason)) {
|
310 |
if (!maybeOpenDb(reason)) {
|
|
... |
|
... |
336 |
|
347 |
|
337 |
|
348 |
|
338 |
// Fill up result list window with next screen of hits
|
349 |
// Fill up result list window with next screen of hits
|
339 |
void RecollMain::listNextPB_clicked()
|
350 |
void RecollMain::listNextPB_clicked()
|
340 |
{
|
351 |
{
|
341 |
fprintf(stderr, "listNextPB_clicked\n");
|
|
|
342 |
if (!rcldb)
|
352 |
if (!rcldb)
|
343 |
return;
|
353 |
return;
|
|
|
354 |
|
344 |
int percent;
|
355 |
int percent;
|
345 |
Rcl::Doc doc;
|
356 |
Rcl::Doc doc;
|
|
|
357 |
|
|
|
358 |
// Need to fetch one document before we can get the result count
|
346 |
rcldb->getDoc(0, doc, &percent);
|
359 |
rcldb->getDoc(0, doc, &percent);
|
347 |
int resCnt = rcldb->getResCnt();
|
360 |
int resCnt = rcldb->getResCnt();
|
348 |
fprintf(stderr, "listNextPB_clicked rescnt\n");
|
361 |
|
349 |
LOGDEB(("listNextPB_clicked: rescnt %d, winfirst %d\n", resCnt,
|
362 |
LOGDEB(("listNextPB_clicked: rescnt %d, winfirst %d\n", resCnt,
|
350 |
reslist_winfirst));
|
363 |
reslist_winfirst));
|
351 |
|
364 |
|
352 |
// If we are already on the last page, nothing to do:
|
365 |
// If we are already on the last page, nothing to do:
|
353 |
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt))
|
366 |
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt))
|
|
... |
|
... |
373 |
break;
|
386 |
break;
|
374 |
}
|
387 |
}
|
375 |
if (i == 0) {
|
388 |
if (i == 0) {
|
376 |
reslistTE->append("<qt><head></head><body><p>");
|
389 |
reslistTE->append("<qt><head></head><body><p>");
|
377 |
char line[80];
|
390 |
char line[80];
|
378 |
sprintf(line, "<p><b>Displaying results starting at index %d (maximum set size %d)</b><br>",
|
391 |
sprintf(line, "<p><b>Displaying results starting at index"
|
|
|
392 |
" %d (maximum set size %d)</b><br>",
|
379 |
reslist_winfirst+1, resCnt);
|
393 |
reslist_winfirst+1, resCnt);
|
380 |
reslistTE->append(line);
|
394 |
reslistTE->append(line);
|
381 |
}
|
395 |
}
|
382 |
|
396 |
|
383 |
gotone = true;
|
397 |
gotone = true;
|
|
... |
|
... |
456 |
} else {
|
470 |
} else {
|
457 |
asearchform->show();
|
471 |
asearchform->show();
|
458 |
}
|
472 |
}
|
459 |
}
|
473 |
}
|
460 |
|
474 |
|
461 |
// Execute and advanced search query
|
475 |
// Execute an advanced search query. The parameters normally come from
|
|
|
476 |
// the advanced search dialog
|
462 |
void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
|
477 |
void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
|
463 |
{
|
478 |
{
|
464 |
LOGDEB(("RecollMain::startAdvSearch\n"));
|
479 |
LOGDEB(("RecollMain::startAdvSearch\n"));
|
465 |
string reason;
|
480 |
string reason;
|
466 |
if (!maybeOpenDb(reason)) {
|
481 |
if (!maybeOpenDb(reason)) {
|
|
... |
|
... |
493 |
return;
|
508 |
return;
|
494 |
}
|
509 |
}
|
495 |
|
510 |
|
496 |
int par = reslistTE_par;
|
511 |
int par = reslistTE_par;
|
497 |
|
512 |
|
498 |
Rcl::Doc doc;
|
|
|
499 |
if (reslist_current != -1) {
|
513 |
if (reslist_current != -1) {
|
500 |
QColor color("white");
|
514 |
QColor color("white");
|
501 |
reslistTE->setParagraphBackgroundColor(reslist_current+1, color);
|
515 |
reslistTE->setParagraphBackgroundColor(reslist_current+1, color);
|
502 |
}
|
516 |
}
|
503 |
QColor color("lightblue");
|
517 |
QColor color("lightblue");
|
|
... |
|
... |
506 |
int reldocnum = par - 1;
|
520 |
int reldocnum = par - 1;
|
507 |
if (curPreview && reslist_current == reldocnum)
|
521 |
if (curPreview && reslist_current == reldocnum)
|
508 |
return;
|
522 |
return;
|
509 |
|
523 |
|
510 |
reslist_current = reldocnum;
|
524 |
reslist_current = reldocnum;
|
|
|
525 |
startPreview(reslist_winfirst + reldocnum);
|
|
|
526 |
}
|
511 |
|
527 |
|
|
|
528 |
|
|
|
529 |
// Open a preview window for a given document
|
|
|
530 |
// docnum is a db query index
|
|
|
531 |
void RecollMain::startPreview(int docnum)
|
|
|
532 |
{
|
|
|
533 |
Rcl::Doc doc;
|
512 |
if (!rcldb->getDoc(reslist_winfirst + reldocnum, doc, 0)) {
|
534 |
if (!rcldb->getDoc(docnum, doc, 0)) {
|
513 |
QMessageBox::warning(0, "Recoll",
|
535 |
QMessageBox::warning(0, "Recoll",
|
514 |
QString("Can't retrieve document from database"));
|
536 |
QString("Cannot retrieve document info"
|
|
|
537 |
" from database"));
|
515 |
return;
|
538 |
return;
|
516 |
}
|
539 |
}
|
517 |
|
540 |
|
518 |
// Go to the file system to retrieve / convert the document text
|
541 |
// Go to the file system to retrieve / convert the document text
|
519 |
// for preview:
|
542 |
// for preview:
|
520 |
string fn = urltolocalpath(doc.url);
|
543 |
string fn = urltolocalpath(doc.url);
|
|
|
544 |
struct stat st;
|
|
|
545 |
if (stat(fn.c_str(), &st) < 0) {
|
|
|
546 |
QMessageBox::warning(0, "Recoll",
|
|
|
547 |
QString("Cannot access document file: ") +
|
|
|
548 |
fn.c_str());
|
|
|
549 |
return;
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
QStatusBar *stb = statusBar();
|
|
|
553 |
if (stb) {
|
|
|
554 |
char csz[20];
|
|
|
555 |
sprintf(csz, "%lu", (unsigned long)st.st_size);
|
|
|
556 |
string msg = string("Loading: ") + fn + " (size " + csz
|
|
|
557 |
+ " bytes)";
|
|
|
558 |
stb->message(msg.c_str());
|
|
|
559 |
stb->repaint(false);
|
|
|
560 |
XFlush(qt_xdisplay());
|
|
|
561 |
}
|
|
|
562 |
|
521 |
Rcl::Doc fdoc;
|
563 |
Rcl::Doc fdoc;
|
522 |
FileInterner interner(fn, rclconfig, tmpdir);
|
564 |
FileInterner interner(fn, rclconfig, tmpdir);
|
523 |
if (interner.internfile(fdoc, doc.ipath) != FileInterner::FIDone) {
|
565 |
if (interner.internfile(fdoc, doc.ipath) != FileInterner::FIDone) {
|
524 |
QMessageBox::warning(0, "Recoll",
|
566 |
QMessageBox::warning(0, "Recoll",
|
525 |
QString("Can't turn doc into internal rep ") +
|
567 |
QString("Can't turn doc into internal rep ") +
|
526 |
doc.mimetype.c_str());
|
568 |
doc.mimetype.c_str());
|
527 |
return;
|
569 |
return;
|
528 |
}
|
570 |
}
|
|
|
571 |
|
|
|
572 |
if (stb)
|
|
|
573 |
stb->clear();
|
|
|
574 |
|
529 |
list<string> terms;
|
575 |
list<string> terms;
|
530 |
rcldb->getQueryTerms(terms);
|
576 |
rcldb->getQueryTerms(terms);
|
531 |
list<pair<int, int> > termoffsets;
|
577 |
list<pair<int, int> > termoffsets;
|
532 |
string rich = plaintorich(fdoc.text, terms, termoffsets);
|
578 |
string rich = plaintorich(fdoc.text, terms, termoffsets);
|
533 |
|
579 |
|