|
a/src/qtgui/rclmain_w.cpp |
|
b/src/qtgui/rclmain_w.cpp |
|
... |
|
... |
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#include "autoconfig.h"
|
17 |
#include "autoconfig.h"
|
18 |
|
18 |
|
19 |
#include <utility>
|
19 |
#include <utility>
|
20 |
#include MEMORY_INCLUDE
|
20 |
#include <memory>
|
21 |
#include <stdlib.h>
|
21 |
#include <stdlib.h>
|
22 |
|
22 |
|
23 |
#include <qapplication.h>
|
23 |
#include <qapplication.h>
|
24 |
#include <qmessagebox.h>
|
24 |
#include <qmessagebox.h>
|
25 |
#include <qfiledialog.h>
|
25 |
#include <qfiledialog.h>
|
|
... |
|
... |
65 |
#include "fragbuts.h"
|
65 |
#include "fragbuts.h"
|
66 |
#include "systray.h"
|
66 |
#include "systray.h"
|
67 |
#include "rclmain_w.h"
|
67 |
#include "rclmain_w.h"
|
68 |
#include "rclhelp.h"
|
68 |
#include "rclhelp.h"
|
69 |
#include "moc_rclmain_w.cpp"
|
69 |
#include "moc_rclmain_w.cpp"
|
70 |
|
|
|
71 |
/* Qt5 moc expands macros when defining signals. The SIGNAL() macro is
|
|
|
72 |
a stringification, so it does not expand macros. We have signals
|
|
|
73 |
where one of the types is a #define (for the variations on
|
|
|
74 |
std::shared_ptr). In qt5, the connection does not work because the
|
|
|
75 |
signal string is different between the definition and the connect
|
|
|
76 |
call, because of the different macro expansion. We have to use
|
|
|
77 |
another level of macro in Qt5 to force macro expansion, but not in
|
|
|
78 |
Qt4, so we both define the XSIGNAL and XSLOT macros here, and have
|
|
|
79 |
ifdefs in the code. What a mess... */
|
|
|
80 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
|
|
81 |
#define XSIGNAL(X) SIGNAL(X)
|
|
|
82 |
#define XSLOT(X) SLOT(X)
|
|
|
83 |
#endif
|
|
|
84 |
|
70 |
|
85 |
using std::pair;
|
71 |
using std::pair;
|
86 |
|
72 |
|
87 |
QString g_stringAllStem, g_stringNoStem;
|
73 |
QString g_stringAllStem, g_stringNoStem;
|
88 |
|
74 |
|
|
... |
|
... |
305 |
connect(sc, SIGNAL (activated()), sSearch, SLOT (takeFocus()));
|
291 |
connect(sc, SIGNAL (activated()), sSearch, SLOT (takeFocus()));
|
306 |
|
292 |
|
307 |
connect(&m_watcher, SIGNAL(fileChanged(QString)),
|
293 |
connect(&m_watcher, SIGNAL(fileChanged(QString)),
|
308 |
this, SLOT(updateIdxStatus()));
|
294 |
this, SLOT(updateIdxStatus()));
|
309 |
|
295 |
|
310 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
|
|
311 |
connect(sSearch,
|
296 |
connect(sSearch,
|
312 |
XSIGNAL(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)),
|
|
|
313 |
this, XSLOT(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)));
|
|
|
314 |
#else
|
|
|
315 |
connect(sSearch,
|
|
|
316 |
SIGNAL(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)),
|
297 |
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
317 |
this, SLOT(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)));
|
298 |
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
318 |
#endif
|
|
|
319 |
connect(sSearch, SIGNAL(clearSearch()),
|
299 |
connect(sSearch, SIGNAL(clearSearch()),
|
320 |
this, SLOT(resetSearch()));
|
300 |
this, SLOT(resetSearch()));
|
321 |
connect(preferencesMenu, SIGNAL(triggered(QAction*)),
|
301 |
connect(preferencesMenu, SIGNAL(triggered(QAction*)),
|
322 |
this, SLOT(setStemLang(QAction*)));
|
302 |
this, SLOT(setStemLang(QAction*)));
|
323 |
connect(preferencesMenu, SIGNAL(aboutToShow()),
|
303 |
connect(preferencesMenu, SIGNAL(aboutToShow()),
|
|
... |
|
... |
381 |
this, SLOT(periodic100()));
|
361 |
this, SLOT(periodic100()));
|
382 |
|
362 |
|
383 |
restable->setRclMain(this, true);
|
363 |
restable->setRclMain(this, true);
|
384 |
connect(actionSaveResultsAsCSV, SIGNAL(triggered()),
|
364 |
connect(actionSaveResultsAsCSV, SIGNAL(triggered()),
|
385 |
restable, SLOT(saveAsCSV()));
|
365 |
restable, SLOT(saveAsCSV()));
|
386 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
|
|
387 |
connect(this, XSIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
|
|
|
388 |
restable, XSLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
|
|
|
389 |
#else
|
|
|
390 |
connect(this, SIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
|
366 |
connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)),
|
391 |
restable, SLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
|
367 |
restable, SLOT(setDocSource(std::shared_ptr<DocSequence>)));
|
392 |
#endif
|
|
|
393 |
|
|
|
394 |
connect(this, SIGNAL(searchReset()),
|
368 |
connect(this, SIGNAL(searchReset()),
|
395 |
restable, SLOT(resetSource()));
|
369 |
restable, SLOT(resetSource()));
|
396 |
connect(this, SIGNAL(resultsReady()),
|
370 |
connect(this, SIGNAL(resultsReady()),
|
397 |
restable, SLOT(readDocSource()));
|
371 |
restable, SLOT(readDocSource()));
|
398 |
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
372 |
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
|
... |
|
... |
417 |
this, SLOT(saveDocToFile(Rcl::Doc)));
|
391 |
this, SLOT(saveDocToFile(Rcl::Doc)));
|
418 |
connect(restable, SIGNAL(showSnippets(Rcl::Doc)),
|
392 |
connect(restable, SIGNAL(showSnippets(Rcl::Doc)),
|
419 |
this, SLOT(showSnippets(Rcl::Doc)));
|
393 |
this, SLOT(showSnippets(Rcl::Doc)));
|
420 |
|
394 |
|
421 |
reslist->setRclMain(this, true);
|
395 |
reslist->setRclMain(this, true);
|
422 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
|
|
423 |
connect(this, XSIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
|
|
|
424 |
reslist, XSLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
|
|
|
425 |
#else
|
|
|
426 |
connect(this, SIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
|
396 |
connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)),
|
427 |
reslist, SLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
|
397 |
reslist, SLOT(setDocSource(std::shared_ptr<DocSequence>)));
|
428 |
#endif
|
|
|
429 |
connect(firstPageAction, SIGNAL(triggered()),
|
398 |
connect(firstPageAction, SIGNAL(triggered()),
|
430 |
reslist, SLOT(resultPageFirst()));
|
399 |
reslist, SLOT(resultPageFirst()));
|
431 |
connect(prevPageAction, SIGNAL(triggered()),
|
400 |
connect(prevPageAction, SIGNAL(triggered()),
|
432 |
reslist, SLOT(resPageUpOrBack()));
|
401 |
reslist, SLOT(resPageUpOrBack()));
|
433 |
connect(nextPageAction, SIGNAL(triggered()),
|
402 |
connect(nextPageAction, SIGNAL(triggered()),
|
|
... |
|
... |
692 |
// and scram out
|
661 |
// and scram out
|
693 |
_Exit(0);
|
662 |
_Exit(0);
|
694 |
}
|
663 |
}
|
695 |
|
664 |
|
696 |
// Start a db query and set the reslist docsource
|
665 |
// Start a db query and set the reslist docsource
|
697 |
void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple)
|
666 |
void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
698 |
{
|
667 |
{
|
699 |
LOGDEB("RclMain::startSearch. Indexing " << (m_idxproc?"on":"off") << " Active " << (m_queryActive) << "\n" );
|
668 |
LOGDEB("RclMain::startSearch. Indexing " << (m_idxproc?"on":"off") << " Active " << (m_queryActive) << "\n" );
|
700 |
if (m_queryActive) {
|
669 |
if (m_queryActive) {
|
701 |
LOGDEB("startSearch: already active\n" );
|
670 |
LOGDEB("startSearch: already active\n" );
|
702 |
return;
|
671 |
return;
|
703 |
}
|
672 |
}
|
704 |
m_queryActive = true;
|
673 |
m_queryActive = true;
|
705 |
restable->setEnabled(false);
|
674 |
restable->setEnabled(false);
|
706 |
m_source = STD_SHARED_PTR<DocSequence>();
|
675 |
m_source = std::shared_ptr<DocSequence>();
|
707 |
|
676 |
|
708 |
m_searchIsSimple = issimple;
|
677 |
m_searchIsSimple = issimple;
|
709 |
|
678 |
|
710 |
// The db may have been closed at the end of indexing
|
679 |
// The db may have been closed at the end of indexing
|
711 |
string reason;
|
680 |
string reason;
|
|
... |
|
... |
731 |
Rcl::Query *query = new Rcl::Query(rcldb);
|
700 |
Rcl::Query *query = new Rcl::Query(rcldb);
|
732 |
query->setCollapseDuplicates(prefs.collapseDuplicates);
|
701 |
query->setCollapseDuplicates(prefs.collapseDuplicates);
|
733 |
|
702 |
|
734 |
curPreview = 0;
|
703 |
curPreview = 0;
|
735 |
DocSequenceDb *src =
|
704 |
DocSequenceDb *src =
|
736 |
new DocSequenceDb(STD_SHARED_PTR<Rcl::Query>(query),
|
705 |
new DocSequenceDb(std::shared_ptr<Rcl::Query>(query),
|
737 |
string(tr("Query results").toUtf8()), sdata);
|
706 |
string(tr("Query results").toUtf8()), sdata);
|
738 |
src->setAbstractParams(prefs.queryBuildAbstract,
|
707 |
src->setAbstractParams(prefs.queryBuildAbstract,
|
739 |
prefs.queryReplaceAbstract);
|
708 |
prefs.queryReplaceAbstract);
|
740 |
m_source = STD_SHARED_PTR<DocSequence>(src);
|
709 |
m_source = std::shared_ptr<DocSequence>(src);
|
741 |
m_source->setSortSpec(m_sortspec);
|
710 |
m_source->setSortSpec(m_sortspec);
|
742 |
m_source->setFiltSpec(m_filtspec);
|
711 |
m_source->setFiltSpec(m_filtspec);
|
743 |
|
712 |
|
744 |
emit docSourceChanged(m_source);
|
713 |
emit docSourceChanged(m_source);
|
745 |
emit sortDataChanged(m_sortspec);
|
714 |
emit sortDataChanged(m_sortspec);
|
746 |
initiateQuery();
|
715 |
initiateQuery();
|
747 |
}
|
716 |
}
|
748 |
|
717 |
|
749 |
class QueryThread : public QThread {
|
718 |
class QueryThread : public QThread {
|
750 |
STD_SHARED_PTR<DocSequence> m_source;
|
719 |
std::shared_ptr<DocSequence> m_source;
|
751 |
public:
|
720 |
public:
|
752 |
QueryThread(STD_SHARED_PTR<DocSequence> source)
|
721 |
QueryThread(std::shared_ptr<DocSequence> source)
|
753 |
: m_source(source)
|
722 |
: m_source(source)
|
754 |
{
|
723 |
{
|
755 |
}
|
724 |
}
|
756 |
~QueryThread() { }
|
725 |
~QueryThread() { }
|
757 |
virtual void run()
|
726 |
virtual void run()
|
|
... |
|
... |
959 |
}
|
928 |
}
|
960 |
DocSequenceDocs *src =
|
929 |
DocSequenceDocs *src =
|
961 |
new DocSequenceDocs(rcldb, docs,
|
930 |
new DocSequenceDocs(rcldb, docs,
|
962 |
qs2utf8s(tr("Sub-documents and attachments")));
|
931 |
qs2utf8s(tr("Sub-documents and attachments")));
|
963 |
src->setDescription(qs2utf8s(tr("Sub-documents and attachments")));
|
932 |
src->setDescription(qs2utf8s(tr("Sub-documents and attachments")));
|
964 |
STD_SHARED_PTR<DocSequence>
|
933 |
std::shared_ptr<DocSequence>
|
965 |
source(new DocSource(theconfig, STD_SHARED_PTR<DocSequence>(src)));
|
934 |
source(new DocSource(theconfig, std::shared_ptr<DocSequence>(src)));
|
966 |
|
935 |
|
967 |
ResTable *res = new ResTable();
|
936 |
ResTable *res = new ResTable();
|
968 |
res->setRclMain(this, false);
|
937 |
res->setRclMain(this, false);
|
969 |
res->setDocSource(source);
|
938 |
res->setDocSource(source);
|
970 |
res->readDocSource();
|
939 |
res->readDocSource();
|
|
... |
|
... |
1001 |
|
970 |
|
1002 |
void RclMain::showDocHistory()
|
971 |
void RclMain::showDocHistory()
|
1003 |
{
|
972 |
{
|
1004 |
LOGDEB("RclMain::showDocHistory\n" );
|
973 |
LOGDEB("RclMain::showDocHistory\n" );
|
1005 |
emit searchReset();
|
974 |
emit searchReset();
|
1006 |
m_source = STD_SHARED_PTR<DocSequence>();
|
975 |
m_source = std::shared_ptr<DocSequence>();
|
1007 |
curPreview = 0;
|
976 |
curPreview = 0;
|
1008 |
|
977 |
|
1009 |
string reason;
|
978 |
string reason;
|
1010 |
if (!maybeOpenDb(reason)) {
|
979 |
if (!maybeOpenDb(reason)) {
|
1011 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
980 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
1012 |
return;
|
981 |
return;
|
1013 |
}
|
982 |
}
|
1014 |
// Construct a bogus SearchData structure
|
983 |
// Construct a bogus SearchData structure
|
1015 |
STD_SHARED_PTR<Rcl::SearchData>searchdata =
|
984 |
std::shared_ptr<Rcl::SearchData>searchdata =
|
1016 |
STD_SHARED_PTR<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND, cstr_null));
|
985 |
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND, cstr_null));
|
1017 |
searchdata->setDescription((const char *)tr("History data").toUtf8());
|
986 |
searchdata->setDescription((const char *)tr("History data").toUtf8());
|
1018 |
|
987 |
|
1019 |
|
988 |
|
1020 |
// If you change the title, also change it in eraseDocHistory()
|
989 |
// If you change the title, also change it in eraseDocHistory()
|
1021 |
DocSequenceHistory *src =
|
990 |
DocSequenceHistory *src =
|
1022 |
new DocSequenceHistory(rcldb, g_dynconf,
|
991 |
new DocSequenceHistory(rcldb, g_dynconf,
|
1023 |
string(tr("Document history").toUtf8()));
|
992 |
string(tr("Document history").toUtf8()));
|
1024 |
src->setDescription((const char *)tr("History data").toUtf8());
|
993 |
src->setDescription((const char *)tr("History data").toUtf8());
|
1025 |
DocSource *source = new DocSource(theconfig, STD_SHARED_PTR<DocSequence>(src));
|
994 |
DocSource *source = new DocSource(theconfig, std::shared_ptr<DocSequence>(src));
|
1026 |
m_source = STD_SHARED_PTR<DocSequence>(source);
|
995 |
m_source = std::shared_ptr<DocSequence>(source);
|
1027 |
m_source->setSortSpec(m_sortspec);
|
996 |
m_source->setSortSpec(m_sortspec);
|
1028 |
m_source->setFiltSpec(m_filtspec);
|
997 |
m_source->setFiltSpec(m_filtspec);
|
1029 |
emit docSourceChanged(m_source);
|
998 |
emit docSourceChanged(m_source);
|
1030 |
emit sortDataChanged(m_sortspec);
|
999 |
emit sortDataChanged(m_sortspec);
|
1031 |
initiateQuery();
|
1000 |
initiateQuery();
|