|
a/src/qtgui/rclmain_w.cpp |
|
b/src/qtgui/rclmain_w.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.11 2006-12-04 09:56:26 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.12 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
99 |
if (prefs.reslistfontfamily.length()) {
|
99 |
if (prefs.reslistfontfamily.length()) {
|
100 |
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
100 |
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
101 |
resList->setFont(nfont);
|
101 |
resList->setFont(nfont);
|
102 |
}
|
102 |
}
|
103 |
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
103 |
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
104 |
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>)));
|
104 |
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
105 |
|
105 |
|
106 |
// signals and slots connections
|
106 |
// signals and slots connections
|
107 |
connect(sSearch, SIGNAL(clearSearch()),
|
107 |
connect(sSearch, SIGNAL(clearSearch()),
|
108 |
resList, SLOT(resetSearch()));
|
108 |
this, SLOT(resetSearch()));
|
109 |
connect(prevPageAction, SIGNAL(activated()),
|
109 |
connect(prevPageAction, SIGNAL(activated()),
|
110 |
resList, SLOT(resultPageBack()));
|
110 |
resList, SLOT(resultPageBack()));
|
111 |
connect(nextPageAction, SIGNAL(activated()),
|
111 |
connect(nextPageAction, SIGNAL(activated()),
|
112 |
resList, SLOT(resultPageNext()));
|
112 |
resList, SLOT(resultPageNext()));
|
113 |
|
113 |
|
|
... |
|
... |
163 |
// We also want to get rid of the advanced search form and previews
|
163 |
// We also want to get rid of the advanced search form and previews
|
164 |
// when we exit (not our children so that it's not systematically
|
164 |
// when we exit (not our children so that it's not systematically
|
165 |
// created over the main form).
|
165 |
// created over the main form).
|
166 |
bool RclMain::close(bool)
|
166 |
bool RclMain::close(bool)
|
167 |
{
|
167 |
{
|
168 |
prefs.mainwidth = width();
|
168 |
LOGDEB(("RclMain::close\n"));
|
169 |
prefs.mainheight = height();
|
|
|
170 |
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
|
|
|
171 |
fileExit();
|
169 |
fileExit();
|
172 |
return false;
|
170 |
return false;
|
173 |
}
|
171 |
}
|
174 |
|
172 |
|
175 |
//#define SHOWEVENTS
|
173 |
//#define SHOWEVENTS
|
|
... |
|
... |
259 |
#endif
|
257 |
#endif
|
260 |
|
258 |
|
261 |
void RclMain::fileExit()
|
259 |
void RclMain::fileExit()
|
262 |
{
|
260 |
{
|
263 |
LOGDEB1(("RclMain: fileExit\n"));
|
261 |
LOGDEB1(("RclMain: fileExit\n"));
|
|
|
262 |
prefs.mainwidth = width();
|
|
|
263 |
prefs.mainheight = height();
|
|
|
264 |
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem();
|
264 |
if (asearchform)
|
265 |
if (asearchform)
|
265 |
delete asearchform;
|
266 |
delete asearchform;
|
266 |
// Let the exit handler clean up things
|
267 |
// Let the exit handler clean up things
|
267 |
exit(0);
|
268 |
exit(0);
|
268 |
}
|
269 |
}
|
|
... |
|
... |
335 |
{
|
336 |
{
|
336 |
return url.substr(7, string::npos);
|
337 |
return url.substr(7, string::npos);
|
337 |
}
|
338 |
}
|
338 |
|
339 |
|
339 |
// Start a db query and set the reslist docsource
|
340 |
// Start a db query and set the reslist docsource
|
340 |
void RclMain::startAdvSearch(RefCntr<Rcl::SearchData> sdata)
|
341 |
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
341 |
{
|
342 |
{
|
342 |
LOGDEB(("RclMain::startAdvSearch\n"));
|
343 |
LOGDEB(("RclMain::startSearch\n"));
|
343 |
// The db may have been closed at the end of indexing
|
344 |
// The db may have been closed at the end of indexing
|
344 |
string reason;
|
345 |
string reason;
|
345 |
if (!maybeOpenDb(reason)) {
|
346 |
if (!maybeOpenDb(reason)) {
|
346 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
347 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
347 |
exit(1);
|
348 |
exit(1);
|
348 |
}
|
349 |
}
|
349 |
|
350 |
|
350 |
resList->resetSearch();
|
351 |
resList->resetSearch();
|
351 |
|
352 |
|
352 |
int qopts = 0;
|
353 |
int qopts = 0;
|
353 |
if (prefs.queryBuildAbstract && !sdata->fileNameOnly()) {
|
|
|
354 |
qopts |= Rcl::Db::QO_BUILD_ABSTRACT;
|
|
|
355 |
if (prefs.queryReplaceAbstract)
|
|
|
356 |
qopts |= Rcl::Db::QO_REPLACE_ABSTRACT;
|
|
|
357 |
}
|
|
|
358 |
if (!prefs.queryStemLang.length() == 0)
|
354 |
if (!prefs.queryStemLang.length() == 0)
|
359 |
qopts |= Rcl::Db::QO_STEM;
|
355 |
qopts |= Rcl::Db::QO_STEM;
|
360 |
|
356 |
|
361 |
if (!rcldb->setQuery(sdata, qopts, prefs.queryStemLang.ascii())) {
|
357 |
if (!rcldb->setQuery(sdata, qopts, prefs.queryStemLang.ascii())) {
|
362 |
QMessageBox::warning(0, "Recoll", tr("Cant start query: ") +
|
358 |
QMessageBox::warning(0, "Recoll", tr("Cant start query: ") +
|
363 |
QString::fromAscii(rcldb->getReason().c_str()));
|
359 |
QString::fromAscii(rcldb->getReason().c_str()));
|
364 |
return;
|
360 |
return;
|
365 |
}
|
361 |
}
|
366 |
curPreview = 0;
|
362 |
curPreview = 0;
|
|
|
363 |
m_searchData = sdata;
|
|
|
364 |
m_docSource = RefCntr<DocSequence>(new DocSequenceDb(rcldb, string(tr("Query results").utf8())));
|
|
|
365 |
setDocSequence();
|
|
|
366 |
}
|
367 |
|
367 |
|
|
|
368 |
void RclMain::resetSearch()
|
|
|
369 |
{
|
|
|
370 |
resList->resetSearch();
|
|
|
371 |
m_searchData = RefCntr<Rcl::SearchData>();
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
void RclMain::setDocSequence()
|
|
|
375 |
{
|
|
|
376 |
if (m_searchData.getcnt() == 0)
|
|
|
377 |
return;
|
368 |
DocSequence *docsource;
|
378 |
RefCntr<DocSequence> docsource;
|
369 |
if (sortspecs.sortwidth > 0) {
|
379 |
if (m_sortspecs.sortwidth > 0) {
|
370 |
DocSequenceDb myseq(rcldb, string(tr("Query results").utf8()));
|
380 |
docsource = RefCntr<DocSequence>(new DocSeqSorted(m_docSource,
|
371 |
docsource = new DocSeqSorted(myseq, sortspecs,
|
381 |
m_sortspecs,
|
372 |
string(tr("Query results (sorted)").utf8()));
|
382 |
string(tr("Query results (sorted)").utf8())));
|
373 |
} else {
|
383 |
} else {
|
374 |
docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8()));
|
384 |
docsource = m_docSource;
|
375 |
}
|
385 |
}
|
376 |
m_searchId++;
|
386 |
m_searchId++;
|
377 |
resList->setDocSource(docsource, sdata);
|
387 |
resList->setDocSource(docsource, m_searchData);
|
378 |
}
|
388 |
}
|
379 |
|
389 |
|
380 |
// Open advanced search dialog.
|
390 |
// Open advanced search dialog.
|
381 |
void RclMain::showAdvSearchDialog()
|
391 |
void RclMain::showAdvSearchDialog()
|
382 |
{
|
392 |
{
|
383 |
if (asearchform == 0) {
|
393 |
if (asearchform == 0) {
|
384 |
asearchform = new AdvSearch(0);
|
394 |
asearchform = new AdvSearch(0);
|
385 |
connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
395 |
connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
386 |
this, SLOT(startAdvSearch(RefCntr<Rcl::SearchData>)));
|
396 |
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
387 |
asearchform->show();
|
397 |
asearchform->show();
|
388 |
} else {
|
398 |
} else {
|
389 |
// Close and reopen, in hope that makes us visible...
|
399 |
// Close and reopen, in hope that makes us visible...
|
390 |
asearchform->close();
|
400 |
asearchform->close();
|
391 |
asearchform->show();
|
401 |
asearchform->show();
|
|
... |
|
... |
396 |
{
|
406 |
{
|
397 |
if (sortform == 0) {
|
407 |
if (sortform == 0) {
|
398 |
sortform = new SortForm(0);
|
408 |
sortform = new SortForm(0);
|
399 |
connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
409 |
connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
400 |
this, SLOT(sortDataChanged(DocSeqSortSpec)));
|
410 |
this, SLOT(sortDataChanged(DocSeqSortSpec)));
|
|
|
411 |
connect(sortform, SIGNAL(applySortData()),
|
|
|
412 |
this, SLOT(setDocSequence()));
|
401 |
sortform->show();
|
413 |
sortform->show();
|
402 |
} else {
|
414 |
} else {
|
403 |
// Close and reopen, in hope that makes us visible...
|
415 |
// Close and reopen, in hope that makes us visible...
|
404 |
sortform->close();
|
416 |
sortform->close();
|
405 |
sortform->show();
|
417 |
sortform->show();
|
|
... |
|
... |
720 |
string reason;
|
732 |
string reason;
|
721 |
if (!maybeOpenDb(reason)) {
|
733 |
if (!maybeOpenDb(reason)) {
|
722 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
734 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
723 |
exit(1);
|
735 |
exit(1);
|
724 |
}
|
736 |
}
|
725 |
|
|
|
726 |
DocSequence *docsource;
|
|
|
727 |
if (sortspecs.sortwidth > 0) {
|
|
|
728 |
DocSequenceHistory myseq(rcldb, g_dynconf,
|
|
|
729 |
string(tr("Document history").utf8()));
|
|
|
730 |
docsource = new
|
|
|
731 |
DocSeqSorted(myseq, sortspecs,
|
|
|
732 |
string(tr("Document history (sorted)").utf8()));
|
|
|
733 |
} else {
|
|
|
734 |
docsource = new
|
|
|
735 |
DocSequenceHistory(rcldb, g_dynconf,
|
|
|
736 |
string(tr("Document history").utf8()));
|
|
|
737 |
}
|
|
|
738 |
// Construct a bogus SearchData
|
737 |
// Construct a bogus SearchData structure
|
|
|
738 |
m_searchData =
|
739 |
RefCntr<Rcl::SearchData> sdata(new Rcl::SearchData(Rcl::SCLT_AND));
|
739 |
RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND));
|
740 |
sdata->setDescription((const char *)tr("History data").utf8());
|
740 |
m_searchData->setDescription((const char *)tr("History data").utf8());
|
|
|
741 |
|
741 |
m_searchId++;
|
742 |
m_searchId++;
|
742 |
resList->setDocSource(docsource, sdata);
|
743 |
|
|
|
744 |
m_docSource = RefCntr<DocSequence>(new DocSequenceHistory(rcldb,
|
|
|
745 |
g_dynconf,
|
|
|
746 |
string(tr("Document history").utf8())));
|
|
|
747 |
setDocSequence();
|
743 |
}
|
748 |
}
|
744 |
|
749 |
|
745 |
|
750 |
|
746 |
void RclMain::sortDataChanged(DocSeqSortSpec spec)
|
751 |
void RclMain::sortDataChanged(DocSeqSortSpec spec)
|
747 |
{
|
752 |
{
|
748 |
LOGDEB(("RclMain::sortDataChanged\n"));
|
753 |
LOGDEB(("RclMain::sortDataChanged\n"));
|
749 |
sortspecs = spec;
|
754 |
m_sortspecs = spec;
|
750 |
}
|
755 |
}
|
751 |
|
756 |
|
752 |
// Called when the uiprefs dialog is ok'd
|
757 |
// Called when the uiprefs dialog is ok'd
|
753 |
void RclMain::setUIPrefs()
|
758 |
void RclMain::setUIPrefs()
|
754 |
{
|
759 |
{
|