11
#include "cswordmodulesearch.h"
10
#include "backend/cswordmodulesearch.h"
12
#include "backend/config/cbtconfig.h"
13
13
#include "backend/drivers/cswordmoduleinfo.h"
14
14
#include "backend/managers/cswordbackend.h"
15
#include "backend/config/cbtconfig.h"
18
19
#include <swmodule.h>
23
22
CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
25
24
CSwordModuleSearch::CSwordModuleSearch()
26
: m_searchedText(QString::null),
25
: m_searchedText(QString::null),
33
31
CSwordModuleSearch::~CSwordModuleSearch() {
37
35
/** This function sets the modules which should be searched. */
38
36
void CSwordModuleSearch::setModules( const QList<CSwordModuleInfo*>& list ) {
42
40
/** Starts the search for the search text. */
43
41
bool CSwordModuleSearch::startSearch() {
44
backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
47
bool foundItems = false;
49
// for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
50
QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
52
for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
53
if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
58
m_foundItems = foundItems;
60
//m_finishedSig.activate();
42
backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
45
bool foundItems = false;
47
// for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
48
QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
50
for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
51
if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
56
m_foundItems = foundItems;
58
//m_finishedSig.activate();
65
63
/** Sets the text which should be search in the modules. */
66
64
void CSwordModuleSearch::setSearchedText( const QString& text ) {
67
m_searchedText = text;
65
m_searchedText = text;
70
68
/** Sets the search scope. */
71
69
void CSwordModuleSearch::setSearchScope( const sword::ListKey& scope ) {
72
m_searchScope.copyFrom( scope );
74
if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
78
//disable searching with a scope!
79
// if (m_searchOptions | useScope) {
80
// qWarning("using the scope!");
81
//set back the scope flag
70
m_searchScope.copyFrom( scope );
72
if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
76
//disable searching with a scope!
77
// if (m_searchOptions | useScope) {
78
// qWarning("using the scope!");
79
//set back the scope flag
86
84
/** Sets the search scope back. */
87
85
void CSwordModuleSearch::resetSearchScope() {
88
m_searchScope.ClearList();
86
m_searchScope.ClearList();
91
89
/** Returns true if in the last search the searcher found items, if no items were found return false. */
92
90
bool CSwordModuleSearch::foundItems() const {
96
94
/** Returns a copy of the used search scope. */
97
95
const sword::ListKey& CSwordModuleSearch::searchScope() const {
101
99
void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member ) {
102
//m_finishedSig.connect(receiver, member);
103
QObject::connect(this, SIGNAL(finished()), receiver, member);
106
/** Should be called when the search finished. */
107
void CSwordModuleSearch::searchFinished() {
108
//m_finishedSig.activate();
112
bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules )
114
bool hasIndices = true;
115
QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
116
for( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
117
if (!(*it)->hasIndex()) {
100
//m_finishedSig.connect(receiver, member);
101
QObject::connect(this, SIGNAL(finished()), receiver, member);
104
bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules ) {
105
bool hasIndices = true;
106
QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
107
for ( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
108
if (!(*it)->hasIndex()) {